flamegraph-rs / flamegraph

Easy flamegraphs for Rust projects and everything else, without Perl or pipes <3
Apache License 2.0
4.74k stars 144 forks source link

feature: allow choosing custom build profiles #257

Closed jtmoon79 closed 1 year ago

jtmoon79 commented 1 year ago

tl;dr allow passing --profile to cargo flamegraph

Problem

In Cargo.toml, I optimized the release profile for the binary.

[profile.release]
codegen-units = 1
panic = "abort"
strip = true

Now cargo flamegraph fails with

$ cargo flamegraph --bin my_program
...
Error: unable to generate a flamegraph from the collapsed stack data

Caused by:
    0: I/O error: No stack counts found
    1: No stack counts found

Solution

Allow passing --profile=profile_name to cargo flamegraph, similar to cargo build --profile=.... Then flamegraph could then pass the profile_name to the underlying cargo build --profile= call. This would allow creating a custom profile for flamegraph in Cargo.toml.

For example, I would then be able to add to Cargo.toml:

[profile.flamegraph]
inherits = "release"
codegen-units = 16
panic = "unwind"
strip = false

and then I could select that build profile with

$ cargo flamegraph --bin my_program --profile flamegraph
djc commented 1 year ago

Makes sense, want to submit a PR?

jtmoon79 commented 1 year ago

Makes sense, want to submit a PR?

I'll put it on my TODO list.

jtmoon79 commented 1 year ago

@djc I think this feature was already implemented by @madadam in c532c046b171952f8812dd76b09298c0c558bf8d (Issue #167 )

https://github.com/flamegraph-rs/flamegraph/blob/8792e0927c43a53c80584948622ce7be259e60e6/src/bin/cargo-flamegraph.rs#L15-L17

Could a new version of flamegraph be released?

djc commented 1 year ago

Released https://github.com/flamegraph-rs/flamegraph/releases/tag/v0.6.3 last week.