perf(profiling): avoid FFI call on allocation hot path - #4068
Conversation
Read executor_globals.current_execute_data directly on NTS builds instead of calling through the C FFI wrapper for every allocation and reallocation. Keep the existing wrapper on ZTS builds. A 60-second macOS sample reduced get_current_execute_data self time from 0.412% (207/50,210 main-thread samples) to 0.002% (1/49,737). Known allocation-hook self time fell from 4.184% to 3.601%, a 13.9% relative reduction. Repeated end-to-end throughput remained within system scheduling noise. Validation: cargo test (22 passed); allocation sampling-distance, memory-peak, and GC PHPTs passed.
|
Benchmarks [ profiler ]Benchmark execution time: 2026-07-27 15:06:26 Comparing candidate commit 241f72a in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 28 metrics, 8 unstable metrics.
|
bwoebi
left a comment
There was a problem hiding this comment.
Looks good. Now we need to also inline the ZTS path :-)
Description
Read
executor_globals.current_execute_datadirectly on NTS builds instead of calling through the C FFI wrapper for every allocation and reallocation. Keep the existing wrapper on ZTS builds.A 60-second macOS sample reduced
get_current_execute_dataself time from 0.412% (207/50,210 main-thread samples) to 0.002% (1/49,737). Known allocation-hook self time fell from 4.184% to 3.601%, a 13.9% relative reduction. Repeated end-to-end throughput remained within system scheduling noise.Reviewer checklist
https://datadoghq.atlassian.net/browse/PROF-15505