Skip to content

refactor(benchmarks): measure allocator thread CPU time - #2500

Open
BridgeAR wants to merge 1 commit into
mainfrom
BridgeAR/2026-09-10-allocator-benchmark-stability
Open

refactor(benchmarks): measure allocator thread CPU time#2500
BridgeAR wants to merge 1 commit into
mainfrom
BridgeAR/2026-09-10-allocator-benchmark-stability

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Sep 9, 2026

Copy link
Copy Markdown
Member

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_cpu prefix 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. libc is 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 warnings
  • cargo test -p libdd-profiling-heap-allocator
  • Run all 30 sampler_overhead benchmark cases on Linux.
  • cargo check -p libdd-profiling-heap-allocator --all-targets on macOS.

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.
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📚 Documentation Check Results

⚠️ 49 documentation warning(s) found

📦 libdd-profiling-heap-allocator - 49 warning(s)


Updated: 2026-09-09 22:46:33 UTC | Commit: 5870791 | missing-docs job results

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🔒 Cargo Deny Results

No issues found!

📦 libdd-profiling-heap-allocator - ✅ No issues


Updated: 2026-09-09 22:47:58 UTC | Commit: 5870791 | dependency-check job results

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Sep 9, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 77.62% (-0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: ed967a2 | Docs | View more details | Give us feedback!

@BridgeAR BridgeAR changed the title bench(profiling): measure allocator thread CPU time refactor(benchmarks): measure allocator thread CPU time Sep 9, 2026
@BridgeAR
BridgeAR marked this pull request as ready for review September 9, 2026 22:55
@BridgeAR
BridgeAR requested review from a team as code owners September 9, 2026 22:55

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@dd-octo-sts

dd-octo-sts Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 95.57 MB 95.57 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 8.96 MB 8.96 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 12.10 MB 12.10 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 106.92 MB 106.92 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 28.91 MB 28.91 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 96.08 KB 96.08 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 191.08 MB 191.07 MB -0% (-8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 810.01 MB 810.01 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 9.65 MB 9.65 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 96.08 KB 96.08 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 27.37 MB 27.37 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 55.31 MB 55.31 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 25.26 MB 25.26 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 97.58 KB 97.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 196.30 MB 196.30 MB -0% (-8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 795.90 MB 795.90 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 7.46 MB 7.46 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 97.58 KB 97.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 29.44 MB 29.44 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 52.22 MB 52.22 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 85.61 MB 85.61 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 9.99 MB 9.99 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 101.52 MB 101.52 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 12.20 MB 12.20 MB 0% (0 B) 👌

@pr-commenter

pr-commenter Bot commented Sep 9, 2026

Copy link
Copy Markdown

Benchmarks

Comparison

Benchmark execution time: 2026-09-09 23:24:29

Comparing candidate commit ed967a2 in PR branch BridgeAR/2026-09-10-allocator-benchmark-stability with baseline commit a2a1dfb in branch main.

📊 Benchmarking dashboard

Found 2 performance improvements and 2 performance regressions! Performance is the same for 152 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:msgpack_decoder::v05/high_sharing/200

  • 🟩 execution_time [-20.981µs; -20.865µs] or [-11.774%; -11.709%]
  • 🟩 throughput [+148913.362op/s; +149686.328op/s] or [+13.268%; +13.337%]

scenario:vec_map/get_mut/16

  • 🟥 execution_time [+20.958ns; +29.852ns] or [+7.853%; +11.186%]
  • 🟥 throughput [-6314381.230op/s; -4358940.067op/s] or [-10.452%; -7.215%]

Benchmark execution time: 2026-09-09 23:21:11

Comparing candidate commit ed967a2 in PR branch BridgeAR/2026-09-10-allocator-benchmark-stability with baseline commit a2a1dfb in branch main.

📊 Benchmarking dashboard

Found 1 performance improvements and 6 performance regressions! Performance is the same for 128 metrics, 11 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:datadog_sample_span/name_pattern_rule_not_matching/wall_time

  • 🟩 execution_time [-7.378ns; -7.268ns] or [-4.476%; -4.409%]

scenario:normalization/normalize_name/normalize_name/good

  • 🟥 execution_time [+494.257ns; +559.191ns] or [+4.487%; +5.077%]
  • 🟥 throughput [-4366654.402op/s; -3856794.625op/s] or [-4.810%; -4.248%]

scenario:trace_buffer/2_senders/no_delay

  • 🟥 execution_time [+217.822µs; +234.450µs] or [+14.560%; +15.671%]
  • 🟥 throughput [-163093.750op/s; -152021.762op/s] or [-13.550%; -12.630%]

scenario:trace_buffer/4_senders/no_delay

  • 🟥 execution_time [+163.489µs; +174.928µs] or [+4.550%; +4.869%]
  • 🟥 throughput [-46625.223op/s; -43555.397op/s] or [-4.653%; -4.347%]

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:datadog_sample_span/parent_not_sampled_short_circuit/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+544.037%; -550.265%]

scenario:datadog_sample_span/parent_sampled_short_circuit/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+557.086%; -556.371%]

scenario:flagevaluation_evp/coalescer/typical/100flags_50users_10fields

  • unstable execution_time [-10338.159ns; +11567.079ns] or [-5.499%; +6.153%]

scenario:glob_matcher/ascii_case_insensitive_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+556.291%; -555.997%]

scenario:glob_matcher/ascii_exact_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+555.735%; -555.735%]

scenario:glob_matcher/ascii_exact_miss/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+554.022%; -554.929%]

scenario:glob_matcher/ascii_wildcard_backtrack_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+554.968%; -555.374%]

scenario:glob_matcher/ascii_wildcard_heavy_backtrack/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+557.446%; -556.541%]

scenario:glob_matcher/ascii_wildcard_question_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+556.503%; -556.096%]

scenario:glob_matcher/ascii_wildcard_star_match/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+555.735%; -555.735%]

scenario:glob_matcher/star_short_circuit/allocated_bytes

  • unstable execution_time [-0.000ns; +0.000ns] or [+560.704%; -558.080%]

Candidate

Omitted due to size.

Baseline

Omitted due to size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant