perf(profiling): speed up ddprof_time sample processing - #4194
realFlowControl wants to merge 11 commits into
Conversation
Profiling the full PHP process under the reverted I/O upscaling workload showed that ddprof_time spent 912 of 2823 active samples (32%) hashing ProfileIndex with SipHash. Use the already available FxHashMap for the internal profile map. The map normally contains one trusted, low-cardinality key, so SipHash's collision resistance adds cost without useful protection. In matched process profiles, active ddprof_time samples fell from 2823 to 2056 (-27%). Across three 100x workloads, median PHP user CPU fell from 14.94s to 14.07s (-5.8%).
Build ProfileIndex and its semantic hash once per request instead of rebuilding and hashing all sample types and tags for every sample. Equal profile identities from different requests still compare equal and aggregate into the same profile. The full-process profile showed ddprof_time message-processing samples fall from 2056 to 1451 (-29.4%). Median PHP user CPU fell from 14.07s to 12.57s (-10.7%).
After select wakes ddprof_time, process up to the bounded channel capacity before returning to select. This amortizes channel registration and timer checks while limiting timer delay to 100 messages. Estimated active ddprof_time CPU fell from 2061 to 1984 samples (-3.7%). Median PHP user CPU fell from 12.57s to 12.35s (-1.8%), and stress-run drops fell from 3/68/350 to 0/0/1.
Keep normal sample frames and labels directly owned instead of allocating two Arc wrappers per sample. Promote them to Arc only when experimental heap-live tracking needs to share the payload with the allocation tracker. Median PHP user CPU fell from 12.35s to 11.90s (-3.6%). The full-process profile no longer showed Arc<Backtrace>::drop_slow, and stress-run drops fell from 0/0/1 to 0/0/0.
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 10 Pipeline jobs failed
ℹ️ InfoNo other issues found (see more)🧪 All tests passed 🎯 Code Coverage (details) Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: 6c35136 | Docs | View more details | Give us feedback! |
Benchmarks [ profiler ]Benchmark execution time: 2026-09-18 15:03:50 Comparing candidate commit 6c35136 in PR branch Found 6 performance improvements and 0 performance regressions! Performance is the same for 21 metrics, 9 unstable metrics.
|
Benchmarks [ tracer ]Benchmark execution time: 2026-09-17 11:20:08 Comparing candidate commit 8dbc671 in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 193 metrics, 0 unstable metrics.
|
…ion" This reverts commit 23277c9.
…trace-php into florian/optimize-ddprof-time
Description
The profiler sends samples through a bounded 100-message channel using non-blocking sends. The original
/dev/nullI/O upscaling workload can produce samples faster thanddprof_timeaggregates them, which fills the channel and drops samples. I profiled the complete PHP process with macOSsampleand optimized the measuredddprof_timehot paths.This PR is intentionally split into five commits and can be reviewed commit by commit:
FxHashMapfor the trusted, low-cardinality internal profile map. The initial profile showed 32% of active message-processing samples in SipHash.ProfileIndexand its semantic hash. Samples clone the cachedArc, while equal identities from different requests still aggregate into the same profile.select!wakes the consumer. This amortizes channel registration and timer checks without allowing unbounded timer starvation.Arconly when experimental heap-live tracking actually needs shared ownership.Median PHP user CPU for the same 100x stress workload improved from 14.94s to 11.90s, a 20.3% reduction. The incremental medians were 14.07s after the map change, 12.57s after cached identity, 12.35s after batch draining, and 11.90s after owned payloads.
Reviewer checklist