-
Notifications
You must be signed in to change notification settings - Fork 15
feat(profiling): Profile::{try_new2,try_add_sample2}
#1351
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
Conversation
BenchmarksComparisonBenchmark execution time: 2025-12-05 04:17:47 Comparing candidate commit e677b96 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 55 metrics, 2 unstable metrics. 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
Group 18
Group 19
BaselineOmitted due to size. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1351 +/- ##
==========================================
+ Coverage 70.96% 71.12% +0.16%
==========================================
Files 400 403 +3
Lines 63691 64083 +392
==========================================
+ Hits 45199 45582 +383
- Misses 18492 18501 +9
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
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
|
libdd-profiling/src/internal/profile/profiles_dictionary_translator.rs
Outdated
Show resolved
Hide resolved
| #[derive(Copy, Clone, Debug, Default)] | ||
| pub struct Label<'a> { | ||
| pub key: StringId2, | ||
|
|
||
| /// At most one of `.str` and `.num` should not be empty. | ||
| pub str: &'a str, | ||
| pub num: i64, | ||
|
|
||
| /// Should only be present when num is present. | ||
| /// Specifies the units of num. | ||
| /// Use arbitrary string (for example, "requests") as a custom count unit. | ||
| /// If no unit is specified, consumer may apply heuristic to deduce the unit. | ||
| /// Consumers may also interpret units like "bytes" and "kilobytes" as memory | ||
| /// units and units like "seconds" and "nanoseconds" as time units, | ||
| /// and apply appropriate unit conversions to these. | ||
| pub num_unit: &'a str, | ||
| } |
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.
Would it make sense to use Rust enums here to enforce this?
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.
Some of the code does model it this way, such as the internal::Label. But the api2::Label is meant to be more similar to api::Label for easier adoption, and it does not use enums because it more closely mirrors the FFI.
libdd-profiling/src/internal/profile/profiles_dictionary_translator.rs
Outdated
Show resolved
Hide resolved
libdd-profiling/src/internal/profile/profiles_dictionary_translator.rs
Outdated
Show resolved
Hide resolved
| let internal_id = functions.dedup(function); | ||
| self.functions.try_reserve(1)?; | ||
| self.functions.insert(set_id, internal_id); | ||
| Ok(internal_id) |
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.
so this both functions and self.functions? Why do we need both
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.
One is the internal function "table" and the other is a HashMap that converts from the ProfilesDictionary IDs into the internal IDs.
libdd-profiling/src/internal/profile/profiles_dictionary_translator.rs
Outdated
Show resolved
Hide resolved
342cef5 to
19bb0ef
Compare
| locations.push(Location2 { | ||
| mapping: MappingId2::default(), | ||
| function: frame.function, | ||
| address: 0, | ||
| line: frame.line_number as i64, | ||
| }); |
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.
Would this make sense as a .into() function
libdd-profiling/src/internal/profile/profiles_dictionary_translator.rs
Outdated
Show resolved
Hide resolved
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Tests failed on this commit f6d7637: What to do next?
|
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
What does this PR do?
This adds two new methods to
libdd_profiling::internal::Profilewith supporting types:Profile::try_new2Profile::try_add_sample2Motivation
These APIs together are faster than the versions that aren't suffixed with 2.
Additional Notes
This doesn't add the FFI API yet, that's coming next.
How to test the change?
Everything should be the same. There is a benchmark you can run to compare some basic API level tests. Here is what I got locally on my M1:
In this basic benchmarking test, it's roughly 3x faster.