Description
Problem
When profiling Rust code on Linux using perf
, I can either use perf record
with --call-graph=dwarf
or I can enable frame pointers during the build by passing -Cforce-frame-pointers
to rustc. With frame pointers, a perf run is substantially faster to process. My understanding is that this is because stack traces can be captured in the kernel with eBPF, which can follow the frame pointers, whereas with debug info it's all done by calling addr2line
after the fact.
For a profiling run I just did, it took more than 8 minutes to process the perf data when using debug info and less than a second when using frame pointers.
I'd like to be able to turn on frame pointers for a particular profile in my Cargo.toml
. Currently, I instead turn it on globally in my ~/.cargo/config.toml
.
Proposed Solution
Add force-frame-pointers
as an option in cargo profiles. e.g.
[profile.profiling]
inherits = "release"
force-frame-pointers = true
Notes
If it's agreed that this is a reasonable feature to add, I'm happy to implement it.