Expand description
pprof-rs is an integrated profiler for rust program.
This crate provides a programable interface to start/stop/report a profiler dynamically. With the help of this crate, you can easily integrate a profiler into your rust program in a modern, convenient way.
A sample usage is:
let guard = pprof2::ProfilerGuard::new(100).unwrap();Then you can read report from the guard:
if let Ok(report) = guard.report().build() {
println!("report: {:?}", &report);
};More configuration can be passed through ProfilerGuardBuilder:
let guard = pprof2::ProfilerGuardBuilder::default().frequency(1000).blocklist(&["libc", "libgcc", "pthread", "vdso"]).build().unwrap();The frequency means the sampler frequency, and the blocklist means the
profiler will ignore the sample whose first frame is from library containing
these strings.
Skipping libc, libgcc and libpthread could be a solution to the
possible deadlock inside the _Unwind_Backtrace, and keep the signal
safety. The dwarf information in “vdso” is incorrect in some distributions,
so it’s also suggested to skip it.
You can find more details in README.md
Modules§
- criterion
- flamegraph
- Tools for producing flame graphs from folded stack traces.
- protos
Structs§
- Collector
- Frames
- A representation of a backtrace.
thread_nameandthread_idwas got frompthread_getname_npandpthread_self. frames is a vector of symbols. - Hash
Counter - Profiler
Guard - RAII structure used to stop profiling when dropped. It is the only interface to access profiler.
- Profiler
Guard Builder - Report
- The final presentation of a report which is actually an
HashMapfromFramesto isize (count). - Report
Builder - A builder of
ReportandUnresolvedReport. It builds report from a runningProfiler. - Symbol
- Symbol is a representation of a function symbol. It contains name and addr of it. If built with debug message, it can also provide line number and filename. The name in it is not demangled.
- Unresolved
Report - The presentation of an unsymbolicated report which is actually an
HashMapfromUnresolvedFramesto isize (count).
Enums§
Constants§
- MAX_
DEPTH - Define the MAX supported stack depth. TODO: make this variable mutable.
- MAX_
THREAD_ NAME - Define the MAX supported thread name length. TODO: make this variable mutable.