#profiler #pprof

pyroscope

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

13 releases

0.5.8 Dec 3, 2024
0.5.7 Aug 4, 2023
0.5.6 May 19, 2023
0.5.3 Jun 27, 2022
0.1.0 Dec 17, 2021

#26 in Profiling

Download history 47207/week @ 2024-08-22 46824/week @ 2024-08-29 50494/week @ 2024-09-05 44580/week @ 2024-09-12 47169/week @ 2024-09-19 52497/week @ 2024-09-26 49617/week @ 2024-10-03 52797/week @ 2024-10-10 51853/week @ 2024-10-17 49353/week @ 2024-10-24 49931/week @ 2024-10-31 42027/week @ 2024-11-07 80220/week @ 2024-11-14 44636/week @ 2024-11-21 47237/week @ 2024-11-28 42285/week @ 2024-12-05

224,114 downloads per month
Used in 9 crates (8 directly)

Apache-2.0

140KB
3K SLoC

Rust 2.5K SLoC // 0.1% comments Python 257 SLoC // 0.0% comments Ruby 210 SLoC // 0.0% comments Forge Config 32 SLoC Shell 7 SLoC // 0.4% comments Bazel 3 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.4"
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 sends 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 orchestrate 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 separately. The currently available backends are:

Native Integration

Pyroscope can be used directly in your projects with native integration. No agents or external programs are required.

Limitations

  • Backend: The Pyroscope Agent uses pprof-rs as a backend. As a result, the limitations for pprof-rs also applies.
  • Tagging: 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.

Major Contributors

We'd like to give a big thank you to the following contributors who have made significant contributions to this project:

License

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

See LICENSE for details.

Dependencies

~6–17MB
~230K SLoC