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 0.99× to 1.49×.

slowdown
telco, scimark, fannkuch, nbody 0.99–1.03× arithmetic in tight loops
pyflate, chaos, float, go 1.17–1.22×
raytrace, hexiom, deltablue, richards 1.40–1.49× 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, measured with hyperfine:

wall time vs vanilla
vanilla 0.98 s
trace0 (protobuf) 1.38 s 1.41×
cProfile 2.42 s 2.47×
profile 19.27 s 19.5×

trace0 costs about a third of what cProfile does and keeps every event, where cProfile only keeps per-function aggregates. That trace was 210MB — a full timeline is not free, it is just cheaper in time than in disk.

For the callback in isolation, scripts/bench_producer.py reports the difference against the same workload untraced: ~5 ns per event at 8 threads, ~14 ns on a single thread. An event is one PY_START or PY_RETURN, so a function call is two.

Try it, without installing anything

uvx fetches the wheel, traces your script, and leaves nothing behind:

uvx trace0 run --output trace.pb --format protobuf 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 give it whatever it imports with --with:

uvx --with httpx --with pandas trace0 run --output trace.pb your_script.py

To trace under a free-threaded interpreter, name it — every thread is traced, not just the calling one:

uvx --python 3.13t trace0 run --output trace.pb your_script.py

Install

Add it to a project when you want the Tracer API:

uv add trace0

Requires Python 3.13+. Free-threaded builds (3.13t, 3.14t) are a first-class target.

from trace0 import Tracer

with Tracer("trace.pb", "protobuf"):
    your_workload()

The same CLI is then on your project's path:

uv run trace0 run --output trace.pb --format protobuf your_script.py

