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

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.16
File Size Uploaded Provenance Actions
trace0-0.1.16.tar.gz 66.4 kB With provenance Details for trace0-0.1.16.tar.gz

Built distributions (wheels)

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

Total release size: 8.6 MB

Release files / trace0-0.1.16.tar.gz

Download URL trace0-0.1.16.tar.gz
Size 66.4 kB
Tags Source
SHA-256 checksum
How to use checksums
afe83baf38339b8d2fcfc5c7db0af84a2c4a1a163ec285a78dcc88ff4532d432
BLAKE2b-256 checksum
How to use checksums
69c325c918fb03dda691ad127f6a18b975b5cad67ce5ad31cb7c1984609239b5
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.16-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL trace0-0.1.16-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 752.7 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
58cbbc3624fa183fd8e756de0812a28fd15a6132c365b390e8912ff2bcf8a119
BLAKE2b-256 checksum
How to use checksums
e423665904c6563d1bea2c6d3cd6d0111428578ce3effe8469cbf006f019171b
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.16-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL trace0-0.1.16-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 734.9 kB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
6fd899b384940f6c4b7f12cc96223c6f5a3fb13e3f7434024161063e4e3b5b81
BLAKE2b-256 checksum
How to use checksums
91708ceb145facf558c8c9317db569dd34bfa24ff909b366bd71f9bc7c2fdc3f
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.16-cp314-cp314t-macosx_11_0_arm64.whl

Download URL trace0-0.1.16-cp314-cp314t-macosx_11_0_arm64.whl
Size 674.0 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b65af4c15a5d2fb275b895cd22baacd4bc6c7af9d75512b4a505f8ef4ff88cbd
BLAKE2b-256 checksum
How to use checksums
69b1b60884a2968f7a7017cb028b7c7b82ddc3ce2053eaa0ff7f1da58360e989
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.16-cp314-cp314t-macosx_10_12_x86_64.whl

Download URL trace0-0.1.16-cp314-cp314t-macosx_10_12_x86_64.whl
Size 693.5 kB
Tags CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b21de129c0c0d19b518ed830079faa99c956d17ae4a6f1f0111af32dd9583abc
BLAKE2b-256 checksum
How to use checksums
411ec4a058e45450dadd99bc1e7347987aed1c32bfe40343d092a40d6208d52b
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.16-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL trace0-0.1.16-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 750.5 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e6963115f1882d911d835628b014afa8ca57b0c422d31346a8cf0253d9d3fff4
BLAKE2b-256 checksum
How to use checksums
3068c965b606721a7767b79055277b3b998cd1026337535346a3d57816deb866
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.16-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL trace0-0.1.16-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 737.3 kB
Tags CPython 3.14 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
adde6929c48f0cb26b9424d549f0f0ebfe552d41abf2fb6e04d78bc0bf7166cb
BLAKE2b-256 checksum
How to use checksums
9b24498a41361b407c0ad3ffa041e21d1eccb9b46c6412b234845a0df3c7fbc1
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.16-cp314-cp314-macosx_11_0_arm64.whl

Download URL trace0-0.1.16-cp314-cp314-macosx_11_0_arm64.whl
Size 676.5 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ff928ef40be6a0f4c3a4157b41da66defa0468dc2c2718503f889dddc249cb49
BLAKE2b-256 checksum
How to use checksums
350c8f61c69ccc249b96d6566e7af0608beef9ed655b8b7dc1ab2622e13725b5
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.16-cp314-cp314-macosx_10_12_x86_64.whl

Download URL trace0-0.1.16-cp314-cp314-macosx_10_12_x86_64.whl
Size 694.5 kB
Tags CPython 3.14 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
168be46b6d764ad61c077cb200723cdfd97bfddf784def6dcba87bc44f2f35f7
BLAKE2b-256 checksum
How to use checksums
b8c3e924842d7ac15a00f00d6c4910dbe648f8861dc28a1711554758d870b8e1
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.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL trace0-0.1.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 749.8 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
349172be51309e646712de98855b1819a870ae027c932f3976be9e366934ea85
BLAKE2b-256 checksum
How to use checksums
feaa678c3661e1d77e538e3f61a7e80db6b064ebd22517f6c5adad91a3bf8e7a
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.16-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL trace0-0.1.16-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 736.9 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
416d063d4575458bb4ebe3bc07be722005c24edfb4838d66e55f9e7452278ff3
BLAKE2b-256 checksum
How to use checksums
23d06fe014f55462137118e9f2f3f62e89b138fd7097a7ee1d41f19fd61ae574
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.16-cp313-cp313-macosx_11_0_arm64.whl

Download URL trace0-0.1.16-cp313-cp313-macosx_11_0_arm64.whl
Size 673.8 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f80b47780720af8a0e4b6266c78928181c5dca05480ea3b7fc3423881bc4939a
BLAKE2b-256 checksum
How to use checksums
e6853cf574ff1b06beb90b0eed560b97bafbb8bd71b900427aeb4cedf7a0deae
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.16-cp313-cp313-macosx_10_12_x86_64.whl

Download URL trace0-0.1.16-cp313-cp313-macosx_10_12_x86_64.whl
Size 693.8 kB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1d04b5f297a3041d82f3614c2d267572b37e9db6891bf4d4e1d0bc4c0edf97e4
BLAKE2b-256 checksum
How to use checksums
9dcb42b3f13bc9bffdf6cf935757d7969d942b5d9fe6abc28511cc4300aa3a65
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.16

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