Skip to content

test(profiling): add profiles dictionary benchmarks#2088

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 10 commits into
mainfrom
taegyunkim/prof-14423-prof-dictinary-bench
Jul 8, 2026
Merged

test(profiling): add profiles dictionary benchmarks#2088
gh-worker-dd-mergequeue-cf854d[bot] merged 10 commits into
mainfrom
taegyunkim/prof-14423-prof-dictinary-bench

Conversation

@taegyunkim

@taegyunkim taegyunkim commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a focused Criterion benchmark for ProfilesDictionary unique string insertion.

The benchmark uses ProfilesDictionary and covers 1, 2, 4, and 16 producer threads, so follow-up arena sizing/growth changes have a baseline in the GitLab benchmark job.

#2048 changes the default configs for the ProfilesDictionary

Why these thread counts?

This benchmark is focused on dictionary string interning. It is not a full end-to-end profiler benchmark.

Thread count Why it is useful
1 Approximates single-writer consumers such as ddprof. ddprof appears to intern from the worker thread while export happens from a separate inactive profile buffer.
2 Approximates current dd-trace-py contention: one native stack sampler thread can intern off-GIL while one Python/Cython collector path is active under the GIL.
4 / 16 Stress cases for future higher-concurrency scenarios, including possible free-threaded/no-GIL Python work.

In dd-trace-py, profile mutation and serialization are guarded by profile_mtx, but dictionary interning can happen before a sample is added to the profile. This means dictionary insertion can still be concurrent even when profile writes are serialized.

What this does not cover

This benchmark does not model every profiler behavior. In particular, it does not cover:

  • function or mapping insertion,
  • duplicate-heavy/cached lookup workloads,
  • profile serialization reading from the dictionary,
  • full profiler end-to-end behavior.

Why only ProfilesDictionary?

I originally tried an additional synthetic benchmark comparing 4 vs 16 shards. Local exploratory results suggested 16 shards helps once there is concurrent insertion:

1 thread:   4 shards ~40 µs,   16 shards ~55 µs
2 threads:  4 shards ~157 µs,  16 shards ~129 µs
4 threads:  4 shards ~385 µs,  16 shards ~280 µs
16 threads: 4 shards ~2.64 ms, 16 shards ~1.61 ms

However, that synthetic comparison also changed total initial hash-table capacity because the capacity was applied per shard. Since the current follow-up keeps the production shard count at 16, this PR stays minimal and only adds the ProfilesDictionary benchmark.

If we revisit shard count later, we should add a dedicated shard-count benchmark that holds total starting capacity constant across shard counts.

How to test the change?

  • cargo +nightly-2026-02-08 fmt --all -- --check
  • cargo check -p libdd-profiling --benches
  • cargo +stable clippy -p libdd-profiling --benches -- -D warnings

PROF-14423

@taegyunkim taegyunkim requested a review from a team as a code owner June 5, 2026 14:05
@taegyunkim taegyunkim added the profiling Relates to the profiling* modules. label Jun 5, 2026
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/taegyunkim/prof-14423-prof-dictinary-bench

Summary by Rule

Rule Base Branch PR Branch Change

Annotation Counts by File

File Base Branch PR Branch Change

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 5 5 No change (0%)
datadog-ffe-ffi 1 1 No change (0%)
datadog-ipc 22 22 No change (0%)
datadog-live-debugger 4 4 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-sidecar 45 45 No change (0%)
libdd-common 13 13 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 6 6 No change (0%)
libdd-ddsketch 2 2 No change (0%)
libdd-dogstatsd-client 1 1 No change (0%)
libdd-profiling 13 13 No change (0%)
libdd-remote-config 3 3 No change (0%)
libdd-telemetry 20 20 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 3 3 No change (0%)
libdd-trace-stats 1 1 No change (0%)
libdd-trace-utils 11 11 No change (0%)
Total 182 182 No change (0%)

About This Report

This report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality.

@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: 427e0ea0f9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread libdd-profiling/benches/profiles_dictionary.rs Outdated
@codecov-commenter

