2
2
3
3
` pprof ` is a cpu profiler that can be easily integrated into a rust program.
4
4
5
- [ ![ Actions Status] ( https://github.com/tikv /pprof-rs/workflows/build/badge.svg )] ( https://github.com/tikv /pprof-rs/actions )
6
- [ ![ Crates.io] ( https://img.shields.io/crates/v/pprof.svg )] ( https://crates.io/crates/pprof )
7
- [ ![ Dependency Status] ( https://deps.rs/repo/github/tikv /pprof-rs/status.svg )] ( https://deps.rs/repo/github/tikv /pprof-rs )
8
- [ ![ FOSSA Status] ( https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftikv %2Fpprof-rs.svg?type=shield )] ( https://app.fossa.com/projects/git%2Bgithub.com%2Ftikv %2Fpprof-rs?ref=badge_shield )
5
+ [ ![ Actions Status] ( https://github.com/EmbarkStudios /pprof-rs/workflows/build/badge.svg )] ( https://github.com/EmbarkStudios /pprof-rs/actions )
6
+ [ ![ Crates.io] ( https://img.shields.io/crates/v/pprof.svg )] ( https://crates.io/crates/pprof2 )
7
+ [ ![ Dependency Status] ( https://deps.rs/repo/github/EmbarkStudios /pprof-rs/status.svg )] ( https://deps.rs/repo/github/EmbarkStudios /pprof-rs )
8
+ [ ![ FOSSA Status] ( https://app.fossa.com/api/projects/git%2Bgithub.com%2FEmbarkStudios %2Fpprof-rs.svg?type=shield )] ( https://app.fossa.com/projects/git%2Bgithub.com%2FEmbarkStudios %2Fpprof-rs?ref=badge_shield )
9
9
10
10
## Usage
11
11
12
12
First, get a guard to start profiling. Profiling will continue until this guard was dropped.
13
13
14
14
``` rust
15
- let guard = pprof :: ProfilerGuardBuilder :: default (). frequency (1000 ). blocklist (& [" libc" , " libgcc" , " pthread" , " vdso" ]). build (). unwrap ();
15
+ let guard = pprof2 :: ProfilerGuardBuilder :: default (). frequency (1000 ). blocklist (& [" libc" , " libgcc" , " pthread" , " vdso" ]). build (). unwrap ();
16
16
```
17
17
18
18
During the profiling time, you can get a report with the guard.
@@ -26,8 +26,8 @@ if let Ok(report) = guard.report().build() {
26
26
` Debug ` was implemented for ` Report ` . It will print a human-readable stack counter report. Here is an example:
27
27
28
28
```
29
- FRAME: backtrace::backtrace::trace::h3e91a3123a3049a5 -> FRAME: pprof ::profiler::perf_signal_handler::h7b995c4ab2e66493 -> FRAME: Unknown -> FRAME: prime_number::is_prime_number::h70653a2633b88023 -> FRAME: prime_number::main::h47f1058543990c8b -> FRAME: std::rt::lang_start::{{closure}}::h4262e250f8024b06 -> FRAME: std::rt::lang_start_internal::{{closure}}::h812f70926ebbddd0 -> std::panicking::try::do_call::h3210e2ce6a68897b -> FRAME: __rust_maybe_catch_panic -> FRAME: std::panicking::try::h28c2e2ec1c3871ce -> std::panic::catch_unwind::h05e542185e35aabf -> std::rt::lang_start_internal::hd7efcfd33686f472 -> FRAME: main -> FRAME: __libc_start_main -> FRAME: _start -> FRAME: Unknown -> THREAD: prime_number 1217
30
- FRAME: backtrace::backtrace::trace::h3e91a3123a3049a5 -> FRAME: pprof ::profiler::perf_signal_handler::h7b995c4ab2e66493 -> FRAME: Unknown -> FRAME: alloc::alloc::box_free::h82cea48ed688e081 -> FRAME: prime_number::main::h47f1058543990c8b -> FRAME: std::rt::lang_start::{{closure}}::h4262e250f8024b06 -> FRAME: std::rt::lang_start_internal::{{closure}}::h812f70926ebbddd0 -> std::panicking::try::do_call::h3210e2ce6a68897b -> FRAME: __rust_maybe_catch_panic -> FRAME: std::panicking::try::h28c2e2ec1c3871ce -> std::panic::catch_unwind::h05e542185e35aabf -> std::rt::lang_start_internal::hd7efcfd33686f472 -> FRAME: main -> FRAME: __libc_start_main -> FRAME: _start -> FRAME: Unknown -> THREAD: prime_number 1
29
+ FRAME: backtrace::backtrace::trace::h3e91a3123a3049a5 -> FRAME: pprof2 ::profiler::perf_signal_handler::h7b995c4ab2e66493 -> FRAME: Unknown -> FRAME: prime_number::is_prime_number::h70653a2633b88023 -> FRAME: prime_number::main::h47f1058543990c8b -> FRAME: std::rt::lang_start::{{closure}}::h4262e250f8024b06 -> FRAME: std::rt::lang_start_internal::{{closure}}::h812f70926ebbddd0 -> std::panicking::try::do_call::h3210e2ce6a68897b -> FRAME: __rust_maybe_catch_panic -> FRAME: std::panicking::try::h28c2e2ec1c3871ce -> std::panic::catch_unwind::h05e542185e35aabf -> std::rt::lang_start_internal::hd7efcfd33686f472 -> FRAME: main -> FRAME: __libc_start_main -> FRAME: _start -> FRAME: Unknown -> THREAD: prime_number 1217
30
+ FRAME: backtrace::backtrace::trace::h3e91a3123a3049a5 -> FRAME: pprof2 ::profiler::perf_signal_handler::h7b995c4ab2e66493 -> FRAME: Unknown -> FRAME: alloc::alloc::box_free::h82cea48ed688e081 -> FRAME: prime_number::main::h47f1058543990c8b -> FRAME: std::rt::lang_start::{{closure}}::h4262e250f8024b06 -> FRAME: std::rt::lang_start_internal::{{closure}}::h812f70926ebbddd0 -> std::panicking::try::do_call::h3210e2ce6a68897b -> FRAME: __rust_maybe_catch_panic -> FRAME: std::panicking::try::h28c2e2ec1c3871ce -> std::panic::catch_unwind::h05e542185e35aabf -> std::rt::lang_start_internal::hd7efcfd33686f472 -> FRAME: main -> FRAME: __libc_start_main -> FRAME: _start -> FRAME: Unknown -> THREAD: prime_number 1
31
31
FRAME: backtrace::backtrace::trace::h3e91a3123a3049a5 -> FRAME: pprof::profiler::perf_signal_handler::h7b995c4ab2e66493 -> FRAME: Unknown -> FRAME: prime_number::main::h47f1058543990c8b -> FRAME: std::rt::lang_start::{{closure}}::h4262e250f8024b06 -> FRAME: std::rt::lang_start_internal::{{closure}}::h812f70926ebbddd0 -> std::panicking::try::do_call::h3210e2ce6a68897b -> FRAME: __rust_maybe_catch_panic -> FRAME: std::panicking::try::h28c2e2ec1c3871ce -> std::panic::catch_unwind::h05e542185e35aabf -> std::rt::lang_start_internal::hd7efcfd33686f472 -> FRAME: main -> FRAME: __libc_start_main -> FRAME: _start -> FRAME: Unknown -> THREAD: prime_number 1
32
32
```
33
33
@@ -43,7 +43,7 @@ FRAME: backtrace::backtrace::trace::h3e91a3123a3049a5 -> FRAME: pprof::profiler:
43
43
## Flamegraph
44
44
45
45
``` toml
46
- pprof = { version = " 0.13" , features = [" flamegraph" ] }
46
+ pprof2 = { version = " 0.13" , features = [" flamegraph" ] }
47
47
```
48
48
49
49
If ` flamegraph ` feature is enabled, you can generate flamegraph from the report. ` Report ` struct has a method ` flamegraph ` which can generate flamegraph and write it into a ` Write ` .
@@ -60,7 +60,7 @@ Additionally, custom flamegraph options can be specified.
60
60
``` rust
61
61
if let Ok (report ) = guard . report (). build () {
62
62
let file = File :: create (" flamegraph.svg" ). unwrap ();
63
- let mut options = pprof :: flamegraph :: Options :: default ();
63
+ let mut options = pprof2 :: flamegraph :: Options :: default ();
64
64
options . image_width = Some (2500 );
65
65
report . flamegraph_with_options (file , & mut options ). unwrap ();
66
66
};
@@ -77,7 +77,7 @@ Before the report was generated, `frame_post_processor` was provided as an inter
77
77
For example:
78
78
79
79
``` rust
80
- fn frames_post_processor () -> impl Fn (& mut pprof :: Frames ) {
80
+ fn frames_post_processor () -> impl Fn (& mut pprof2 :: Frames ) {
81
81
let thread_rename = [
82
82
(Regex :: new (r " ^grpc-server-\d*$" ). unwrap (), " grpc-server" ),
83
83
(Regex :: new (r " ^cop-high\d*$" ). unwrap (), " cop-high" ),
@@ -151,7 +151,7 @@ Then `pprof` will generate a svg file according to the profile.
151
151
With ` criterion ` feature enabled, a criterion custom profiler is provided in ` pprof-rs ` .
152
152
153
153
``` rust
154
- use pprof :: criterion :: {PProfProfiler , Output };
154
+ use pprof2 :: criterion :: {PProfProfiler , Output };
155
155
156
156
criterion_group! {
157
157
name = benches ;
@@ -218,7 +218,7 @@ Unfortunately, there is no 100% robust stack tracing method. [Some related resea
218
218
This can be resolved by adding a blocklist:
219
219
220
220
``` rust
221
- let guard = pprof :: ProfilerGuardBuilder :: default (). frequency (1000 ). blocklist (& [" libc" , " libgcc" , " pthread" , " vdso" ]). build (). unwrap ();
221
+ let guard = pprof2 :: ProfilerGuardBuilder :: default (). frequency (1000 ). blocklist (& [" libc" , " libgcc" , " pthread" , " vdso" ]). build (). unwrap ();
222
222
```
223
223
224
224
The ` vdso ` should also be added to the blocklist, because in some distribution (e.g. ubuntu 18.04), the dwarf information in vdso is incorrect.
0 commit comments