Skip to main content

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.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trace0 0.1.15
File Size Uploaded Provenance Actions
trace0-0.1.15.tar.gz 66.4 kB With provenance Details for trace0-0.1.15.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for trace0 0.1.15
File Actions
trace0-0.1.15-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Details for trace0-0.1.15-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
trace0-0.1.15-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 Details for trace0-0.1.15-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
trace0-0.1.15-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for trace0-0.1.15-cp314-cp314t-macosx_11_0_arm64.whl
trace0-0.1.15-cp314-cp314t-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 Details for trace0-0.1.15-cp314-cp314t-macosx_10_12_x86_64.whl
trace0-0.1.15-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details for trace0-0.1.15-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
trace0-0.1.15-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ ARM64 Details for trace0-0.1.15-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
trace0-0.1.15-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for trace0-0.1.15-cp314-cp314-macosx_11_0_arm64.whl
trace0-0.1.15-cp314-cp314-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.12+ x86-64 Details for trace0-0.1.15-cp314-cp314-macosx_10_12_x86_64.whl
trace0-0.1.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details for trace0-0.1.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
trace0-0.1.15-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details for trace0-0.1.15-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
trace0-0.1.15-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for trace0-0.1.15-cp313-cp313-macosx_11_0_arm64.whl
trace0-0.1.15-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details for trace0-0.1.15-cp313-cp313-macosx_10_12_x86_64.whl

Total release size: 8.7 MB

Release files / trace0-0.1.15.tar.gz

Download URL trace0-0.1.15.tar.gz
Size 66.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4f98a492665f57aea57a34d8b9349f4a528c5ce20c7862cc39204306d2b6998c
BLAKE2b-256 checksum
How to use checksums
acd29b978422c3bc905ba31e3f2f1c75de950165802c46a3e6442ef2f2dcf44c
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL trace0-0.1.15-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 755.2 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2bda843ee913fcddfc52f46cf2e6d51916a912177a466e1c16ef1db1208d4daf
BLAKE2b-256 checksum
How to use checksums
7e9a7f6647ed153dc6e6466eee513f23a9c3192b386db43cdf24700257879335
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL trace0-0.1.15-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 739.0 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
c4f4bb24a7a571033319743e6eab0366a20a2acef8214113c6b0f2a1634a8467
BLAKE2b-256 checksum
How to use checksums
16a4a5928ba2e0daccc1d501ac4b031580bc2f0e771b809b799dfc4ce4e42c22
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp314-cp314t-macosx_11_0_arm64.whl

Download URL trace0-0.1.15-cp314-cp314t-macosx_11_0_arm64.whl
Size 677.8 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d22b84ba88653dc477b6a2c460d4ce502ea35136366ec2a0368d692e294b8094
BLAKE2b-256 checksum
How to use checksums
d21a2c2f2dac3475eba87f7dbaf5c01fab6e06e6a3c3a22792641d5689bc386a
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp314-cp314t-macosx_10_12_x86_64.whl

Download URL trace0-0.1.15-cp314-cp314t-macosx_10_12_x86_64.whl
Size 696.7 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
21aeeca8a6df3c10488146c8f011297f96a5120647322073838634494edb5fd6
BLAKE2b-256 checksum
How to use checksums
60a9a39a6cc5e29ffe3a9e8ebeab917a586ac09be09e4941bea960a3eba02db6
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL trace0-0.1.15-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 753.6 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b9bdf97b19a2311ff3058e132c1b5db2fa9dc6cbb0e3d75b7a0896bc88ae6335
BLAKE2b-256 checksum
How to use checksums
44c3c2d0ec34ff004bfe8521568dd51abe0599256ac8ad2fc88a4b2de5215913
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL trace0-0.1.15-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 739.3 kB
Tags CPython 3.14 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
21dfa91add7169baab28a9ad566a3ae5f020f28fcb1a13aee913b61895cf5843
BLAKE2b-256 checksum
How to use checksums
467e0018aa9fec61efb4b89347a99743f0d1755d69ab1dbded703c7598221da8
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp314-cp314-macosx_11_0_arm64.whl

Download URL trace0-0.1.15-cp314-cp314-macosx_11_0_arm64.whl
Size 679.2 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
aafaf2f28ee0f554b71959181b388151e6b7d904d2b9f43bc12029d9e4bbbbda
BLAKE2b-256 checksum
How to use checksums
91c8c2a0e1cb0a5f9d76c5e965e875bf1fd475716a723c3fe926b7f73ce208d6
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp314-cp314-macosx_10_12_x86_64.whl

Download URL trace0-0.1.15-cp314-cp314-macosx_10_12_x86_64.whl
Size 696.5 kB
Tags CPython 3.14 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
fb4761596976a8e46fdf12c6d6bb362cf028bb19dfc386522ddb7eec3706e3ab
BLAKE2b-256 checksum
How to use checksums
d3cd1e703d5e793298d28ad6608c74b3dfae1458b358458ad4d89a5bca9abb4e
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL trace0-0.1.15-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 752.9 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bdb45de17c967454b2a29d9435944cef3440651a072074bea6d8e76c0837f609
BLAKE2b-256 checksum
How to use checksums
18a73e0d0df2bd20777b5004f25218172aa78f75a13f8da14b6826437ed4b3b1
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL trace0-0.1.15-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 737.9 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
4ba09dc2a9afc95fc002a431e2b178b3f576051df1b15cd5f965dc5f8b7bad2f
BLAKE2b-256 checksum
How to use checksums
a5a6f89814a1591c59716bf7dee7fb2b67551ef9526da2a588c78df6d4cc1ee9
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp313-cp313-macosx_11_0_arm64.whl

Download URL trace0-0.1.15-cp313-cp313-macosx_11_0_arm64.whl
Size 677.1 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f41bf016b1b442fa43eb78d361b969e2bad34e9edac797273b7c595dd9e01d5b
BLAKE2b-256 checksum
How to use checksums
095b553c7d87ea4bb34ef8aa1fe7d5339982f2b39d5b93f356b11776c53be3ed
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 9, 2026.

Transparency log

Release files / trace0-0.1.15-cp313-cp313-macosx_10_12_x86_64.whl

Download URL trace0-0.1.15-cp313-cp313-macosx_10_12_x86_64.whl
Size 693.7 kB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
80581a855fca3a56d2718f5dc8a39c51184fcb4b79c8729379e7d6823e6d15eb
BLAKE2b-256 checksum
How to use checksums
2aaf948ccd788fa7df34d7c4460e08dd71de9849429e273656198efaef1c145a
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 9, 2026.

Transparency log

Security for trace0 0.1.15

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.

Select from 13 files

Attestation for trace0-0.1.15.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 9, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page