jemalloc_pprof

Convert jemalloc heap profiles to pprof format for memory leak and OOM debugging

Tool
Cargo
v0.9.0
276stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
46/100Fair
Development Activity36
Maintenance12
Community60
Maturity48
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture80
Code Quality74
Innovation76
Learning Curve62

jemalloc_pprof converts heap profiling data collected by the jemalloc memory allocator into Google’s pprof protocol buffer format, so Rust services can plug memory profiling into the same tooling ecosystem (pprof viewers, flamegraph generators, continuous profiling platforms) already used across Go and other pprof-native languages. It was originally developed inside Materialize and later extracted into this standalone library in collaboration with Polar Signals, the company behind the Parca continuous profiling project.

The crate works by interacting with jemalloc via tikv-jemalloc-ctl to trigger and read heap profile dumps, then translating jemalloc’s native profile format into pprof’s protobuf schema (via the sibling mappings and util/pprof_util workspace crates), optionally producing flamegraphs directly or symbolizing stack frames. It requires switching the process’s global allocator to jemalloc via tikv-jemallocator with its profiling feature enabled, and currently only supports Linux.

What You Get

  • Conversion of jemalloc heap profile dumps into Google’s pprof protobuf format for use with standard pprof tooling
  • Direct flamegraph generation from heap profiles via the flamegraph feature
  • Stack frame symbolization support via the symbolize feature for human-readable profile output
  • A workspace of focused sibling crates (mappings for memory-map parsing, util/pprof_util for shared pprof encoding) that other profiling tools can reuse independently
  • A capi crate exposing the conversion functionality to non-Rust callers via a C ABI

Common Use Cases

  • Diagnosing a Rust service’s memory leak by capturing and converting jemalloc heap profiles for visual inspection in pprof or Parca
  • Investigating recurring OOM kills in a containerized Rust service by feeding periodic heap snapshots into continuous profiling infrastructure
  • Continuously exporting heap profiles from production Rust services to Polar Signals Cloud or a self-hosted Parca instance
  • Generating flamegraphs of memory allocation hotspots during performance/memory optimization work

Under The Hood

Architecture The crate (src/lib.rs) is deliberately thin — it drives tikv-jemalloc-ctl to trigger jemalloc heap dumps, then delegates the actual profile translation to two sibling workspace crates: mappings (parsing /proc/self/maps-style memory mapping info needed to attribute addresses to binaries/libraries) and util, published separately as pprof_util (shared pprof protobuf encoding logic used across Polar Signals’ profiling tools). A separate capi crate wraps the conversion logic behind a C ABI, and an example crate demonstrates end-to-end usage, giving the workspace a clean core-plus-bindings-plus-example structure. Tech Stack Rust 2021 edition, Linux-only. Built on tikv-jemalloc-ctl (the interface to jemalloc’s control/stats API) and prost for pprof protobuf encoding/decoding, with optional inferno (flamegraph rendering) and backtrace (symbolization) pulled in behind the flamegraph/symbolize features respectively. Requires the host application to also depend on tikv-jemallocator with its profiling feature to actually enable jemalloc’s profiling hooks. Code Quality The core src/lib.rs is compact at under 200 lines, with the bulk of the conversion complexity factored out into the mappings and util crates rather than inlined — a sign of deliberate separation of concerns rather than a monolithic implementation. GitHub activity shows infrequent maintenance commits, consistent with a narrowly-scoped utility crate that reaches feature-completeness rather than needing continuous churn. API Design Because this crate exists specifically to interoperate with an established external format (pprof) and a specific allocator (jemalloc), its API surface is necessarily narrow and tightly coupled to both: users must already be running jemalloc via tikv-jemallocator with profiling enabled before this crate does anything useful. The README is explicit and upfront about this prerequisite plus the Linux-only requirement, which keeps expectations realistic even though it does narrow the audience versus a more general-purpose profiling tool.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search