fxprof-processed-profile
Build profiles in the Firefox Profiler processed JSON format from Rust.
Repository Health
Technical Analysis
fxprof-processed-profile is a Rust crate for constructing performance profiles in the Firefox Profiler’s processed profile JSON format, ready to load into profiler.firefox.com. It provides a Profile builder into which you add processes, threads, samples, stacks, frames, markers, and categories, then serialize to JSON via serde.
Part of the samply profiler project, the crate models the profiler’s data structures with handle-based APIs for strings, frames, and stacks so large profiles stay compact and efficient to assemble. It is the format-building layer used to turn sampled call-stack data into interactive flame graphs and timelines in the Firefox Profiler UI.
What You Get
- A Profile builder for the Firefox Profiler processed JSON format
- Handle-based APIs for strings, frames, and stacks to keep large profiles compact
- serde-based serialization straight to JSON loadable at profiler.firefox.com
Common Use Cases
- Exporting a custom profiler’s samples into a format the Firefox Profiler can visualize
- Generating flame graphs and timelines from sampled call-stack data
- Adding markers and categories to enrich a performance profile
Under The Hood
Architecture
The crate exposes a Profile aggregate that owns processes, threads, and interned tables for strings, frames, and stacks. Callers add data through handle-returning methods (handle_for_string, handle_for_frame_with_label, handle_for_stack, add_sample), building a stack tree by reference rather than duplicating frames. Serialization is driven by serde derive implementations that emit the Firefox Profiler processed schema.
Tech Stack
Rust (edition 2021, MSRV 1.63) depending on serde, serde_derive, serde_json, bitflags, debugid, rustc-hash, and indexmap (with serde feature); assert-json-diff is used in tests.
Code Quality
Maintained as part of the actively-developed samply project (thousands of commits, dozens of contributors) with JSON-diff tests validating serialized output against expected fixtures.
API Design
The handle-based builder keeps the API allocation-conscious and hard to misuse, and the documented example shows a complete profile assembled in a few lines before serializing with serde_json.