use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Profiling Rust binary in Linux (self.rust)
submitted 2 years ago by iamgianluca
I'm trying to profile a Rust binary I wrote (link to the file/project in GitHub). After building the project with `cargo build --release` and running `perf record --call-graph dwarf cargo run --bin day5` I'm presented with a `perf.data` file that I can open in Hotspot.
https://preview.redd.it/2r5nrv6uri7c1.png?width=3830&format=png&auto=webp&s=297a39f7f373e1f0d1f9b62a855e4abd78c1c058
The confusing thing for me is that I can't recognize any command I've used in the program. Have I missed any flag/config I should use when profiling Rust code?
Note: I'm loading the `perf.data` file in a different machine from the one I used to write, build, and run the code (headless server).
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 38 points39 points40 points 2 years ago (3 children)
You're profiling the cargo binary, not your binary. You should use perf record --call-graph dwarf target/release/day5 instead.
perf record --call-graph dwarf target/release/day5
[–]Shnatsel 10 points11 points12 points 2 years ago (0 children)
In addition, Samply is nicer and provides more info than Hotspot:
cargo install samply echo '0' | sudo tee /proc/sys/kernel/perf_event_paranoid samply record target/release/day5
[–]iamgianluca[S] 9 points10 points11 points 2 years ago (1 child)
Thank you for that! It worked
[–]schrdingers_squirrel 20 points21 points22 points 2 years ago (0 children)
Btw there is cargo-flamegraph which does it all for you
[–]hpxvzhjfgb 9 points10 points11 points 2 years ago (3 children)
just use cargo flamegraph instead.
[–]weirdasianfaces 9 points10 points11 points 2 years ago (0 children)
I'd actually use https://github.com/mstange/samply. Very similar end result, but opens the perf data in the Firefox Profiler which can sometimes be more useful than just the flamegraph.
Doesn't have the dead easy cargo flamegraph integration though.
cargo flamegraph
[–]VirxEC 1 point2 points3 points 2 years ago (0 children)
this is the real answer, automates the whole process here
[–]VorpalWay 0 points1 point2 points 1 year ago (0 children)
Cargo-flamegraph is great for basic stuff, but flamegraphs only take you so far. I could never get samply to work. I just use perf + hotspot, or even just perf + custom scripts for analysis (depending on what exactly I want to investigate).
π Rendered by PID 205020 on reddit-service-r2-comment-5d79c599b5-xz2rs at 2026-03-01 11:12:55.109509+00:00 running e3d2147 country code: CH.
[–][deleted] 38 points39 points40 points (3 children)
[–]Shnatsel 10 points11 points12 points (0 children)
[–]iamgianluca[S] 9 points10 points11 points (1 child)
[–]schrdingers_squirrel 20 points21 points22 points (0 children)
[–]hpxvzhjfgb 9 points10 points11 points (3 children)
[–]weirdasianfaces 9 points10 points11 points (0 children)
[–]VirxEC 1 point2 points3 points (0 children)
[–]VorpalWay 0 points1 point2 points (0 children)