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/bench_pyperformance.py.

Against the alternatives, on a call-dense workload — transpiling SQL with sqlglot, 10.8M events per second of work. Reproduce with scripts/bench_alternatives.py:

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 210 MB — a full timeline is not free, it is just cheaper in time than in disk. The same run as JSON is 3 GB.

For the callback in isolation, scripts/bench_producer.py 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.13t trace0 run --output trace.pb your_script.py

Free-threaded builds (3.13t, 3.14t) are a first-class target — every thread is traced, not just the calling one.

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.

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.

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trace0-0.1.7.tar.gz (37.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

trace0-0.1.7-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (630.0 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

trace0-0.1.7-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (617.4 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

trace0-0.1.7-cp314-cp314t-macosx_11_0_arm64.whl (563.9 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

trace0-0.1.7-cp314-cp314t-macosx_10_12_x86_64.whl (577.6 kB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

trace0-0.1.7-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (632.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

trace0-0.1.7-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (617.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

trace0-0.1.7-cp314-cp314-macosx_11_0_arm64.whl (564.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

trace0-0.1.7-cp314-cp314-macosx_10_12_x86_64.whl (576.3 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

trace0-0.1.7-cp313-cp313t-macosx_11_0_arm64.whl (564.6 kB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

trace0-0.1.7-cp313-cp313t-macosx_10_12_x86_64.whl (577.0 kB view details)

Uploaded CPython 3.13tmacOS 10.12+ x86-64

trace0-0.1.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

trace0-0.1.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (618.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

trace0-0.1.7-cp313-cp313-macosx_11_0_arm64.whl (566.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trace0-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl (576.9 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

Details for the file trace0-0.1.7.tar.gz.

File metadata

  • Download URL: trace0-0.1.7.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for trace0-0.1.7.tar.gz
Algorithm Hash digest
SHA256 363bf4797268bba928b8c1178afe1bd92dd23940b13db07f193a5e179b86adf5
MD5 4969954b76b08a9034a13050fff17c61
BLAKE2b-256 89d6cee2956b1996ffb109bc01a24d8aaa47596656b236b567626a67eee47839

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7.tar.gz:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e2e36523f64971e8f14e9840f2d3ad18c753b57f4d798852249679412aea2e0b
MD5 5c88ee722349d0cce2eb4c652f82b39a
BLAKE2b-256 c13b6c6559e221c5ec52e5fdb14ab8590781722e9340e4a3ab869516544e7c87

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cf1d4f4b78d71b1467f45f2cdb444b3644f94eb29fdb849e0a146f9e4847fe61
MD5 5bc422dc1fc0b62cb231883b6e44f702
BLAKE2b-256 b32d83bb88f9d46f674dcb09af9cc2e1574f4620c7516ec5eb4136cab2c73647

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 36f7439ca395f5ea8de4f95bbb1c1ee530c998f93c092c58801f3502561e84ea
MD5 e5a787d7f34832254a044561d1414af9
BLAKE2b-256 98fad108675b22c79ccbab53ce5d1476f44904977e0ff174b377dbab582112a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp314-cp314t-macosx_11_0_arm64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp314-cp314t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f4953da946fb7508e26df6d64eecff5573d7ac5636492fd2bec33d612742a38b
MD5 d7b8b6a91984cbba4466c69fc13bb704
BLAKE2b-256 7b1f367e79834d4a1e3137d2c683b8d9a923863ddb44eafcf00e630953d695a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp314-cp314t-macosx_10_12_x86_64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7d4013d85aac4cc5bacf20eb949830ef691f58e071a5f19e591649da56bd74ae
MD5 1352d4b084e86b27fca211d1b50771b3
BLAKE2b-256 b10697513be5296ad01c76b476a29fbc1b9efb620c1433d350160a9434187dbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 62087058c969d6f37985602e83cb5bf1672e08e8c73319ccbee96af296940d29
MD5 10a5151f6f34b40e8b0b4dcb7285b7e1
BLAKE2b-256 5bcac4d4c83bb4dd58cd855f851b09b9118dd9059dd783090a1f4b951fb37498

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b7348e7458f68fb04fb0ad72ac55ac825411ed7a442644bcb77efa0a2010f748
MD5 70e73643c2d6dae210daefb19595f5b7
BLAKE2b-256 e8ca46d10ab3b8f304afb58bbe8d4845ba9b952a81dcecfbef4051b39862a96c

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3d505e164ac5e8357b4a1ba9a47332e46d174e3ab0b1ac3d200159ffd33e3044
MD5 d79425451fdde3593eff96a504a8f667
BLAKE2b-256 b94f1def5ac03aa603e234ad1064d8303bdf0d76ed18f7ab7ef0cbcd6f57238d

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp314-cp314-macosx_10_12_x86_64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp313-cp313t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ad304d0a6803bf4de0d8ea550dc7d0398a45692e934378a6be7f8a6727fbe9a
MD5 e03440dd853cdfec71370ccbc72c24a7
BLAKE2b-256 72438edfe3251f9c69d17ee2d0d7e81bb44b7386bed107f882270260e8a2b7f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp313-cp313t-macosx_11_0_arm64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp313-cp313t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a5e297ea89974aa5547585b536e6585aff193ab2a1672ac6472c2ba01c950e80
MD5 46470e042cda85acd871c9c5ccf35207
BLAKE2b-256 6cc3305389e6ae6e0cf22a19db1afcb232288fed32a63d31bb02137ae972724b

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp313-cp313t-macosx_10_12_x86_64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 40f845e146cefe4990c0ef1272dc6c0973b018f57038e9aad1a5219fce5005df
MD5 73616e3382c9d4a33c4ec062f992b03c
BLAKE2b-256 74ab29bc779cbaf4722218890637c6f8ac9646fa37658487effda0c6bb8edc3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 258eacb76fcd77d48dfb6d4033d4bab2ad623c35340534d907b29c229dd62b87
MD5 28ffc18ce99f178ec38c865f368978ae
BLAKE2b-256 47e3f177ef2ae4635d5ee81fdaed52a6933a9044aa7c9c384caa44724ac7437e

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 137fcaff56edd09b563992f2e0736bd21e04ae87adb5b6f88e8b61c014eea9ee
MD5 ef1465c4a60d355918a1180dec1e34ff
BLAKE2b-256 8931b6649ae16f7fc02cdbb96f5973a8c93b903198979f89c09f03c908bd25a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trace0-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b59503e58b71603ab60781c6a6e8cba8c3ba99f6173782055ffbbe6f992605e6
MD5 2442772dad8a3112c59e48c1e3c6bdad
BLAKE2b-256 36461692781b840f8c528d1ee02be4481ef1f547ffd9de2c240d376bb60f1580

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.7-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: release.yml on soof-golan/trace0

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page