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

feat(profiling): Filter out lonely samples #1445

Merged
merged 7 commits into from
Sep 6, 2022

Conversation

phacops
Copy link
Contributor

@phacops phacops commented Aug 31, 2022

This PR aims to be more strict on what profiles we accept. We're seeing profiles with only 1 sample on some threads, sometimes all threads. These profiles are useless and we don't want to ingest them.

This is removing samples which are alone on a given thread and rejecting the profile if we end up without any sample.

@phacops phacops requested review from jan-auer and a team August 31, 2022 23:31
@phacops phacops requested a review from a team as a code owner August 31, 2022 23:31
@phacops phacops requested review from olksdr and a team September 1, 2022 13:01
Copy link
Member

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

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

Looks good to me, just some non-blocking nitpicks.

.or_default() += 1;
}

sample_count_by_thread_id.retain(|_, count| *count > 1);
Copy link
Member

Choose a reason for hiding this comment

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

Is 1 some sort of natural limit? Or might this value change in the future? In the latter case, I would put it in a constant or even make it configurable.
nit: An explanation in the form of a code comment or as part of the function's documentation would be nice.

Copy link
Contributor Author

@phacops phacops Sep 1, 2022

Choose a reason for hiding this comment

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

1 is the only limit we'd want. Basically, we need at least 2 samples (list of frames executed at a given timestamp) to calculate a duration. So it's not going to change, I'll remove every thread with only 1 sample since I can't do anything interesting with this data.

I added a comment to make that clear.

Copy link
Member

Choose a reason for hiding this comment

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

Perfect, thanks!

@@ -121,11 +121,31 @@ struct CocoaProfile {
version_name: String,
}

impl CocoaProfile {
fn filter_samples(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Would remove_singleton_samples be a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the name for something much more descriptive.

@phacops phacops requested a review from jjbayer September 1, 2022 18:56

/// Removes an event with a duration of 0
fn remove_events_with_no_duration(&mut self) {
let mut android_profile = self.profile.as_ref().unwrap().clone();
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need to clone here?

Suggested change
let mut android_profile = self.profile.as_ref().unwrap().clone();
let android_profile = self.profile.as_mut().unwrap();

Also, the unwrap() is unfortunate, even if calling parse() guarantees that the option has a value. Maybe we can make AndroidProfile::profile non-optional, and convert parse() into a function that is called during deserialization, something like

#[serde(deserialize_with="parse_android_trace_log")]
profile: AndroidTraceLog,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is unfortunate and the reason for that was to not have to parse if the relay node was not in processing mode. Now, I think we can still make it so we only parse when we need to while still getting rid of the Option.

@phacops phacops merged commit 6a255cb into master Sep 6, 2022
@phacops phacops deleted the pierre/profiling-clean-and-reject-profiles branch September 6, 2022 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants