Skip to content

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

Open
@davidlattimore

Description

@davidlattimore

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-profilesArea: profilesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions