Skip to content

Commit

Permalink
Profiling instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
d-e-s-o committed Aug 4, 2023
1 parent a5a7825 commit 441d80b
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions PROFILE.md
Original file line number Diff line number Diff line change
@@ -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<Item = String>) -> anyhow::Result<Ve
}

if let Some(Some(ref unit_test)) = opt.unit_test {
- match kind.into_iter().any(|k| k == "lib") {
+ match kind.into_iter().any(|k| k == "lib" || k == "cdylib" || k == "rlib" || k == "staticlib") {
true => cmd.arg("--lib"),
false => cmd.args(&["--bin", unit_test]),
};
@@ -182,7 +182,7 @@ fn workload(opt: &Opt, artifacts: &[Artifact]) -> anyhow::Result<Vec<String>> {
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<String>,
+ bench: Option<Option<String>>,
/// Path to Cargo.toml
#[clap(long)]
@@ -115,7 +115,7 @@ fn build(opt: &Opt, kind: impl IntoIterator<Item = String>) -> anyhow::Result<Ve
cmd.arg(test);
}
- if let Some(ref bench) = opt.bench {
+ if let Some(Some(ref bench)) = opt.bench {
cmd.arg("--bench");
cmd.arg(bench);
}
@@ -178,7 +178,7 @@ fn workload(opt: &Opt, artifacts: &[Artifact]) -> anyhow::Result<Vec<String>> {
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)),
..
```

0 comments on commit 441d80b

Please sign in to comment.