flamegraph icon indicating copy to clipboard operation
flamegraph copied to clipboard

Flamegraph of non "default-member" binary in a Workspace project

Open andrewdavidmackenzie opened this issue 3 years ago • 4 comments

I have a workspace project with this Cargo.toml:

[workspace]
members = ["flowc", "flowr", "flowrstructs", "provider", "flow_impl", "flow_impl_derive", "flowstdlib", "samples"]
default-members = ["flowc"]

So that cargo run runs flowc by default.

To run other binaries I use the -p (package) flag of cargo, thus: cargo run -p flowr -- -n samples/fibonacci

I can't figure out how to generate a flamegraph for flowr using cargo. Here are the options I have tried:

cargo flamegraph --dev -p flowr -- -n samples/fibonacci
    Finished dev [unoptimized + debuginfo] target(s) in 0.28s
several possible targets found: ["flowc", "flowc-loader_tests", "flowc-compiler_tests", "flowc-execution_tests", "helper", "flowc-sample_loading_tests", "flowr", "flowr-loader_tests", "flowstdlib", "build-script-build", "flowsamples", "build-script-build"], please pass `--bin <binary>` or `--example <example>` to cargo flamegraph to choose one of them

or

cargo flamegraph --dev --bin flowr -- -n samples/fibonacci
error: no bin target named `flowr`

        Did you mean `flowc`?
cargo build failed: None

or following flamegraph readme that shows --bin=<binary>

cargo flamegraph --dev --bin=flowr -- -n samples/fibonacci
error: no bin target named `flowr`

        Did you mean `flowc`?
cargo build failed: None

I'll try by using flamegraph directly (without cargo) and the path to the binary, but would appreciate being able to use cargo. Thanks.

andrewdavidmackenzie avatar Dec 30 '20 10:12 andrewdavidmackenzie

Are you using version 0.4 already?

djc avatar Dec 30 '20 11:12 djc

Yes, just build from source using cargo install

andrewdavidmackenzie avatar Dec 30 '20 11:12 andrewdavidmackenzie

Can you try running with -v/--verbose? This should give you more info about what path it is searching for.

djc avatar Dec 30 '20 13:12 djc

You could also just review the source code to see what might need changing:

https://github.com/flamegraph-rs/flamegraph/blob/master/src/bin/cargo-flamegraph.rs#L254

djc avatar Dec 30 '20 13:12 djc