codecov-commenter commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.53%. Comparing base (98016ad) to head (477834f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2088      +/-   ##
==========================================
- Coverage   73.54%   73.53%   -0.02%     
==========================================
  Files         475      475              
  Lines       79007    79007              
==========================================
- Hits        58109    58095      -14     
- Misses      20898    20912      +14     
Components Coverage Δ
libdd-crashtracker 65.32% <ø> (-0.02%) ⬇️
libdd-crashtracker-ffi 37.68% <ø> (ø)
libdd-agent-client 83.79% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 86.27% <ø> (+0.01%) ⬆️
libdd-data-pipeline-ffi 73.86% <ø> (ø)
libdd-common 79.93% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.34% <ø> (ø)
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.36% <ø> (ø)
libdd-profiling 81.68% <ø> (-0.03%) ⬇️
libdd-profiling-ffi 64.79% <ø> (ø)
libdd-sampling 97.48% <ø> (ø)
datadog-sidecar 36.51% <ø> (+0.02%) ⬆️
datdog-sidecar-ffi 12.23% <ø> (ø)
spawn-worker 48.86% <ø> (ø)
libdd-tinybytes 93.80% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.30% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.32% <ø> (ø)
libdd-tracer-flare 86.57% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jun 5, 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: 74.33% (-0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a0dfbe4 | Docs | Datadog PR Page | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Jun 5, 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 85.91 MB 85.91 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.88 MB 7.88 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 97.11 MB 97.11 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.61 MB 10.61 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.46 MB 25.46 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 88.44 KB 88.44 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 184.60 MB 184.59 MB -0% (-8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 946.40 MB 946.40 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.32 MB 8.32 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 88.44 KB 88.44 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 24.62 MB 24.62 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 49.04 MB 49.04 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 22.06 MB 22.06 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 89.82 KB 89.82 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 188.62 MB 188.62 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 935.37 MB 935.37 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.43 MB 6.43 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 89.82 KB 89.82 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 26.43 MB 26.43 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 46.65 MB 46.65 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 76.59 MB 76.59 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.78 MB 8.78 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 92.11 MB 92.11 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.69 MB 10.69 MB 0% (0 B) 👌

@github-actions github-actions Bot removed the profiling Relates to the profiling* modules. label Jun 5, 2026
@taegyunkim taegyunkim force-pushed the taegyunkim/prof-14423-prof-dictinary-bench branch from 2e23e15 to 477834f Compare June 5, 2026 20:26

@morrisonlevi morrisonlevi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How stable is the benchmark in your experience so far? It seems like it would be pretty variable, but at least you have a startup barrier in there.

Comment thread libdd-profiling/benches/profiles_dictionary.rs Outdated
Comment thread libdd-profiling/benches/profiles_dictionary.rs Outdated
Comment thread libdd-profiling/benches/profiles_dictionary.rs
Comment thread libdd-profiling/benches/profiles_dictionary.rs Outdated
Comment thread libdd-profiling/benches/profiles_dictionary.rs Outdated
Comment thread libdd-profiling/benches/profiles_dictionary.rs
Comment thread libdd-profiling/benches/profiles_dictionary.rs
@taegyunkim

Copy link
Copy Markdown
Contributor Author

How stable is the benchmark in your experience so far? It seems like it would be pretty variable, but at least you have a startup barrier in there.

@morrisonlevi Good question, I checked this again.

I think I remember trying benchmark runs on gitlab multiple times and got stable results, I'm going to re-run them again at the latest commit for updated data.

From my local runs using workspaces,

case observed local behavior
1 thread ~278 to 280 µs, confidence interval width under 1%
2 threads ~547 to 549 µs, confidence interval width around 1%
4 threads ~730 to 735 µs, confidence interval width around 1 to 2%
16 threads ~2.25 to 2.31 ms, noisier, up to ~7% CI width in one run

at least for 1 ~2 threads cases which I believe more resembles the case of dd-trace-py and ddprof profilers, are stable enough to be used as a baseline.

Yeah, the barrier helps avoid measuring staggered thread starts.

The generated input shares some full strings across workers, so
"unique_string_inserts" was misleading. Rename the benchmark group and
function to "profile_string_inserts" and update the comments to match.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@taegyunkim taegyunkim force-pushed the taegyunkim/prof-14423-prof-dictinary-bench branch from 2418e69 to a0dfbe4 Compare July 7, 2026 19:46
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit f9ac7f2 into main Jul 8, 2026
89 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the taegyunkim/prof-14423-prof-dictinary-bench branch July 8, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants