Skip to content

feat(profiling-ffi): ProfilesDictionary_insert_strs#1764

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intomainfrom
levi/ffi-insert-strs
Mar 19, 2026
Merged

feat(profiling-ffi): ProfilesDictionary_insert_strs#1764
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intomainfrom
levi/ffi-insert-strs

Conversation

@morrisonlevi
Copy link
Copy Markdown
Contributor

@morrisonlevi morrisonlevi commented Mar 18, 2026

What does this PR do?

Adds a batch variant of ddog_prof_ProfilesDictionary_insert_str called ddog_prof_ProfilesDictionary_insert_strs that interns a slice of CharSlices into an existing ProfilesDictionary in a single call, writing the resulting StringId2s to a caller-provided MutSlice.

Motivation

Every profiler adopting ProfilesDictionary needs to insert their known label keys, so may as well make it convenient.

Additional Notes

Taegyun and I thought of this while going over some memory allocations, and they had unexpected large allocations for adding 3 label keys. This is because the profile was aggregated over multiple processes, but also it reports the full 1 MiB of virtual memory per shard of the sharded set, and these label keys were the first in their respective buckets. This function doesn't really change that, but it at least makes it more convenient to intern all label strings up front.

How to test the change?

Tests were added to existing suites, can just run cargo test or nextest etc.

Batch variant of ddog_prof_ProfilesDictionary_insert_str that interns
a slice of CharSlices into an existing ProfilesDictionary in a single
call, writing the resulting StringId2s to a caller-provided MutSlice.
@github-actions
Copy link
Copy Markdown

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/levi/ffi-insert-strs

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 28 28 No change (0%)
datadog-live-debugger 6 6 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-remote-config 3 3 No change (0%)
datadog-sidecar 59 59 No change (0%)
libdd-common 10 10 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 5 5 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-telemetry 19 19 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 9 9 No change (0%)
libdd-trace-utils 15 15 No change (0%)
Total 208 208 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.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts bot commented Mar 18, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 8.70 MB 8.70 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 100.36 MB 100.37 MB +0% (+7.81 KB) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 117.03 MB 117.03 MB +0% (+6.89 KB) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 11.28 MB 11.28 MB +0% (+416 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
libdatadog-x86-windows
Artifact Baseline Commit Change
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 87.57 MB 87.58 MB +0% (+6.63 KB) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 10.22 MB 10.22 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 109.90 MB 109.91 MB +0% (+6.29 KB) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 11.97 MB 11.97 MB +0% (+256 B) 👌

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.46%. Comparing base (2db515d) to head (80e2712).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1764      +/-   ##
==========================================
+ Coverage   71.44%   71.46%   +0.01%     
==========================================
  Files         430      430              
  Lines       64152    64214      +62     
==========================================
+ Hits        45835    45891      +56     
- Misses      18317    18323       +6     
Components Coverage Δ
libdd-crashtracker 63.82% <ø> (-0.02%) ⬇️
libdd-crashtracker-ffi 17.10% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 87.69% <ø> (ø)
libdd-data-pipeline-ffi 73.57% <ø> (ø)
libdd-common 79.73% <ø> (ø)
libdd-common-ffi 73.40% <ø> (ø)
libdd-telemetry 62.48% <ø> (ø)
libdd-telemetry-ffi 16.75% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 80.35% <ø> (-0.12%) ⬇️
libdd-profiling 81.60% <100.00%> (+0.11%) ⬆️
libdd-profiling-ffi 64.94% <100.00%> (+1.29%) ⬆️
datadog-sidecar 33.61% <ø> (ø)
datdog-sidecar-ffi 13.01% <ø> (ø)
spawn-worker 54.69% <ø> (ø)
libdd-tinybytes 93.16% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 91.80% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.05% <ø> (ø)
datadog-tracer-flare 86.88% <ø> (ø)
libdd-log 74.69% <ø> (ø)
🚀 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.

@morrisonlevi morrisonlevi marked this pull request as ready for review March 18, 2026 23:07
@morrisonlevi morrisonlevi requested a review from a team as a code owner March 18, 2026 23:07
Copy link
Copy Markdown
Contributor

@taegyunkim taegyunkim left a comment

Choose a reason for hiding this comment

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

Thanks for adding the API!

@morrisonlevi
Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 bot commented Mar 19, 2026

View all feedbacks in Devflow UI.

2026-03-19 17:45:38 UTC ℹ️ Start processing command /merge


2026-03-19 17:45:42 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 45m (p90).


2026-03-19 18:25:10 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d bot merged commit b09f6af into main Mar 19, 2026
94 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d bot deleted the levi/ffi-insert-strs branch March 19, 2026 18:25
bwoebi added a commit that referenced this pull request Mar 20, 2026
…-unprocessed

* 'main' of github.com:DataDog/libdatadog:
  feat(sidecar): add thread mode as fallback connection for restricted environments (#1447)
  feat(profiling-ffi): ProfilesDictionary_insert_strs (#1764)
  chore(release): merge release branch to main (#1760)
  fix(libdd-crashtracker-ffi)!: add missing fields for endpoint configuration (#1758)
  ci: prevent running macos tests on release branches (#1765)
  chore(datadog-tracer-flare): remove unnecessary features/deps (#1761)
  fix(profiling-ffi): Windows extern statics need __declspec(dllimport) (#1468)
  feat(profiling): thread id/name as well-known strs (#1757)
  ci: switch to ephemeral branches (#1731)
  chore(crashtracker): use weaker mem ordering for OP_COUNTERS (#1744)
  refactor(trace-utils)!: change header name type to accept dynamic values (#1722)
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.

3 participants