#pyroscope #profiler #profiling #pprof

pyroscope

Pyroscope Profiler Agent for continuous profiling of Rust, Python and Ruby applications

7 releases (4 breaking)

Uses new Rust 2021

0.5.1 May 1, 2022
0.5.0 Apr 28, 2022
0.4.0 Mar 30, 2022
0.3.1 Feb 14, 2022
0.0.1-alpha Dec 23, 2021

#9 in Profiling

Download history 19/week @ 2022-01-27 76/week @ 2022-02-03 44/week @ 2022-02-10 281/week @ 2022-02-17 1146/week @ 2022-02-24 1647/week @ 2022-03-03 2337/week @ 2022-03-10 2043/week @ 2022-03-17 1430/week @ 2022-03-24 1443/week @ 2022-03-31 1705/week @ 2022-04-07 1607/week @ 2022-04-14 1856/week @ 2022-04-21 1700/week @ 2022-04-28 1979/week @ 2022-05-05 1882/week @ 2022-05-12

7,794 downloads per month
Used in 4 crates

Apache-2.0

86KB
2K SLoC

Pyroscope Profiler

Pyroscope Profiler for Rust. Profile your Rust applications.

license tests build Crate


You may be looking for:

Table of Contents

Quick Start

Add this to your Cargo.toml:

[dependencies]
pyroscope = "0.5.0"
pyroscope-pprofrs = "0.2"

Include Pyroscope and pprof-rs dependencies:

use pyroscope::PyroscopeAgent;
use pyroscope_pprofrs::{pprof_backend, PprofConfig};

Configure the Pyroscope agent:

 let agent =
     PyroscopeAgent::builder("http://localhost:4040", "myapp-profile")
     .backend(pprof_backend(PprofConfig::new().sample_rate(100)))
     .build()?;

Profile your code:

 let agent_running = agent.start()?;

 // Computation to profile 

 let agent_ready = agent_running.stop()?;
 agent_ready.shutdown();

Pyroscope Server

The Pyroscope Agent send the profiling data to a Pyroscope Server. You need to have a Pyroscope Server running in order to consume and visualize this data. It's not possible, currently, to forward the data to another endpoint.

Multi-Threading

The Pyroscope Agent and the pprof-rs backend can profile and report data from a multi-threaded program. pprof-rs, however, does not track child-processes and thus profiling is limited to a single process.

Profiling Backends

The Pyroscope Agent doesn't do any profiling. The agent role is to orchasrate a profiling backend, and report the profiling data to the Pyroscope Server. The Agent can support external backends (in fact, all current backends are independent crates) and you can make your own. Backends can also be used seperately. The currently available backends are:

Limitations

  • Backend: The Pyroscope Agent uses pprof-rs as a backend. As a result, the limitations for pprof-rs also applies.
  • Tagging: Adding or removing tags is not possible within threads. In general, the Pyroscope Agent is not Sync; and as a result a reference cannot be shared between threads. A multi-threaded program could be profiled but the agent is not thread-aware and a particular thread cannot be tagged. As of 0.5.0, the Pyroscope Agent support tagging within threads. Check the Tags and Multi-Thread examples for usage.
  • Timer: epoll (for Linux) and kqueue (for macOS) are required for a more precise timer.
  • Shutdown: The Pyroscope Agent might take some time (usually less than 10 seconds) to shutdown properly and drop its threads. For a proper shutdown, it's recommended that you run the shutdown function before dropping the Agent.

Getting help

You can read the Docs or check the examples for detailed usage of the library. You can also join the Slack channel if you have questions.

License

Pyroscope is distributed under the Apache License (Version 2.0).

See LICENSE for details.

Dependencies

~3–12MB
~237K SLoC