Formats are json (Chrome Trace Event, human-readable and diffable) and protobuf (Perfetto, smaller and faster to write).

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.3.tar.gz (43.7 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.3-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (638.4 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

trace0-0.1.3-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (622.6 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

trace0-0.1.3-cp314-cp314t-macosx_11_0_arm64.whl (569.5 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

trace0-0.1.3-cp314-cp314t-macosx_10_12_x86_64.whl (582.4 kB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

trace0-0.1.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (638.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

trace0-0.1.3-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (625.5 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

trace0-0.1.3-cp314-cp314-macosx_11_0_arm64.whl (572.3 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

trace0-0.1.3-cp314-cp314-macosx_10_12_x86_64.whl (582.3 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

trace0-0.1.3-cp313-cp313t-macosx_11_0_arm64.whl (571.4 kB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

trace0-0.1.3-cp313-cp313t-macosx_10_12_x86_64.whl (583.4 kB view details)

Uploaded CPython 3.13tmacOS 10.12+ x86-64

trace0-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (638.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

trace0-0.1.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (623.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

trace0-0.1.3-cp313-cp313-macosx_11_0_arm64.whl (570.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trace0-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl (582.6 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: trace0-0.1.3.tar.gz
  • Upload date:
  • Size: 43.7 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.3.tar.gz
Algorithm Hash digest
SHA256 eaa0b280c144f6392bc659f7864ac69c891f8adbcba3650ffab0bdd5920ccf30
MD5 009b42d98486e7a417734346ec7cf33b
BLAKE2b-256 647b0e6ad57582493bd5837d9521412729464783c5a6575ea5d64f6d9663e85b

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3.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.3-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a51733c36d16f16dfee2b76dbfc21be4c9017310d77b34e00aff80f68f3833b
MD5 279207c333f258444afbf90c7030b179
BLAKE2b-256 28a1cbb7cd0a53af2f732ab475391f1ac0160d0f23534f4967e8c849e24659e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4ef434c25ce461a77fb45c364b1635d7795a1d987ca032c1649356a80cca8c36
MD5 a74d9192f8154e3633a13436adec890d
BLAKE2b-256 b2bda36600f0afaaceffc07f8e4881088eca82aca5ff79775594ce5c4a375f4f

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b1944311cc33a40f79bd82c267ec9c2426eac197cd4ac6178178723e49fcc682
MD5 a55dad5ccb79fc24dca3a4d4be6da3a6
BLAKE2b-256 c8b6cd668b072a533b5a483aac44042becf6c8c686a4cadb443fe3171f183ff3

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp314-cp314t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 968c7fa05fc8c089ceb8d18cd97210d619ccd129a13bdba99683e015df358924
MD5 87effd37523aedf74ffa8090fd7cac3b
BLAKE2b-256 11773e3ca074c00de8a924f9876ecf80520c04bd408b119a92f66ca9be7b9195

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 906bb6199e83cc261546e8289d7fbb6212033ae06941e32708c1bfe509b82630
MD5 d32a7ce81671aee85615e2b2e2cb9d06
BLAKE2b-256 51c11ff53e7b5bd6b0fd6b2b7812233d15af641e2db9ab6b87aba69a5600e588

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e4c6cb2747a29858b93c3f79551f6f4fb192a0f25e56eaff4821ecbc556c81f9
MD5 f2a95a53221d37f5932387297322b957
BLAKE2b-256 3454850d35b83b62fc37798715ffb3af2aeff1f124f49af82c3b3eec97c2b1f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd1cead175a29742bef03881dbf06f24193ba6e36fb17c5d2c1a393bb0a17f98
MD5 b4b3ca797b473c8cbf9b3faf105fb3b0
BLAKE2b-256 20b281cb6dceda97d998a8c61b00d2392dfeab24372bf5309060deafc5fa53ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e6edd99a4d89a7d2a5b6ec1e76912b7c714fb99d19e539b6ec0ea848cb0219da
MD5 fc0ffb1b2596a877a834ef1f7c2d9864
BLAKE2b-256 4227a9aeb5375e6368838c418e78ac4f56f28c7ba829d41bd656d5f5864cf967

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp313-cp313t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23756a4d85d6425fd2b5ee3a4e96b179008f703bfd727c86d00d8b379a9d7a71
MD5 3a45c608a13b032973e3e5c05dc251e2
BLAKE2b-256 4b70a74f563f698cbb62eeaed72bc9a43243187f4a2dea33e79ba3904996693b

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp313-cp313t-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4e4456fca520c00d8542d0c1526d6974ce22058f5aac064f428f8f7cce4e2a74
MD5 0c54c11aa53c93f973810416d8ddb518
BLAKE2b-256 4725e2186ceeedf6c821cee1739fb10d21c73209068bd32bec8cb1d53dcd5d56

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57f2107b6bddcbfacae1e0f39ab18ae6c4b5dcf8c328b2452ddca51e7b0fbdeb
MD5 9b54316e918fcfd7cf68aa4e1e01a560
BLAKE2b-256 a40a9fa9cf5a9b8aa9f61f9c159e412932569a296fe57c96d82ef4445b6de2f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ed73cce27990b11d51d6b97fd102a424794b1bc51516aa2b415f11e2e968f3c3
MD5 592111e6b2b3e317d4e1c1ec18911c66
BLAKE2b-256 908da9f161e64096302c34dbf9290200a50339c4c83fd699bb37e1a11e9d2010

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af8d8f01a16367a08c6f00c1523bb1fda1d219286b14611254e0e28e49c93a39
MD5 f730ff5681e787b516a77fed8aa9bdb4
BLAKE2b-256 35dde69a4d2feff1a2c8d171464b9be8b18ee126385bee3978ca136074d648e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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.3-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for trace0-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 52d80f104b6a2226dd25ce9b084d39d620c883a82e030c1370c39d395baca057
MD5 3ad52e11b7125f7dc2c91612a46341c7
BLAKE2b-256 12dd844d3977509fbfd14aaade91100de6062e9aca50ee95598b70dd2fe79adf

See more details on using hashes here.

Provenance

The following attestation bundles were made for trace0-0.1.3-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