Issues in profiling a Rust application

  1. I first used the tool flamegraph (which relies on perf) to profile my Rust application. It works at first until it throw segmentation fault which seems to be a bug in perf.
  2. I then tried to profile my Rust application using valgrind. It sort of works but I found another issue with it. It seems that valgrind dumps performance data of public methods only. Manually marking methods as pub successfully makes valgrind dump performance data for them but there were a few exceptions. I wonder is there any special configuration of rustc or valgrind that I missed or is this a compatible issue of valgrind with Rust.
  3. Does anyone have good experiences with other (CPU) profiling tools for Rust?

Did you add debug info to your release build? [profile.release] debug = true in Cargo.toml. This should give you data for private methods too.

On macOS I use Xcode

1 Like

Yes, I do have debug = true for the release profile. And I've tried the dev profile too. Both of them have the same issue. I'm using flamegraph and valgrind in Ubuntu 20.04 (via Docker).

Extra flag that might help with perf build RUSTFLAGS="-g -Cforce-frame-pointers=on"
I tend to run perf record with -m 1M

I've used [cargo flamegraph] ( successfully in the past. Maybe it will work better or more easily than the flamegraph you used?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.