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

refactor(hydro_deploy)!: end-to-end flamegraph generation, fix #1365 #1372

Merged
merged 5 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 139 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion hydro_deploy/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ futures = "0.3.26"
futures-core = "0.3.26"
hydroflow_cli_integration = { path = "../hydroflow_cli_integration", version = "^0.5.2" }
indicatif = "0.17.8"
inferno = "0.11.20"
memo-map = "0.3.2"
nanoid = "0.4.0"
nix = "0.26.2"
Expand All @@ -31,4 +32,4 @@ shell-escape = "0.1.5"
tempfile = "3.3.0"
tokio = { version = "1.16", features = [ "full" ] }
tokio-stream = { version = "0.1.15", default-features = false }
tokio-util = { version = "0.7.7" }
tokio-util = { version = "0.7.7", features = [ "io-util" ] }
15 changes: 13 additions & 2 deletions hydro_deploy/core/src/hydroflow_crate/perf_options.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
use std::path::PathBuf;

#[derive(Clone)]
#[derive(Clone, buildstructor::Builder)]
#[non_exhaustive] // Prevent direct construction.
pub struct PerfOptions {
pub output_file: PathBuf,
pub frequency: u32,

/// TODO(mingwei): Only used by localhost, for now.
pub perf_outfile: Option<PathBuf>,

/// If set, what the write the folded output to.
pub fold_outfile: Option<PathBuf>,
pub fold_options: Option<inferno::collapse::perf::Options>,
/// If set, what to write the output flamegraph SVG file to.
pub flamegraph_outfile: Option<PathBuf>,
// This type is super annoying and isn't `clone` and has a lifetime... so wrap in fn pointer for now.
pub flamegraph_options: Option<fn() -> inferno::flamegraph::Options<'static>>,
}
41 changes: 24 additions & 17 deletions hydro_deploy/core/src/hydroflow_crate/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,24 +303,31 @@ impl Service for HydroflowCrateService {
}

async fn stop(&mut self) -> Result<()> {
let launched_binary = self.launched_binary.as_mut().unwrap();
launched_binary.stdin().send("stop\n".to_string())?;

let timeout_result = ProgressTracker::leaf(
self.display_id
ProgressTracker::with_group(
&self
.display_id
.clone()
.unwrap_or_else(|| format!("service/{}", self.id))
+ " / waiting for exit",
tokio::time::timeout(Duration::from_secs(60), launched_binary.wait()),
)
.await;
match timeout_result {
Err(_timeout) => {} // `wait()` timed out, but stop will force quit.
Ok(Err(unexpected_error)) => return Err(unexpected_error), // `wait()` errored.
Ok(Ok(_exit_status)) => {}
}
launched_binary.stop().await?;
.unwrap_or_else(|| format!("service/{}", self.id)),
None,
|| async {
let launched_binary = self.launched_binary.as_mut().unwrap();
launched_binary.stdin().send("stop\n".to_string())?;

Ok(())
let timeout_result = ProgressTracker::leaf(
"waiting for exit".to_owned(),
tokio::time::timeout(Duration::from_secs(60), launched_binary.wait()),
)
.await;
match timeout_result {
Err(_timeout) => {} // `wait()` timed out, but stop will force quit.
Ok(Err(unexpected_error)) => return Err(unexpected_error), // `wait()` errored.
Ok(Ok(_exit_status)) => {}
}
launched_binary.stop().await?;

Ok(())
},
)
.await
}
}
5 changes: 4 additions & 1 deletion hydro_deploy/core/src/localhost/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ impl LaunchedHost for LaunchedLocalhost {
"dwarf,64000",
"-o",
])
.arg(&perf.output_file)
.arg(
perf.perf_outfile
.expect("perf_outfile should be set for localhost perf."),
MingweiSamuel marked this conversation as resolved.
Show resolved Hide resolved
)
.arg(&binary.bin_path)
.args(args);
tmp
Expand Down
Loading
Loading