Skip to content

Commit 1316514

Browse files
feat(prof): optimise allocation profiling for PHP >= 8.4 (#3550)
* fix PHP 8.4 allocation profiling * add correctness with another custom allocater * remove tls prepare access * fix clippy warning * cleanup disable due to JIT code * cleanup more code and leave some safety comments * no gshutdown function anymore * Add some explaining comments * fix: unused imports after merge * fix: conditional import after merge --------- Co-authored-by: Levi Morrison <[email protected]>
1 parent 7ae15a5 commit 1316514

5 files changed

Lines changed: 200 additions & 224 deletions

File tree

.github/workflows/prof_correctness.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ jobs:
102102
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/allocations_1byte/test.pprof
103103
export DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE=1
104104
php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/allocations.php
105+
mkdir -p profiling/tests/correctness/allocations_1byte_no_zend_alloc/
106+
export DD_PROFILING_OUTPUT_PPROF=$PWD/profiling/tests/correctness/allocations_1byte_no_zend_alloc/test.pprof
107+
export DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE=1
108+
USE_ZEND_ALLOC=0 php -d extension=$PWD/target/profiler-release/libdatadog_php_profiling.so profiling/tests/correctness/allocations.php
105109
unset DD_PROFILING_ALLOCATION_SAMPLING_DISTANCE
106110
107111
- name: Run ZTS tests
@@ -131,6 +135,12 @@ jobs:
131135
expected_json: profiling/tests/correctness/allocations.json
132136
pprof_path: profiling/tests/correctness/allocations_1byte/
133137

138+
- name: Check profiler correctness for allocations with 1 byte sampling distance and `USE_ZEND_ALLOC=0`
139+
uses: Datadog/prof-correctness/analyze@main
140+
with:
141+
expected_json: profiling/tests/correctness/allocations.json
142+
pprof_path: profiling/tests/correctness/allocations_1byte_no_zend_alloc/
143+
134144
- name: Check profiler correctness for time
135145
uses: Datadog/prof-correctness/analyze@main
136146
with:

profiling/build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,7 @@ fn cfg_php_feature_flags(vernum: u64) {
400400
if vernum >= 80400 {
401401
println!("cargo:rustc-cfg=php_frameless");
402402
println!("cargo:rustc-cfg=php_opcache_restart_hook");
403-
// Commenting the following line temporary disables the new hooking mechanism for
404-
// allocation profiling until we solved the intefereing with
405-
// `memory_get_usage()`/`memory_get_peak_usage()`
406-
// println!("cargo:rustc-cfg=php_zend_mm_set_custom_handlers_ex");
403+
println!("cargo:rustc-cfg=php_zend_mm_set_custom_handlers_ex");
407404
}
408405
}
409406

0 commit comments

Comments
 (0)