### Start Profiling with ProfilerGuard::new Source: https://context7.com/tikv/pprof-rs/llms.txt Starts CPU profiling immediately at a specified frequency. Profiling stops when the guard is dropped. This example demonstrates basic usage and printing a human-readable report. ```rust use std::fs::File; fn main() { // Start profiling at 100 Hz let guard = pprof::ProfilerGuard::new(100).unwrap(); // --- code under profiling --- let mut sum = 0u64; for i in 0..10_000_000u64 { sum = sum.wrapping_add(i); } println!("sum = {}", sum); // ---------------------------- // Build a human-readable report and print it if let Ok(report) = guard.report().build() { println!("{:?}", report); // Example output line: // FRAME: my_crate::main::h... -> THREAD: main 42 } // Guard dropped here → profiling stops } ``` -------------------------------- ### Start Profiling with ProfilerGuardBuilder Source: https://github.com/tikv/pprof-rs/blob/master/README.md Initialize the profiler guard to begin CPU profiling. Configure frequency and blocklisted symbols. Profiling continues until the guard is dropped. ```rust let guard = pprof::ProfilerGuardBuilder::default().frequency(1000).blocklist(&["libc", "libgcc", "pthread", "vdso"]).build().unwrap(); ``` -------------------------------- ### Use pprof command-line tool Source: https://github.com/tikv/pprof-rs/blob/master/README.md Example command to generate an SVG flamegraph from a protobuf profile file using the `pprof` command-line tool. ```shell ~/go/bin/pprof -svg profile.pb ``` -------------------------------- ### ProfilerGuard::new Source: https://context7.com/tikv/pprof-rs/llms.txt Starts CPU profiling immediately with a specified samples-per-second frequency. Profiling stops automatically when the guard is dropped. ```APIDOC ## ProfilerGuard::new — Start profiling with a fixed frequency Creates a `ProfilerGuard` that immediately begins CPU profiling at the given samples-per-second frequency. Profiling stops and internal state is reset when the guard is dropped. ```rust use std::fs::File; fn main() { // Start profiling at 100 Hz let guard = pprof::ProfilerGuard::new(100).unwrap(); // --- code under profiling --- let mut sum = 0u64; for i in 0..10_000_000u64 { sum = sum.wrapping_add(i); } println!("sum = {}", sum); // ---------------------------- // Build a human-readable report and print it if let Ok(report) = guard.report().build() { println!("{:?}", report); // Example output line: // FRAME: my_crate::main::h... -> THREAD: main 42 } // Guard dropped here → profiling stops } ``` ``` -------------------------------- ### Build Profiler with Advanced Options using ProfilerGuardBuilder Source: https://context7.com/tikv/pprof-rs/llms.txt Allows advanced configuration of the profiler, including sampling frequency and a shared-library blocklist to prevent deadlocks. This example sets a frequency of 1000 Hz and blocks common system libraries. ```rust fn main() { let guard = pprof::ProfilerGuardBuilder::default() .frequency(1000) // Skip frames whose first address falls inside these libraries, // preventing potential deadlocks with libgcc's libunwind and // incorrect DWARF info in vdso on some Linux distributions. .blocklist(&["libc", "libgcc", "pthread", "vdso"]) .build() .unwrap(); // workload for _ in 0..100_000 { let _ = (0..1000u64).sum::(); } if let Ok(report) = guard.report().build() { println!("Samples collected: {}", report.data.values().sum::()); } } ``` -------------------------------- ### pprof Error Handling with ProfilerGuard Source: https://context7.com/tikv/pprof-rs/llms.txt Demonstrates handling errors from pprof APIs, which return `pprof::Result`. Covers signal-handler setup, I/O errors, and lifecycle violations. ```rust use pprof::{Error, ProfilerGuard}; match ProfilerGuard::new(100) { Ok(guard) => { // workload match guard.report().build() { Ok(report) => println!("OK – {} stacks", report.data.len()), Err(Error::CreatingError) => eprintln!("profiler was never initialized"), Err(e) => eprintln!("report failed: {}", e), } } Err(Error::Running) => eprintln!("profiler already running"), Err(Error::NixError(e)) => eprintln!("signal setup failed: {}", e), Err(e) => eprintln!("unexpected error: {}", e), } ``` -------------------------------- ### Produce Symbolicated Report with ReportBuilder::build Source: https://context7.com/tikv/pprof-rs/llms.txt Consumes profiler samples to create a symbolicated `Report`. The report contains a map of call stacks to sample counts and timing metadata. This example iterates through the collected data and prints details about each stack trace. ```rust use std::collections::HashMap; use pprof::{Frames, Report}; let guard = pprof::ProfilerGuard::new(99).unwrap(); // ... workload ... match guard.report().build() { Ok(report) => { // Iterate every unique stack and its hit count for (frames, count) in &report.data { println!( "thread={} hits={} top_frame={:?}", frames.thread_name_or_id(), count, frames.frames.first() .and_then(|f| f.first()) .map(|s| s.name()) .unwrap_or_default() ); } println!( "Profiled for {:.2}s at {} Hz", report.timing.duration.as_secs_f64(), report.timing.frequency, ); } Err(e) => eprintln!("report error: {}", e), } ``` -------------------------------- ### Error Handling with pprof::Error Source: https://context7.com/tikv/pprof-rs/llms.txt All fallible pprof APIs return `pprof::Result`, which is an alias for `std::result::Result`. The `Error` enum encompasses various failure scenarios, including signal-handler setup issues, I/O errors from spill files, and lifecycle violations such as starting a profiler that is already running or stopping one that is not active. ```APIDOC ## Error handling — `pprof::Error` All fallible pprof APIs return `pprof::Result` (`std::result::Result`). The error enum covers signal-handler setup failures, I/O errors from the spill file, and lifecycle violations (starting an already-running profiler, or stopping one that is not running). ```rust use pprof::{Error, ProfilerGuard}; match ProfilerGuard::new(100) { Ok(guard) => { // workload match guard.report().build() { Ok(report) => println!("OK – {} stacks", report.data.len()), Err(Error::CreatingError) => eprintln!("profiler was never initialized"), Err(e) => eprintln!("report failed: {}", e), } } Err(Error::Running) => eprintln!("profiler already running"), Err(Error::NixError(e)) => eprintln!("signal setup failed: {}", e), Err(e) => eprintln!("unexpected error: {}", e), } ``` ``` -------------------------------- ### Produce Raw Unresolved Report with ReportBuilder::build_unresolved Source: https://context7.com/tikv/pprof-rs/llms.txt Returns profiler data without symbol resolution, providing raw addresses. This is useful for off-process symbolication or when avoiding allocations during report generation. The example prints the number of unique unresolved stacks and their counts. ```rust let guard = pprof::ProfilerGuard::new(99).unwrap(); // ... workload ... if let Ok(unresolved) = guard.report().build_unresolved() { println!( "Unique stacks (unresolved): {}", unresolved.data.len() ); for (unresolved_frames, count) in &unresolved.data { // unresolved_frames.frames contains raw backtrace::Frame values println!(" count={} thread_id={}", count, unresolved_frames.thread_id); } } ``` -------------------------------- ### `Report::pprof` Source: https://context7.com/tikv/pprof-rs/llms.txt Converts the report into a `protos::Profile` message compatible with Google's pprof tool. The profile can then be written to disk and analyzed with `go tool pprof`, Grafana Phlare, or any other pprof-compatible viewer. ```APIDOC ## `Report::pprof` — Export as `profile.proto` (features: `prost-codec` or `protobuf-codec`) Converts the report into a `protos::Profile` message compatible with Google's pprof tool. The profile can then be written to disk and analyzed with `go tool pprof`, Grafana Phlare, or any other pprof-compatible viewer. ```toml # Cargo.toml – choose one codec: pprof = { version = "0.15", features = ["prost-codec"] } # or pprof = { version = "0.15", features = ["protobuf-codec"] } ``` ```rust // With prost-codec use pprof::protos::Message; use std::{fs::File, io::Write}; let guard = pprof::ProfilerGuard::new(100).unwrap(); let _: u64 = (0..50_000_000).sum(); if let Ok(report) = guard.report().build() { let profile = report.pprof().unwrap(); let mut buf = Vec::new(); profile.encode(&mut buf).unwrap(); // prost::Message::encode let mut file = File::create("profile.pb").unwrap(); file.write_all(&buf).unwrap(); // Analyze: go tool pprof -http=:8080 profile.pb } ``` ``` -------------------------------- ### Generate pprof Profile Proto Source: https://github.com/tikv/pprof-rs/blob/master/README.md Generate a pprof profile in protobuf format. Requires the `protobuf` feature to be enabled. The output can be consumed by the `pprof` command-line tool. ```rust match guard.report().build() { Ok(report) => { let mut file = File::create("profile.pb").unwrap(); let profile = report.pprof().unwrap(); let mut content = Vec::new(); profile.encode(&mut content).unwrap(); file.write_all(&content).unwrap(); println!("report: {}", &report); } Err(_) => {} }; ``` -------------------------------- ### Multi-threaded Profiling with `ProfilerGuard` Source: https://context7.com/tikv/pprof-rs/llms.txt Demonstrates safe multi-threaded profiling where `ProfilerGuard` captures samples from all threads automatically. Thread names are preserved. ```rust use std::sync::Arc; let guard = pprof::ProfilerGuard::new(100).unwrap(); let data = Arc::new(vec![2u64, 3, 5, 7, 11]); let handles: Vec<_> = (0..4).map(|i| { let d = Arc::clone(&data); std::thread::Builder::new() .name(format!("worker-{}", i)) .spawn(move || { let _: u64 = (0..5_000_000).map(|x| d[x % d.len()]).sum(); }) .unwrap() }).collect(); for h in handles { h.join().unwrap(); } if let Ok(report) = guard.report().build() { for (frames, count) in &report.data { println!("thread={:>12} hits={}", frames.thread_name_or_id(), count); } } ``` -------------------------------- ### Export Profile as `profile.proto` Source: https://context7.com/tikv/pprof-rs/llms.txt Converts the collected profile into a `protos::Profile` message for analysis with external tools like `go tool pprof`. Requires `prost-codec` or `protobuf-codec` feature. ```toml # Cargo.toml – choose one codec: pprof = { version = "0.15", features = ["prost-codec"] } # or pprof = { version = "0.15", features = ["protobuf-codec"] } ``` ```rust // With prost-codec use pprof::protos::Message; use std::{fs::File, io::Write}; let guard = pprof::ProfilerGuard::new(100).unwrap(); let _: u64 = (0..50_000_000).sum(); if let Ok(report) = guard.report().build() { let profile = report.pprof().unwrap(); let mut buf = Vec::new(); profile.encode(&mut buf).unwrap(); // prost::Message::encode let mut file = File::create("profile.pb").unwrap(); file.write_all(&buf).unwrap(); // Analyze: go tool pprof -http=:8080 profile.pb } ``` -------------------------------- ### `Report::flamegraph_with_options` Source: https://context7.com/tikv/pprof-rs/llms.txt Same as `flamegraph`, but accepts an `inferno::flamegraph::Options` struct for full control over colors, image width, title, reverse stacks, and other rendering parameters. ```APIDOC ## `Report::flamegraph_with_options` — Write a flamegraph with custom inferno options (feature: `flamegraph`) Same as `flamegraph`, but accepts an `inferno::flamegraph::Options` struct for full control over colors, image width, title, reverse stacks, and other rendering parameters. ```rust use std::fs::File; use pprof::flamegraph::Options; let guard = pprof::ProfilerGuard::new(100).unwrap(); let _: u64 = (0..50_000_000).sum(); if let Ok(report) = guard.report().build() { let file = File::create("flamegraph_custom.svg").unwrap(); let mut opts = Options::default(); opts.image_width = Some(2500); opts.title = "My Service CPU Profile".to_string(); opts.reverse_stack_order = false; report.flamegraph_with_options(file, &mut opts).unwrap(); } ``` ``` -------------------------------- ### Write an SVG Flamegraph with `Report::flamegraph` Source: https://context7.com/tikv/pprof-rs/llms.txt Converts collected profile data into an interactive SVG flamegraph. Requires the `flamegraph` Cargo feature. Ensure `std::io::Write` is available. ```toml # Cargo.toml [dependencies] pprof = { version = "0.15", features = ["flamegraph"] } ``` ```rust use std::fs::File; let guard = pprof::ProfilerGuard::new(100).unwrap(); // CPU-bound workload let _: u64 = (0..50_000_000).sum(); if let Ok(report) = guard.report().build() { let file = File::create("flamegraph.svg").unwrap(); report.flamegraph(file).unwrap(); // Open flamegraph.svg in a browser to explore the interactive chart } ``` -------------------------------- ### Generate Flamegraph Report Source: https://github.com/tikv/pprof-rs/blob/master/README.md Generate a flamegraph visualization from the profiling report and write it to a file. Requires the 'flamegraph' feature. ```rust use std::fs::File; if let Ok(report) = guard.report().build() { let file = File::create("flamegraph.svg").unwrap(); report.flamegraph(file).unwrap(); }; ``` -------------------------------- ### ProfilerGuardBuilder Source: https://context7.com/tikv/pprof-rs/llms.txt A builder for creating a `ProfilerGuard` with advanced configuration options, including sampling frequency, a shared-library blocklist, and alternate-stack delivery. ```APIDOC ## ProfilerGuardBuilder — Build a profiler with advanced options A builder that allows setting the sampling frequency, a shared-library blocklist (to prevent deadlocks from non-signal-safe unwinders), and (with the `frame-pointer` feature) alternate-stack delivery. ```rust fn main() { let guard = pprof::ProfilerGuardBuilder::default() .frequency(1000) // Skip frames whose first address falls inside these libraries, // preventing potential deadlocks with libgcc's libunwind and // incorrect DWARF info in vdso on some Linux distributions. .blocklist(&["libc", "libgcc", "pthread", "vdso"]) .build() .unwrap(); // workload for _ in 0..100_000 { let _ = (0..1000u64).sum::(); } if let Ok(report) = guard.report().build() { println!("Samples collected: {}", report.data.values().sum::()); } } ``` ``` -------------------------------- ### Generate and Print Profiling Report Source: https://github.com/tikv/pprof-rs/blob/master/README.md Build and print a human-readable stack counter report using the profiling guard. Requires the `Debug` implementation for `Report`. ```rust if let Ok(report) = guard.report().build() { println!("report: {:?}", &report); }; ``` -------------------------------- ### Generate Flamegraph with Custom Options Source: https://github.com/tikv/pprof-rs/blob/master/README.md Generate a flamegraph with customizable options, such as image width. Requires the 'flamegraph' feature. ```rust use std::fs::File; if let Ok(report) = guard.report().build() { let file = File::create("flamegraph.svg").unwrap(); let mut options = pprof::flamegraph::Options::default(); options.image_width = Some(2500); report.flamegraph_with_options(file, &mut options).unwrap(); }; ``` -------------------------------- ### Criterion Benchmarking with pprof Flamegraph Source: https://context7.com/tikv/pprof-rs/llms.txt Integrates pprof with Criterion for generating flamegraph SVGs during benchmarks. Requires `flamegraph` and `criterion` features. Run with `cargo bench --features="flamegraph criterion"`. ```rust #[macro_use] extern crate criterion; use criterion::{black_box, Criterion}; use pprof::criterion::{Output, PProfProfiler}; fn my_function(n: u64) -> u64 { (1..=n).product() } fn bench(c: &mut Criterion) { c.bench_function("factorial_20", |b| { b.iter(|| my_function(black_box(20))) }); } criterion_group! { name = benches; // Attach pprof at 100 Hz, emit flamegraph.svg per benchmark config = Criterion::default() .with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); targets = bench } criterion_main!(benches); // Run: cargo bench --features="flamegraph criterion" // Output: target/criterion/factorial_20/profile/flamegraph.svg ``` -------------------------------- ### Write Flamegraph with Custom Options using `flamegraph_with_options` Source: https://context7.com/tikv/pprof-rs/llms.txt Generates an SVG flamegraph with customizable rendering parameters like image width, title, and stack order. Requires the `flamegraph` Cargo feature. ```rust use std::fs::File; use pprof::flamegraph::Options; let guard = pprof::ProfilerGuard::new(100).unwrap(); let _: u64 = (0..50_000_000).sum(); if let Ok(report) = guard.report().build() { let file = File::create("flamegraph_custom.svg").unwrap(); let mut opts = Options::default(); opts.image_width = Some(2500); opts.title = "My Service CPU Profile".to_string(); opts.reverse_stack_order = false; report.flamegraph_with_options(file, &mut opts).unwrap(); } ``` -------------------------------- ### Integrate with Criterion for Profiling Source: https://github.com/tikv/pprof-rs/blob/master/README.md Configure Criterion to use `PProfProfiler` for generating flamegraphs or protobuf profiles during benchmarks. Specify the sample rate and output type. ```rust use pprof::criterion::{PProfProfiler, Output}; criterion_group!{ name = benches; config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); targets = bench } criterion_main!(benches); ``` -------------------------------- ### `Report::flamegraph` Source: https://context7.com/tikv/pprof-rs/llms.txt Converts the collected profile into an interactive SVG flamegraph and writes it to any `std::io::Write` sink. Requires the `flamegraph` Cargo feature. ```APIDOC ## `Report::flamegraph` — Write an SVG flamegraph (feature: `flamegraph`) Converts the collected profile into an interactive SVG flamegraph and writes it to any `std::io::Write` sink. Requires the `flamegraph` Cargo feature. ```toml # Cargo.toml [dependencies] pprof = { version = "0.15", features = ["flamegraph"] } ``` ```rust use std::fs::File; let guard = pprof::ProfilerGuard::new(100).unwrap(); // CPU-bound workload let _: u64 = (0..50_000_000).sum(); if let Ok(report) = guard.report().build() { let file = File::create("flamegraph.svg").unwrap(); report.flamegraph(file).unwrap(); // Open flamegraph.svg in a browser to explore the interactive chart } ``` ``` -------------------------------- ### Add pprof Dependency with Flamegraph Feature Source: https://github.com/tikv/pprof-rs/blob/master/README.md Include the pprof crate in your Cargo.toml with the 'flamegraph' feature enabled to generate flamegraph reports. ```toml pprof = { version = "0.15", features = ["flamegraph"] } ``` -------------------------------- ### ReportBuilder::build Source: https://context7.com/tikv/pprof-rs/llms.txt Produces a symbolicated `Report` by consuming accumulated profiler samples. The report includes a map of call stacks to sample counts and timing metadata. ```APIDOC ## ReportBuilder::build — Produce a symbolicated `Report` Consumes the samples accumulated in the profiler and returns a `Report` whose `data` field is a `HashMap` mapping each unique call stack to its sample count. The `Report` also carries `timing` metadata (frequency, start time, elapsed duration). ```rust use std::collections::HashMap; use pprof::{Frames, Report}; let guard = pprof::ProfilerGuard::new(99).unwrap(); // ... workload ... match guard.report().build() { Ok(report) => { // Iterate every unique stack and its hit count for (frames, count) in &report.data { println!( "thread={} hits={} top_frame={:?}", frames.thread_name_or_id(), count, frames.frames.first() .and_then(|f| f.first()) .map(|s| s.name()) .unwrap_or_default() ); } println!( "Profiled for {:.2}s at {} Hz", report.timing.duration.as_secs_f64(), report.timing.frequency, ); } Err(e) => eprintln!("report error: {}", e), } ``` ``` -------------------------------- ### Generate Flamegraph Report Source: https://github.com/tikv/pprof-rs/blob/master/README.md Generate a flamegraph SVG report after applying a custom frame post-processor. Requires `File` and `Report` types. ```rust if let Ok(report) = guard.frames_post_processor(frames_post_processor()).report().build() { let file = File::create("flamegraph.svg").unwrap(); report.flamegraph(file).unwrap(); } ``` -------------------------------- ### Address Validation Utility Source: https://context7.com/tikv/pprof-rs/llms.txt The `pprof::validate(addr)` function checks if a raw pointer address is readable. This is primarily used internally for safe frame-pointer walks but is exposed as a public API for custom unwinder implementations. ```APIDOC ## `validate` — Address validation utility `pprof::validate(addr)` checks whether a raw pointer address is readable, which is used internally to guard against unsafe frame-pointer walks. It is exposed as a public API for users who implement custom unwinders. ```rust use pprof::validate; let stack_var: u64 = 42; let addr = &stack_var as *const u64 as usize; if validate(addr) { println!("Address 0x{:x} is readable", addr); } else { println!("Address 0x{:x} is NOT readable", addr); } // Null pointer is always invalid assert!(!validate(0)); ``` ``` -------------------------------- ### Define Custom Frame Post Processor Source: https://github.com/tikv/pprof-rs/blob/master/README.md Implement a closure to modify raw statistic data before report generation. Useful for grouping symbols or threads, and demangling names. Requires the `Regex` type. ```rust fn frames_post_processor() -> impl Fn(&mut pprof::Frames) { let thread_rename = [ (Regex::new(r"^grpc-server-\d*$").unwrap(), "grpc-server"), (Regex::new(r"^cop-high\d*$").unwrap(), "cop-high"), (Regex::new(r"^cop-normal\d*$").unwrap(), "cop-normal"), (Regex::new(r"^cop-low\d*$").unwrap(), "cop-low"), (Regex::new(r"^raftstore-\d*$").unwrap(), "raftstore"), (Regex::new(r"^raftstore-\d*-\d*$").unwrap(), "raftstore"), (Regex::new(r"^sst-importer\d*$").unwrap(), "sst-importer"), ( Regex::new(r"^store-read-low\d*$").unwrap(), "store-read-low", ), (Regex::new(r"^rocksdb:bg\d*$").unwrap(), "rocksdb:bg"), (Regex::new(r"^rocksdb:low\d*$").unwrap(), "rocksdb:low"), (Regex::new(r"^rocksdb:high\d*$").unwrap(), "rocksdb:high"), (Regex::new(r"^snap sender\d*$").unwrap(), "snap-sender"), (Regex::new(r"^snap-sender\d*$").unwrap(), "snap-sender"), (Regex::new(r"^apply-\d*$").unwrap(), "apply"), (Regex::new(r"^future-poller-\d*$").unwrap(), "future-poller"), ]; move |frames| { for (regex, name) in thread_rename.iter() { if regex.is_match(&frames.thread_name) { frames.thread_name = name.to_string(); } } } } ``` -------------------------------- ### Validate Address Readability with pprof Source: https://context7.com/tikv/pprof-rs/llms.txt Checks if a raw pointer address is readable, used internally for safe frame-pointer walks. Useful for custom unwinders. Null pointers are always invalid. ```rust use pprof::validate; let stack_var: u64 = 42; let addr = &stack_var as *const u64 as usize; if validate(addr) { println!("Address 0x{:x} is readable", addr); } else { println!("Address 0x{:x} is NOT readable", addr); } // Null pointer is always invalid assert!(!validate(0)); ``` -------------------------------- ### Mutate Frames Before Report Building with `frames_post_processor` Source: https://context7.com/tikv/pprof-rs/llms.txt Register a closure to modify frames before report finalization. Useful for grouping threads by name patterns or stripping unwanted frames. Requires `regex` crate. ```rust use regex::Regex; let guard = pprof::ProfilerGuard::new(100).unwrap(); // ... workload with many worker threads ... let rename_rules: Vec<(Regex, &str)> = vec![ (Regex::new(r"^worker-\d+$").unwrap(), "worker"), (Regex::new(r"^tokio-runtime-worker$").unwrap(), "tokio-worker"), ]; if let Ok(report) = guard .report() .frames_post_processor(move |frames| { for (re, name) in &rename_rules { if re.is_match(&frames.thread_name) { frames.thread_name = name.to_string(); break; } } }) .build() { // All worker threads now appear under the merged "worker" label println!("{:?}", report); } ``` -------------------------------- ### `ReportBuilder::frames_post_processor` Source: https://context7.com/tikv/pprof-rs/llms.txt Registers a closure that is called on every resolved `Frames` value before the report is finalized. This is useful for grouping threads by name pattern, stripping unwanted frames, or demangling symbols. ```APIDOC ## `ReportBuilder::frames_post_processor` — Mutate frames before report building Registers a closure that is called on every resolved `Frames` value before the report is finalized. This is the primary hook for grouping threads by name pattern, stripping unwanted frames, or demangling symbols from runtimes not handled automatically. ```rust use regex::Regex; let guard = pprof::ProfilerGuard::new(100).unwrap(); // ... workload with many worker threads ... let rename_rules: Vec<(Regex, &str)> = vec![ (Regex::new(r"^worker-\d+$").unwrap(), "worker"), (Regex::new(r"^tokio-runtime-worker$").unwrap(), "tokio-worker"), ]; if let Ok(report) = guard .report() .frames_post_processor(move |frames| { for (re, name) in &rename_rules { if re.is_match(&frames.thread_name) { frames.thread_name = name.to_string(); break; } } }) .build() { // All worker threads now appear under the merged "worker" label println!("{:?}", report); } ``` ``` -------------------------------- ### ReportBuilder::build_unresolved Source: https://context7.com/tikv/pprof-rs/llms.txt Returns the profiler data as an `UnresolvedReport` without performing symbol resolution. This is useful for shipping raw addresses off-process for later symbolication or to avoid allocations during report generation. ```APIDOC ## ReportBuilder::build_unresolved — Produce a raw `UnresolvedReport` Returns the profiler data without performing symbol resolution. Useful when you want to ship raw addresses off-process for later symbolication, or when you need to avoid any allocation during report generation. ```rust let guard = pprof::ProfilerGuard::new(99).unwrap(); // ... workload ... if let Ok(unresolved) = guard.report().build_unresolved() { println!( "Unique stacks (unresolved): {}", unresolved.data.len() ); for (unresolved_frames, count) in &unresolved.data { // unresolved_frames.frames contains raw backtrace::Frame values println!(" count={} thread_id={}", count, unresolved_frames.thread_id); } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.