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

Move profiling processing to the record step #206

Merged
merged 1 commit into from
Jul 22, 2024
Merged

Conversation

janaknat
Copy link
Contributor

Currently, users are unable to generate reports, of an aperf run with --profile, on a system that is not the SUT. Move the processing step for perf_profile and flamegraph to the record stage.

Testing:
Prior to this change, it was not possible to generate a comparison of profiling between runs in arm64 and x86.

arm64profile.tar.gz
x86profile.tar.gz
profilecmp.tar.gz

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 July 17, 2024 22:16
Comment on lines 88 to 98
let out = Command::new("perf")
.args(["script", "-f", "-i", perf_jit_loc.to_str().unwrap()])
.output();
match out {
Err(e) => {
let out = format!("Did not process profiling data due to: {}", e);
error!("{}", out);
write_msg_to_svg(fg_out, out)?;
}
Ok(v) => {
write!(script_out, "{}", std::str::from_utf8(&v.stdout)?)?;
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 get this so that 'perf' is writing the file directly, versus slurping a potentially huge output up into this process, only to then write it out to a file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. We can set the stdout and give it the file and that should work.

@janaknat janaknat force-pushed the pfl-in-record branch 2 times, most recently from 107c798 to cbd1ed5 Compare July 18, 2024 22:08
Comment on lines +81 to +83
let out = Command::new("perf")
.stdout(File::create(&script_loc)?)
.args(["script", "-f", "-i", perf_jit_loc.to_str().unwrap()])
Copy link
Contributor

Choose a reason for hiding this comment

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

For the other invocations of perf you use it's -o option rather than stdout. I don't think there's a functional problem here, but it would be better to be consistent on how you're calling 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.

Most other perf sub-tools provide the -o option. perf script does not :(

Comment on lines 59 to 76
let out_jit = Command::new("perf")
.args([
"inject",
"-j",
"-i",
&file_pathbuf.to_str().unwrap(),
"-o",
perf_jit_loc.clone().to_str().unwrap(),
perf_jit_loc.to_str().unwrap(),
])
.status();
.output();

let fg_out = File::create(data_dir.join(format!("{}-flamegraph.svg", params.run_name)))?;

match out_jit {
Err(e) => {
if e.kind() == ErrorKind::NotFound {
error!("'perf' command not found.");
} else {
error!("Unknown error: {}", e);
let out = format!("Skip processing profiling data due to: {}", e);
error!("{}", out);
write_msg_to_svg(fg_out, out)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

What are you expecting to get out of perf's output since you're telling it to write to a file? Errors would go to stderr anyway.

Can't this go back to only looking at status?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. We should use .status(). I'll change it.

Currently, users are unable to generate reports, of an aperf run with
--profile, on a system that is not the SUT. Move the processing step for
perf_profile and flamegraph to the record stage.
@janaknat janaknat merged commit 820288a into main Jul 22, 2024
6 checks passed
@janaknat janaknat deleted the pfl-in-record branch July 23, 2024 16:39
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.

2 participants