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

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.14
File Size Uploaded Provenance Actions
trace0-0.1.14.tar.gz 65.7 kB With provenance Details for trace0-0.1.14.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for trace0 0.1.14
File Actions
trace0-0.1.14-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.14-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
trace0-0.1.14-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.14-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
trace0-0.1.14-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for trace0-0.1.14-cp314-cp314t-macosx_11_0_arm64.whl
trace0-0.1.14-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.14-cp314-cp314t-macosx_10_12_x86_64.whl
trace0-0.1.14-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.14-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
trace0-0.1.14-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.14-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
trace0-0.1.14-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for trace0-0.1.14-cp314-cp314-macosx_11_0_arm64.whl
trace0-0.1.14-cp314-cp314-macosx_10_12_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.12+ x86-64 Details for trace0-0.1.14-cp314-cp314-macosx_10_12_x86_64.whl
trace0-0.1.14-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.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
trace0-0.1.14-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.14-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
trace0-0.1.14-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for trace0-0.1.14-cp313-cp313-macosx_11_0_arm64.whl
trace0-0.1.14-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details for trace0-0.1.14-cp313-cp313-macosx_10_12_x86_64.whl

Total release size: 8.8 MB

Release files / trace0-0.1.14.tar.gz

Download URL trace0-0.1.14.tar.gz
Size 65.7 kB
Tags Source
SHA-256 checksum
How to use checksums
81f5efc2e96f8d09ef01a432d30820789c76afb9eb9f989097c098c8cf9eeb34
BLAKE2b-256 checksum
How to use checksums
41307992f01a19dd1b6a6b22c560681dd30c073611bd52dd6630d8f0fad28b14
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 log

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

Download URL trace0-0.1.14-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 768.9 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
aa1e198e780b418614c885da3996be8b412ef9ac445b866e0d4f289f3eee51fd
BLAKE2b-256 checksum
How to use checksums
50b309030a694a574eda52954e985e846ea4ae26e9c22ed26529f4b336bec236
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 log

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

Download URL trace0-0.1.14-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 751.2 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
089385214c830632f0ff11a5fc23dbd97aa6f1a59671924f4dd770c400f3bc99
BLAKE2b-256 checksum
How to use checksums
8a061c8899ee7c125622346c322d5c420b3107f3a9042ed0806a9d8b47fbf574
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 log

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

Download URL trace0-0.1.14-cp314-cp314t-macosx_11_0_arm64.whl
Size 689.3 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f8df12774104fee996fdef8a474bd0764cac873bb1a96b63b4280337bf4c9aed
BLAKE2b-256 checksum
How to use checksums
5afa3438efaddeefb80154d097832de7491a952847340cd218dde5194cb58395
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 log

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

Download URL trace0-0.1.14-cp314-cp314t-macosx_10_12_x86_64.whl
Size 711.4 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
17479b310e957339ccf212fb0e146a3057039160b86c6f11e530472340308ea0
BLAKE2b-256 checksum
How to use checksums
0c35dfbaa3142ccacc32b29b89c55b313a241b904b4253f3427025a7179e26a6
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 log

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

Download URL trace0-0.1.14-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 767.5 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bd56a361bd4dfcd23c34d0f9f4545391b7961cb034ff462b0987370c52b88def
BLAKE2b-256 checksum
How to use checksums
5f71d05975ada4f2bcbbd7ef55d7610856735196d6b345293b8d4f24c2a6d172
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 log

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

Download URL trace0-0.1.14-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 751.6 kB
Tags CPython 3.14 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
03d76d2ca4d4877019783f5e74fe2b081d307d25fd68bd9742427bfb51fe857a
BLAKE2b-256 checksum
How to use checksums
70d3a5e9ccc69e26035fb9e0a9d3b2c152e0b83597ab1e631f51788b611b96c7
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 log

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

Download URL trace0-0.1.14-cp314-cp314-macosx_11_0_arm64.whl
Size 690.3 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2a55c973abe2a2e570fd6b2b86734125057cf8c1ddbab2b634b151be68c2c1d4
BLAKE2b-256 checksum
How to use checksums
950b02daa59aa30943a855f855e332cf00a8a86ecb82109ad199f7d5654dd825
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 log

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

Download URL trace0-0.1.14-cp314-cp314-macosx_10_12_x86_64.whl
Size 711.6 kB
Tags CPython 3.14 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b688dcb26eb037315894c57923d6cc308e8756154b906f3f419ba86bc73e0beb
BLAKE2b-256 checksum
How to use checksums
a8f726c276080e59d930256d9397cd8e3418a706b0773f5867d709937d5746ce
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 log

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

Download URL trace0-0.1.14-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 767.1 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2ccb042074c8d1fff627cb741b569e1d5651abc748bba48d7fddc431bda649a1
BLAKE2b-256 checksum
How to use checksums
f3fff31c57f1b071f11cf71fae9f4751992e9b932e21c61b70f3799286791b3b
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 log

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

Download URL trace0-0.1.14-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 752.0 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
e765a6a7ad29bbbfd8e89dd31211495fdf33a558f964991159a21fff504648c0
BLAKE2b-256 checksum
How to use checksums
cf1d7129747ec688c65d744dc482752855d138ece566642d2071f064f0696ec7
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 log

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

Download URL trace0-0.1.14-cp313-cp313-macosx_11_0_arm64.whl
Size 689.3 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fee0e11bf74bf66cf6b714b0555afcbee91d60fb390daee8710a76699ec71839
BLAKE2b-256 checksum
How to use checksums
a186d8a4940bdc40fa92b49bdfda5a6fbac9438ac4d9c1d3992edfb5e55ea13b
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 log

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

Download URL trace0-0.1.14-cp313-cp313-macosx_10_12_x86_64.whl
Size 707.9 kB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f9f66d483517dd74d1df28ce98d31642094e3bb9814d3437326e8410dea69fa3
BLAKE2b-256 checksum
How to use checksums
f2f2e29e4f8bf288f7cb400c43eb0a71b15f18938e9232524dc93a798bebf0bb
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 log

Security for trace0 0.1.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.

Full provenance

All 13 files in this release have been uploaded with provenance metadata.

Select from 13 files

Attestation for trace0-0.1.14.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 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