Commit f9ac7f2
test(profiling): add profiles dictionary benchmarks (#2088)
## 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:
```text
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](https://datadoghq.atlassian.net/browse/PROF-14423)
[PROF-14423]: https://datadoghq.atlassian.net/browse/PROF-14423?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Co-authored-by: morrisonlevi <levi.morrison@datadoghq.com>
Co-authored-by: taegyun.kim <taegyun.kim@datadoghq.com>1 parent 65d8d24 commit f9ac7f2
2 files changed
Lines changed: 109 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
0 commit comments