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

Wait for 'perf record' to finish #160

Merged
merged 1 commit into from
Apr 23, 2024
Merged

Wait for 'perf record' to finish #160

merged 1 commit into from
Apr 23, 2024

Conversation

janaknat
Copy link
Contributor

The time taken by perf record after the collection period depends on the time of collection and the system load. On heavily loaded systems, profiling can take longer than the time it takes to go from perf collection to perf inject in the post collection step. To prevent a race condition, add a wait before the perf inject step.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@janaknat janaknat requested a review from a team as a code owner April 23, 2024 16:56
Comment on lines 38 to 52
let mut child = PERF_CHILD.lock().unwrap();
match child.as_ref() {
None => return Ok(()),
Some(_) => {}
}

trace!("Waiting for perf profile collection to complete...");
match child.as_mut().unwrap().wait() {
Err(e) => {
error!("'perf' did not exit successfully: {}", e);
return Ok(());
}
Ok(_) => trace!("'perf record' executed successfully."),
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you try to do this more generically, like have all data collectors have a synchronous shutdown/stop, even if for most of them it's a no-op, so that this kind of code can be kept hidden/separated from things that shouldn't know about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I've added a finish_data_collection step.

Comment on lines +16 to +18
lazy_static! {
pub static ref PERF_CHILD: Mutex<Option<Child>> = Mutex::new(None);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you put this state into the PerfProfileRaw struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Child type is not Serializable. We have that constraint since the PerfProfileRaw struct is part of the Data enum.

Copy link
Contributor

Choose a reason for hiding this comment

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

That really needs to be fixed. The same type that's being serialized as output data shouldn't be the one doing the data collection, it causes issues like this.

@janaknat janaknat merged commit 3813164 into main Apr 23, 2024
8 checks passed
@janaknat janaknat deleted the profile-fix branch April 23, 2024 19:25
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.

3 participants