-
Notifications
You must be signed in to change notification settings - Fork 15
feat(profiling): add ProfilesDictionary #1349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
BenchmarksComparisonBenchmark execution time: 2025-11-19 22:08:07 Comparing candidate commit 89b7a8e in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 54 metrics, 2 unstable metrics. scenario:benching deserializing traces from msgpack to their internal representation
CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
Group 14
Group 15
Group 16
Group 17
BaselineOmitted due to size. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1349 +/- ##
==========================================
- Coverage 71.19% 71.15% -0.04%
==========================================
Files 392 396 +4
Lines 62677 62798 +121
==========================================
+ Hits 44622 44685 +63
- Misses 18055 18113 +58
🚀 New features to boost your workflow:
|
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-apple-darwin
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-apple-darwin
x86_64-unknown-linux-gnu
|
KowalskiThomas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I see makes sense to me but I'll let someone better versed in Rust make review!
| /// Pprof representations. Omits the start line to save space because Datadog | ||
| /// doesn't use this in any way. | ||
| #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)] | ||
| #[repr(C)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for this to be repr[c]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although I haven't looked to see if this messes up cbindgen. Sometimes a repr(C) will cause it to pick up this definition instead of some other definition, since it doesn't understand modules and namespaces.
The reason is that it makes Function and Function2 layout-compatible, aside from the case of a null StringId2. Converting from Function to Function2 is free, and the reverse is just the code required to coerce nulls into empty strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked and no differences in API (yet):
cargo clean
git switch levi/profiles_dictionary
cargo run --bin release --features profiling --release -- --out $PWD/release2
cargo clean
git switch main
cargo run --bin release --features profiling --release -- --out $PWD/release1
diff release{1,2}/include/datadog/profiling.hThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an assertion or test that would fail if the two are not compatible?
| } | ||
| } | ||
|
|
||
| impl From<Function2> for Function { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but it feels like someone OUGHT to have a crate to do this
| /// `FunctionId2` converts to a `None`. | ||
| /// | ||
| /// # Safety | ||
| /// The pointer object must still be alive. In general this means the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any other requirements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. If the profiles dictionary is alive, this should be safe.
| /// Pprof representations. Omits the start line to save space because Datadog | ||
| /// doesn't use this in any way. | ||
| #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)] | ||
| #[repr(C)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have an assertion or test that would fail if the two are not compatible?
| /// performed on; it is not generally guaranteed that ids from one dictionary | ||
| /// can be used in another dictionary, even if it happens to work by | ||
| /// implementation detail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to detect this error?
What does this PR do?
This adds the ProfilesDictionary data structure, which holds deduplicated functions, mappings, and strings and gives back IDs to the inserted elements.
Motivation
This is another stepping stone for my new profiling API with long-lived functions, mappings, and strings.
Additional Notes
This is stacked on top of PR #1347.
How to test the change?
Regular testing applies, just additions here (that are currently unused).