Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow profiles to set -Cforce-frame-pointers #15333

Open
davidlattimore opened this issue Mar 19, 2025 · 1 comment
Open

Allow profiles to set -Cforce-frame-pointers #15333

davidlattimore opened this issue Mar 19, 2025 · 1 comment
Labels
A-profiles Area: profiles C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.

Comments

@davidlattimore
Copy link

davidlattimore commented Mar 19, 2025

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.

@davidlattimore davidlattimore added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Mar 19, 2025
@epage epage added A-profiles Area: profiles S-needs-team-input Status: Needs input from team on whether/how to proceed. and removed S-triage Status: This issue is waiting on initial triage. labels Mar 20, 2025
@hanna-kruppe
Copy link

Currently, I instead turn it on globally in my ~/.cargo/config.toml.

Note that these config settings don’t have to be global, you can add a .cargo/config.toml file to your workspace root for example. Not quite a replacement for a profile setting for several reasons but FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-profiles Area: profiles C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-team-input Status: Needs input from team on whether/how to proceed.
Projects
None yet
Development

No branches or pull requests

3 participants