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

java-profile flamegraphs saved in tmp folder, duplicate jvm arg fix #207

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

lancelui-amzn
Copy link
Contributor

@lancelui-amzn lancelui-amzn commented Jul 23, 2024

Description of changes:

  • Aperf record creates a folder in /tmp/ to allow JVMs with limited permissions to save flamegraph files. Results are copied to the specified record folder by aperf. Previously, JVMs would directly save folders to the record folder.
  • Made record and report integration tests sequential to avoid conflicts in tmp folder
  • Changed CollectorParams path fields to PathBuf from String
  • Fixed bug in argument parsing that attempted to profile the same JVM twice if duplicate arguments were given.

Testing:

  • Profiled groovy and Cassandra benchmarks, both with various permissions.
  • Ran updated test suite and validated results by created files and visually through UI

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

@lancelui-amzn lancelui-amzn requested a review from a team as a code owner July 23, 2024 17:12
@lancelui-amzn lancelui-amzn requested a review from janaknat July 23, 2024 18:07
@wash-amzn
Copy link
Contributor

Previously, JVMs would directly save folders to the record folder.

Why was that a problem?

params.run_name, key
);

fs::copy(tmp_loc.clone(), html_loc).ok();
Copy link
Contributor

Choose a reason for hiding this comment

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

A move would be better than a copy. Although, the answer to my question of why we have to write to /tmp/ in the first place might mean it has to be a copy.

use std::fs;
use std::os::unix::fs::PermissionsExt;

pub static APERF_TMP: &str = "/tmp/aperf_tmp";
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be passed in as a parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean like another CLI option and part of collector params?

Copy link
Contributor

Choose a reason for hiding this comment

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

As part of the collector params passed into each of the data type.


let html_loc = html_path.to_str().unwrap();
let tmp_loc = format!(
"/tmp/aperf_tmp/{}-java-flamegraph-{}.html",
Copy link
Contributor

Choose a reason for hiding this comment

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

We are hard-coding /tmp/aperf_tmp in multiple locations. We should have the tmp location passed in as a parameter.

@lancelui-amzn
Copy link
Contributor Author

Previously, JVMs would directly save folders to the record folder.

Why was that a problem?

When aperf is launched with sudo, the record folder it creates has sudo permissions. A non-sudo JVM being profiled will not be able to save the flamegraph to this folder.

src/data.rs Outdated
@@ -58,6 +58,7 @@ pub struct CollectorParams {
pub data_dir: String,
pub run_name: String,
pub profile: HashMap<String, String>,
pub tmp_dir: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use PathBuf for paths. We should change the other members of the CollectorParams from String to PathBuf.

Copy link
Contributor

@wash-amzn wash-amzn left a comment

Choose a reason for hiding this comment

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

Approved contingent on Janak's approval

@janaknat janaknat merged commit 7105bec into aws:main Jul 24, 2024
6 checks passed
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