Skip to content
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

Add .pprof to api::Profile helper #75

Merged
merged 6 commits into from
Dec 1, 2022
Merged

Add .pprof to api::Profile helper #75

merged 6 commits into from
Dec 1, 2022

Conversation

morrisonlevi
Copy link
Contributor

@morrisonlevi morrisonlevi commented Nov 30, 2022

What does this PR do?

  • Creates a new type api::Profile.
  • Implements TryFrom<&pprof::Profile> for api::Profile.
  • Tests a few samples in given WordPress profile to ensure it's correct.
  • Drops the nightly clippy lints. These fail too often. Tracking the latest stable's clippy should be good enough.

Motivation

This is a precursor PR for benchmarking hashing functions or other changes. This allows us to read in a pprof from disk and get an api::Profile from it, which we can use to add to the regular profile API. This allows us to benchmark adding samples, interning strings, etc.

Additional Notes

I wrote the tests for those samples by hand -- they aren't auto-generated. It's a very slow process.

How to test the change?

There are no changes to shipped code, so there shouldn't be anything to test.

@morrisonlevi morrisonlevi changed the title Test .pprof to api::Profile Add .pprof to api::Profile helper Nov 30, 2022
@morrisonlevi morrisonlevi marked this pull request as ready for review November 30, 2022 04:00
@morrisonlevi morrisonlevi requested a review from a team as a code owner November 30, 2022 04:00
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

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

Other than making it clear that the new API is only for testing, I don't see any reason not to merge this in. Here sir, take my 👍

Comment on lines +131 to +137
pub struct Profile<'a> {
pub duration: Duration,
pub period: Option<(i64, ValueType<'a>)>,
pub sample_types: Vec<ValueType<'a>>,
pub samples: Vec<Sample<'a>>,
pub start_time: SystemTime,
}
Copy link
Member

Choose a reason for hiding this comment

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

Given the assumption

There are no changes to shipped code, so there shouldn't be anything to test.

Should this be inside the mod test? And perhaps also document the assumption in the code, so that other/newer team members know that this isn't expected to be used outside of libdatadog testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe. I need to see what configuration the bench configuration uses -- I know it uses public APIs only, but I'm not sure if it builds with test or not, so that's the only reason I didn't immediately slap it into #[cfg(test)].

@@ -0,0 +1,4441 @@

Copy link
Member

Choose a reason for hiding this comment

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

Consider perhaps compressing this file as pprof.gz or something OR at least telling github not to render them https://thoughtbot.com/blog/github-diff-supression :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea 👍🏻

@morrisonlevi morrisonlevi merged commit 32d97a0 into main Dec 1, 2022
@morrisonlevi morrisonlevi deleted the levi/pprof-test branch December 1, 2022 15:56
@morrisonlevi morrisonlevi added the profiling Relates to the profiling* modules. label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
profiling Relates to the profiling* modules.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants