trace0
A low-overhead tracing profiler for Python, written in Rust.
trace0 hooks PEP 669 sys.monitoring,
packs each event into 8 bytes in a thread-local buffer, and hands whole batches
to a background thread over lock-free SPSC rings. It emits
Perfetto-compatible traces — open them at
https://ui.perfetto.dev.
How much does it cost?
Across 14 benchmarks from pyperformance, the suite CPython itself is judged on, run unmodified on an M4 Mac:
Median slowdown 1.19×, ranging 1.00× to 1.48×.
| slowdown | ||
|---|---|---|
telco, fannkuch, nbody, scimark |
1.00–1.04× | arithmetic in tight loops |
json_dumps, pyflate, chaos, float, go, spectral_norm |
1.12–1.25× | |
raytrace, hexiom, deltablue, richards |
1.36–1.48× | call-heavy |
The spread is the story: a tracer charges per call, so what a program
pays depends entirely on how many calls it makes per unit of work, not on
how long it runs. Reproduce with scripts/benchmark.py suite.
Against the alternatives, on a call-dense workload — transpiling SQL with
sqlglot, 10.8M events per second of
work. Reproduce with scripts/benchmark.py alternatives:
| wall time | vs vanilla | |
|---|---|---|
| vanilla | 0.97 s | — |
| trace0 (protobuf) | 1.16 s | 1.20× |
| trace0 (json) | 1.35 s | 1.40× |
cProfile |
2.36 s | 2.45× |
profile |
19.11 s | 19.8× |
trace0 adds about a seventh of cProfile's overhead and keeps every event,
where cProfile only keeps per-function aggregates. That protobuf trace was
197 MB — a full timeline is not free, it is just cheaper in time than in disk.
The same run as JSON is an order of magnitude larger.
For the callback in isolation, scripts/benchmark.py overhead reports the
difference against the same workload untraced: ~4 ns per event at 8
threads, ~13 ns on a single thread. An event is one PY_START or
PY_RETURN, so a function call is two.
Try it
No install — uvx fetches the wheel, traces your script, and leaves nothing
behind:
uvx trace0 run --output trace.pb your_script.py
Drop trace.pb onto https://ui.perfetto.dev and you have a flame chart.
The traced script runs inside the tracer's environment, so name what it
imports with --with, and the interpreter with --python:
uvx --with httpx --python 3.14t trace0 run --output trace.pb your_script.py
Free-threaded builds (3.14t) are a first-class target — every thread is traced, not just the calling one.
-m runs a library module, exactly as python -m does; everything after the
module name belongs to it:
uvx --with uvicorn trace0 run --output trace.pb -m uvicorn app:app --port 8000
A server traced from launch spends most of its trace importing. To trace only
the part you care about, wrap it with the Tracer API below instead.
Install
Install it for the Tracer API, which also puts the same CLI on your
project's path. Requires Python 3.13+.
uv add trace0
from trace0 import Tracer
with Tracer("trace.pb"):
your_workload()
Output is Perfetto protobuf by default. --format json, or
Tracer(..., format="json"), writes Chrome Trace Event instead — larger and
slower to write, but human-readable and diffable.
Child processes
Children are traced too, whether they arrive by fork or by exec, so
multiprocessing, subprocess and worker-based servers all show up. They
write into the same file as they run, so there is nothing to merge afterwards:
trace0 run --output trace.pb -m uvicorn app:app --workers 4
leaves one trace.pb holding every worker, on a track of its own. Each process
buffers whole packets and commits them under a lock, so two processes writing
at once never splice into each other, and each namespaces its packet sequences
by pid so Perfetto keeps them apart.
JSON traces use the Chrome JSON Array Format for the same reason — entries follow one another with a trailing comma and no closing bracket. That is what lets several processes append to one array, and it means a process killed mid-run still leaves everything up to its last whole entry.
To trace only the process you launched, pass --no-trace-subprocesses, or
Tracer(..., trace_subprocesses=False).
Being stopped
A run ended by SIGTERM, SIGHUP or SIGQUIT still writes what it recorded.
The default action for those is to end the process outright — nothing unwinds
and no atexit runs — so trace0 takes them over while tracing, finishes the
run, then lets the signal do what it was going to do, exit status and all.
Signals the program handles itself are left alone: if it installs its own
handler, that handler runs and tracing continues. SIGINT is untouched,
because Python already turns it into an exception that unwinds. SIGKILL
cannot be caught, so a run ended that way still loses whatever the exporter
had not yet drained.
Status
Early. The tracer works end to end and is covered by tests, but the API is not yet stable and wheels are not yet built for every platform.
Developing
The benchmarks behind every number above live in one script:
uv run scripts/benchmark.py --help
prek runs the CI checks before a commit lands — formatting and clippy on
commit, both test suites on push:
uv tool install prek && prek install --hook-type pre-commit --hook-type pre-push
Layout
Rust lives under crates/, Python under python/.
| crate | role |
|---|---|
trace0-core |
clock, event model, event queue, exporter contract |
trace0-json |
Chrome Trace Event output |
trace0-proto |
Perfetto protobuf output |
trace0-py |
the sys.monitoring callbacks and the _core extension |
Only trace0-py links against CPython, and it is the one crate with no
tests: a cdylib built with extension-module leaves the interpreter's
symbols undefined, so it cannot link outside maturin. Everything worth
testing lives in the other three, which cargo test runs directly.
License
MIT
Metadata
Release files for trace0 0.1.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| trace0-0.1.13.tar.gz | 65.3 kB | With provenance | Details for trace0-0.1.13.tar.gz |
Built distributions (wheels)
Total release size: 8.8 MB
Release files / trace0-0.1.13.tar.gz
| Download URL | trace0-0.1.13.tar.gz |
|---|---|
| Size | 65.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
220d6e4e9467c477b816ed6c46f64246d14c1bfa85e450e8596a5db05a50bb14
|
|
BLAKE2b-256 checksum How to use checksums |
51b48b338a1e2a54d0fe929479804eb27a9f779f945c6d3cd851c1ffcce76609
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | trace0-0.1.13-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 767.8 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a7d636f935dc69caae59017112db7c99eaec3bfd0f65478c1350105dc7164e38
|
|
BLAKE2b-256 checksum How to use checksums |
4fe4ab44b176d048a25d5d598a1016e4b1cfc28094c58d9cc476e7912b190692
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | trace0-0.1.13-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 750.6 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
11d21f40fa4e0844666b46101588d5219a6ca0bf0b57df51859c9015ebfa374d
|
|
BLAKE2b-256 checksum How to use checksums |
9f0066d134a45bb137b88fa2f6cdd6cd963e69b14c4bf20d47570f198831ecab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | trace0-0.1.13-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 688.6 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
08262bc965d6c008c84cf0080da2da043550507bad2a433e99be28777a6acf3b
|
|
BLAKE2b-256 checksum How to use checksums |
be4c56c04f006440703b8bf6b0858c8ff7e10f7ac6983dc7a370d1e781ab62d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp314-cp314t-macosx_10_12_x86_64.whl
| Download URL | trace0-0.1.13-cp314-cp314t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 710.2 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
10549fa7d26cff7d65606fae7e66f38ef843e0c77d97dcb2b1933849cd1dd85b
|
|
BLAKE2b-256 checksum How to use checksums |
fc1e8e9aa85ca5f3f6147eba375305583c2664161e578a472715fbebdaa58cb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | trace0-0.1.13-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 766.3 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
16157feb6167953f0934fcb4cc76630af65ebcf48315683f58b0e0bf24c53f10
|
|
BLAKE2b-256 checksum How to use checksums |
b0c79372a891e51b68e51b939083b5a330da6971c02390506296bebcdceced6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | trace0-0.1.13-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 750.9 kB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
82054dc915735cb913475cd6472342feee9a108319d2577d51c90ad85894c595
|
|
BLAKE2b-256 checksum How to use checksums |
f6cbbc3e839048f9ddbe103507009e607a77428cf7ded975631649adb1b871ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | trace0-0.1.13-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 689.9 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5a2a52df25a2a81592819ae70cb7f239176ab539f0224f36497dbb3141420a06
|
|
BLAKE2b-256 checksum How to use checksums |
c77941d4c297e6e9233f1be7c4ca0d5a6890a74f1d5c4277c90ba9edf27fc604
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp314-cp314-macosx_10_12_x86_64.whl
| Download URL | trace0-0.1.13-cp314-cp314-macosx_10_12_x86_64.whl |
|---|---|
| Size | 710.7 kB |
| Tags | CPython 3.14 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
876be321965176b38347517a32530f11866dcd863c9e08e4cf3409a65fbdcd01
|
|
BLAKE2b-256 checksum How to use checksums |
9f9180b2c28313760fb6731134befbf49144c92c491810d2955952c594689f81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | trace0-0.1.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 766.0 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
22f933ecb68ee382b23889d0fefa240f81604bf8a633d77c4a1c7200e8dbd50c
|
|
BLAKE2b-256 checksum How to use checksums |
e8729ab9fc3420c4bc234f24774a80c6b6c3803bb95f6c2f6f28973abcd3d2fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | trace0-0.1.13-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 751.0 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
12cd1e7234977fc185b1a8691b22fd39ca3d2339b233a119a8447bdfb3be5d0e
|
|
BLAKE2b-256 checksum How to use checksums |
4e55f40a06305f62f2a8364bb272c08e2d4b4129d9b8eae01b55b529bef59db1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | trace0-0.1.13-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 688.0 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b139618e40107ee1c343e3be19628454782fb24c87bb7d11a924278a3ebc0083
|
|
BLAKE2b-256 checksum How to use checksums |
7363dd137b5a9c2e0cf5835302598e2162da2a454034ab08756a1200106ef1b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / trace0-0.1.13-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | trace0-0.1.13-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 707.0 kB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b1857590be3f538e04e271fe27650c280fd3ba92ca7b949ecf5bf94931394096
|
|
BLAKE2b-256 checksum How to use checksums |
f4f9af8b1f0d262aab4c0857a4adcbb606d5511927692b79190331de9892a9a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logSecurity for trace0 0.1.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 13 files in this release have been uploaded with provenance metadata.
Attestation for trace0-0.1.13.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.