Skip to content
This repository has been archived by the owner. It is now read-only.
πŸ”₯ Pyflame: A Ptracing Profiler For Python. This project is deprecated and not maintained.
C++ Python M4 Shell Other
Branch: master
Clone or download
Latest commit cf8de7a Dec 2, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github add GH files for contributing, and an issue template Oct 27, 2017
docs Lower the default sample rate, as the old value was way too high Mar 21, 2018
m4 Clean up configure.ac, and be more strict about errors Mar 20, 2018
src
tests Merge pull request #146 from inikolaev/disable-line-numbers-flag May 2, 2018
utils Re-wrote FC Json generator since Chrome updated their required format Oct 29, 2016
.clang-format add pyflame Aug 9, 2016
.gitignore update test suite python invocation for rpm packaging Apr 19, 2018
.travis.yml Clean up configure.ac, and be more strict about errors Mar 20, 2018
LICENSE remove appendix from LICENSE Aug 10, 2016
Makefile.am use the more standard "make check" rather than "make test" Aug 8, 2017
NEWS.org tag 1.6.6 release May 2, 2018
README.md Update README.md Dec 3, 2019
autogen.sh add pyflame Aug 9, 2016
configure.ac tag 1.6.6 release May 2, 2018
runtests.sh fix "make check" when virtualenv is named virtualenv-3 May 2, 2018

README.md

Pyflame: A Ptracing Profiler For Python

Build Status Docs Status COPR Status

(This project is deprecated and not maintained.)

Pyflame is a high performance profiling tool that generates flame graphs for Python. Pyflame is implemented in C++, and uses the Linux ptrace(2) system call to collect profiling information. It can take snapshots of the Python call stack without explicit instrumentation, meaning you can profile a program without modifying its source code. Pyflame is capable of profiling embedded Python interpreters like uWSGI. It fully supports profiling multi-threaded Python programs.

Pyflame usually introduces significantly less overhead than the builtin profile (or cProfile) modules, and emits richer profiling data. The profiling overhead is low enough that you can use it to profile live processes in production.

Full Documentation: https://pyflame.readthedocs.io

pyflame

Quickstart

Building And Installing

For Debian/Ubuntu, install the following:

# Install build dependencies on Debian or Ubuntu.
sudo apt-get install autoconf automake autotools-dev g++ pkg-config python-dev python3-dev libtool make

Once you have the build dependencies installed:

./autogen.sh
./configure
make

The make command will produce an executable at src/pyflame that you can run and use.

Optionally, if you have virtualenv installed, you can test the executable you produced using make check.

Using Pyflame

The full documentation for using Pyflame is here. But here's a quick guide:

# Attach to PID 12345 and profile it for 1 second
pyflame -p 12345

# Attach to PID 768 and profile it for 5 seconds, sampling every 0.01 seconds
pyflame -s 5 -r 0.01 -p 768

# Run py.test against tests/, emitting sample data to prof.txt
pyflame -o prof.txt -t py.test tests/

In all of these cases you will get flame graph data on stdout (or to a file if you used -o). This data is in the format expected by flamegraph.pl, which you can find here.

FAQ

The full FAQ is here.

What's The Deal With (idle) Time?

Full answer here. tl;dr: use the -x flag to suppress (idle) output.

What About These Ptrace Errors?

See here.

How Do I Profile Threaded Applications?

Use the --threads option.

Is There A Way To Just Dump Stack Traces?

Yes, use the -d option.

You can’t perform that action at this time.