Can anyone help me understand how jemalloc + pprof work in Rust?

I am coming from Golang background, and pprof works out of box for CPU and memory with pprof package - net/http/pprof - Go Packages. Nice and easy.

When I work on Rust, I find CPU profile works similarly to Go. But for memory, it is not out of box. I used GitHub - polarsignals/rust-jemalloc-pprof: Convert jemalloc heap profiles to pprof to understand memory usage, fix memory leaks, and fix OOM Kills. for memory profile.

The way I used profile is:

  1. setup some web handlers, so profile is triggered when receiving a request like /debug/pprofile/heap (for memory profile) or /debug/pprofile/cpu (for cpu profile)
  2. call the curl remotely from my local machine
  3. use pprof to analyze the profile dump on my local machine.

I find it works for Golang cpu/heap and Rust cpu profile. But for memory, I am seeing Local symbolization failed for xxxxx-a2099af8e65d354b (build ID c04fcdbe120999b2): stat /tmp/xxxxx-a2099af8e65d354b. I can get around it by setting PPROF_BINARY_PATH and download xxxxx-a2099af8e65d354b to my local host.

But I do not understand why I only need to do this for Rust jemalloc memory profile?

1 Like

I don't know anything about memory profiling, but Rust has not used jemalloc by default since version 1.32.0. If you want to use jemalloc-specific features, you will have to add a jemalloc binding library and declare it as the #[global_allocator].

1 Like

Thank you, we enabled jemalloc manually

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.