From 441d80b6f1e5ba7fdc89659bec6ba7a97b4f3185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Fri, 4 Aug 2023 15:06:02 -0700 Subject: [PATCH] Profiling instructions --- PROFILE.md | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 PROFILE.md diff --git a/PROFILE.md b/PROFILE.md new file mode 100644 index 000000000..56f8e2f61 --- /dev/null +++ b/PROFILE.md @@ -0,0 +1,90 @@ +set -x PATH "~/local/opt/flamegraph/target/release/:$PATH" +cargo flamegraph --bench main --root -- --bench normalize_process + +cargo flamegraph --package=blazesym --unit-bench --root --features=nightly -- bench_function_parsing +(requires +https://github.com/d-e-s-o/flamegraph/commit/9f5443b4e6699993d390059bf19f4059281bb5a7) + +With flamegraph patch: +PATH="~/local/opt/flamegraph/target/release:$PATH" cargo flamegraph --verbose --profile=bench --package=blazesym --unit-test -- dwarf::resolver::tests::source_location_finding + +```patch +--- cargo-flamegraph.rs ++++ cargo-flamegraph.rs +@@ -121,7 +121,7 @@ fn build(opt: &Opt, kind: impl IntoIterator) -> anyhow::Result cmd.arg("--lib"), + false => cmd.args(&["--bin", unit_test]), + }; +@@ -182,7 +182,7 @@ fn workload(opt: &Opt, artifacts: &[Artifact]) -> anyhow::Result> { + Opt { + unit_test: Some(Some(t)), + .. +- } => (&["lib", "bin"], t), ++ } => (&["lib", "cdylib", "rlib", "staticlib", "bin"], t), + _ => return Err(anyhow!("no target for profiling")), + }; + +@@ -407,7 +407,7 @@ fn main() -> anyhow::Result<()> { + target.kind + } else if let Some(unit_test) = opt.unit_test { + let target = find_unique_target( +- &["bin", "lib"], ++ &["bin", "lib", "cdylib", "rlib", "staticlib"], + opt.package.as_deref(), + opt.manifest_path.as_deref(), + unit_test.as_deref(), +``` + +OR + +```patch +--- Cargo.toml ++++ Cargo.toml +@@ -35,7 +35,7 @@ autobenches = false + + [lib] + name = "blazesym" +-crate-type = ["cdylib", "rlib", "staticlib"] ++#crate-type = ["cdylib", "rlib", "staticlib"] + + [features] + default = ["demangle", "dwarf", "lru"] +``` + + +``` +--- bin/cargo-flamegraph.rs ++++ bin/cargo-flamegraph.rs +@@ -40,7 +40,7 @@ struct Opt { + + /// Benchmark to run + #[clap(long, group = "exec-args")] +- bench: Option, ++ bench: Option>, + + /// Path to Cargo.toml + #[clap(long)] +@@ -115,7 +115,7 @@ fn build(opt: &Opt, kind: impl IntoIterator) -> anyhow::Result anyhow::Result> { + example: Some(t), .. + } => (&["example"], t), + Opt { test: Some(t), .. } => (&["test"], t), +- Opt { bench: Some(t), .. } => (&["bench"], t), ++ Opt { bench: Some(Some(t)), .. } => (&["bench"], t), + Opt { + unit_test: Some(Some(t)), + .. +```