|
| 1 | +--TEST-- |
| 2 | +[profiling] heap live profiling with active JIT |
| 3 | +--DESCRIPTION-- |
| 4 | +Verify that heap live profiling is disabled if allocation profiling is disabled due to the JIT bug workaround, |
| 5 | +and works normally otherwise. |
| 6 | +--SKIPIF-- |
| 7 | +<?php |
| 8 | +if (!extension_loaded('datadog-profiling')) |
| 9 | + echo "skip: test requires Datadog Continuous Profiler\n"; |
| 10 | +if (PHP_VERSION_ID < 80000) |
| 11 | + echo "skip: JIT requires PHP >= 8.0\n"; |
| 12 | + |
| 13 | +$affected = (PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80121) |
| 14 | + || (PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80208) |
| 15 | + || (PHP_VERSION_ID >= 80400 && PHP_VERSION_ID < 80407); |
| 16 | + |
| 17 | +if (!$affected) { |
| 18 | + echo "skip: JIT workaround is inactive on this PHP version\n"; |
| 19 | +} |
| 20 | +?> |
| 21 | +--ENV-- |
| 22 | +DD_PROFILING_ENABLED=yes |
| 23 | +DD_PROFILING_ALLOCATION_ENABLED=yes |
| 24 | +DD_PROFILING_EXPERIMENTAL_HEAP_LIVE_ENABLED=yes |
| 25 | +DD_PROFILING_EXPERIMENTAL_CPU_TIME_ENABLED=no |
| 26 | +--INI-- |
| 27 | +assert.exception=1 |
| 28 | +zend_extension=opcache |
| 29 | +opcache.enable_cli=1 |
| 30 | +opcache.jit=tracing |
| 31 | +opcache.jit_buffer_size=4M |
| 32 | +--FILE-- |
| 33 | +<?php |
| 34 | + |
| 35 | +ob_start(); |
| 36 | +$extension = new ReflectionExtension('datadog-profiling'); |
| 37 | +$extension->info(); |
| 38 | +$output = ob_get_clean(); |
| 39 | + |
| 40 | +$lines = preg_split("/\R/", $output); |
| 41 | +$values = []; |
| 42 | +foreach ($lines as $line) { |
| 43 | + $pair = explode("=>", $line); |
| 44 | + if (count($pair) != 2) { |
| 45 | + continue; |
| 46 | + } |
| 47 | + $values[trim($pair[0])] = trim($pair[1]); |
| 48 | +} |
| 49 | + |
| 50 | +$allocation_enabled = $values["Allocation Profiling Enabled"]; |
| 51 | +$heap_live_enabled = $values["Experimental Heap Live Profiling Enabled"]; |
| 52 | + |
| 53 | +var_dump($allocation_enabled); |
| 54 | +var_dump($heap_live_enabled); |
| 55 | + |
| 56 | +// If allocation profiling is not fully active, then heap live profiling MUST NOT be active |
| 57 | +if ($allocation_enabled !== "true") { |
| 58 | + assert($heap_live_enabled === "false (requires allocation profiling)"); |
| 59 | +} else { |
| 60 | + assert($heap_live_enabled === "true"); |
| 61 | +} |
| 62 | + |
| 63 | +echo "Done."; |
| 64 | + |
| 65 | +?> |
| 66 | +--EXPECTF-- |
| 67 | +string(%d) "%s" |
| 68 | +string(%d) "%s" |
| 69 | +Done. |
0 commit comments