Skip to content

Commit

Permalink
address PR comments: tmp path parameter, mv instead of cp tmp files
Browse files Browse the repository at this point in the history
  • Loading branch information
lancelui-amzn committed Jul 24, 2024
1 parent bff901d commit d4268ec
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct CollectorParams {
pub data_dir: String,
pub run_name: String,
pub profile: HashMap<String, String>,
pub tmp_dir: String,
}

impl CollectorParams {
Expand All @@ -69,6 +70,7 @@ impl CollectorParams {
data_dir: String::new(),
run_name: String::new(),
profile: HashMap::new(),
tmp_dir: String::new(),
}
}
}
Expand Down Expand Up @@ -123,6 +125,7 @@ impl DataType {
self.collector_params.data_file_path = self.full_path.clone();
self.collector_params.data_dir = param.dir_name.clone();
self.collector_params.profile = param.profile.clone();
self.collector_params.tmp_dir = param.tmp_dir.clone();

self.file_handle = Some(
OpenOptions::new()
Expand Down
10 changes: 5 additions & 5 deletions src/data/java_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ impl JavaProfileRaw {
&(params.collection_time - params.elapsed_time).to_string(),
"-f",
format!(
"/tmp/aperf_tmp/{}-java-flamegraph-{}.html",
params.run_name, jid
"{}/{}-java-flamegraph-{}.html",
params.tmp_dir, params.run_name, jid
)
.as_str(),
jid.as_str(),
Expand Down Expand Up @@ -218,11 +218,11 @@ impl CollectData for JavaProfileRaw {

let html_loc = html_path.to_str().unwrap();
let tmp_loc = format!(
"/tmp/aperf_tmp/{}-java-flamegraph-{}.html",
params.run_name, key
"{}/{}-java-flamegraph-{}.html",
params.tmp_dir, params.run_name, key
);

fs::copy(tmp_loc.clone(), html_loc).ok();
fs::rename(tmp_loc.clone(), html_loc).ok();
}

let mut jps_map = File::create(
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ pub struct InitParams {
pub run_name: String,
pub collector_version: String,
pub commit_sha_short: String,
pub tmp_dir: String,
}

impl InitParams {
Expand Down Expand Up @@ -514,6 +515,7 @@ impl InitParams {
run_name,
collector_version,
commit_sha_short,
tmp_dir: String::new(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub fn record(record: &Record) -> Result<()> {
let mut params = InitParams::new(run_name);
params.period = record.period;
params.interval = record.interval;
params.tmp_dir = APERF_TMP.to_string();

match &record.profile_java {
Some(j) => {
Expand Down

0 comments on commit d4268ec

Please sign in to comment.