refactor(benchmarks): measure allocator thread CPU time - #2500
Conversation
Wall-clock allocator benchmarks charged host descheduling to nanosecond-scale sampler paths. The no-profiler case also used System, so libc allocator variance obscured the semaphore gate it was intended to protect. Measure scheduled thread CPU time, retire the old wall-time series IDs, and use the no-op allocator for the short-circuit regression. On Linux ARM64 with the CI sampling settings, five fresh-process medians spanned 6.2% for system allocation and 9.7% for the no-op fast path. The short-circuit case reported 2 ns in every run. The forced-sample path still spanned 12.2%. Benchmark-only; no production code changes.
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results✅ No issues found! 📦
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: ed967a2 | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed967a2aa8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| std::io::Error::last_os_error() | ||
| ); | ||
| let time = unsafe { time.assume_init() }; | ||
| Duration::new(time.tv_sec as u64, time.tv_nsec as u32) |
There was a problem hiding this comment.
Justify or replace the timespec numeric casts
The new clock conversion silently casts libc's signed, platform-dependent time_t and c_long fields into narrower/unsigned Rust types. Although a valid CLOCK_THREAD_CPUTIME_ID result should be nonnegative with subsecond nanoseconds, encode those assumptions with checked conversions or document why the casts are safe; otherwise malformed or out-of-range values wrap or truncate before reaching Duration. The repository explicitly requires fallible conversions or a short justification for numeric as casts.
AGENTS.md reference: AGENTS.md:L74-L74
Useful? React with 👍 / 👎.
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
BenchmarksComparisonBenchmark execution time: 2026-09-09 23:24:29 Comparing candidate commit ed967a2 in PR branch Found 2 performance improvements and 2 performance regressions! Performance is the same for 152 metrics, 0 unstable metrics.
|
What does this PR do?
Measure allocator benchmarks with Linux thread CPU time instead of wall time. Retire the old series IDs under a
thread_cpuprefix and use the no-op allocator for the no-profiler short-circuit benchmark.Motivation
Wall time charged host descheduling to nanosecond-scale sampler paths. The short-circuit benchmark also included libc allocator variance instead of isolating the semaphore gate.
Across five Linux ARM64 processes using the CI settings, system allocation medians spanned 6.2%, the no-op fast path spanned 9.7%, and the short-circuit case reported 2 ns every time.
Additional Notes
Benchmark-only; no production code changes.
libcis a Linux-only development dependency. The forced-sample path still spanned 12.2%.How to test the change?
cargo clippy -p libdd-profiling-heap-allocator --all-targets -- -D warningscargo test -p libdd-profiling-heap-allocatorsampler_overheadbenchmark cases on Linux.cargo check -p libdd-profiling-heap-allocator --all-targetson macOS.