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 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"):
    your_workload()

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

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

Formats are protobuf (Perfetto, smaller and faster to write, the default) and json (Chrome Trace Event, human-readable and diffable) — pass --format json for the latter.

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.4.tar.gz (35.1 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.4-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (631.1 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

trace0-0.1.4-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (618.2 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

trace0-0.1.4-cp314-cp314t-macosx_11_0_arm64.whl (565.1 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

trace0-0.1.4-cp314-cp314t-macosx_10_12_x86_64.whl (576.0 kB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

trace0-0.1.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (632.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

trace0-0.1.4-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (619.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

trace0-0.1.4-cp314-cp314-macosx_11_0_arm64.whl (565.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

trace0-0.1.4-cp314-cp314-macosx_10_12_x86_64.whl (577.3 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

trace0-0.1.4-cp313-cp313t-macosx_11_0_arm64.whl (565.9 kB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

trace0-0.1.4-cp313-cp313t-macosx_10_12_x86_64.whl (574.4 kB view details)

Uploaded CPython 3.13tmacOS 10.12+ x86-64

trace0-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (631.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

trace0-0.1.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (619.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

trace0-0.1.4-cp313-cp313-macosx_11_0_arm64.whl (565.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trace0-0.1.4-cp313-cp313-macosx_10_12_x86_64.whl (578.4 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: trace0-0.1.4.tar.gz
  • Upload date:
  • Size: 35.1 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.4.tar.gz
Algorithm Hash digest
SHA256 867455d16ccc9339874c1880e9b1981fcfdfff8593944092a9556090e61bb98f
MD5 8871c9dbea3ca3bb4a52316011f4850b
BLAKE2b-256 b24d3bfe796db205ecd128a66ac7b3ee19f7866c9a8432ccad07f648554d304f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0d94cc931bc5c42f8ff56d893ecafd0e61d458f7f4d28d220703be6616f75e8b
MD5 c5ab5735c4bc323717f91741bd3922c7
BLAKE2b-256 e64c55750c67032bd243e33eb889414b7faf958f00e349f2c6a9e49c9f1a87d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dce029fe70d61c32320985e36157529f80f121a13f71a3a72df22b65fe4fcc7e
MD5 ef2e328895e72505d81e246fdd92f229
BLAKE2b-256 7ba682f73292ae50acc1bdcc2a67427c1ede2114117d0cea4f461d5c699081ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c311ab8d7086d5aec5cffa52ded6147c918e0bd10edc3f19077c2cb53e082b54
MD5 4ac837b4ac8eb33eca91137cc6fe07f6
BLAKE2b-256 e118bacf85ce3eab2872d5617975af8d1f2b7ec9feab86554b7d583521222f17

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 478f928321995f411a5c8726a454fddd02fa610f337527061abb3a4a57e1252b
MD5 5a834d883d3f2097a6b87cf24c7d6845
BLAKE2b-256 be615d6d4b7f9b0075e0d885ee58acde15cce3e1b70a59061e26767023341b0a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a6dddc02175a3b5db0cb2cc7a9d22fa078f21d9136a48bb0ca8f3dd666530dbc
MD5 fab29e9779201e6080229ce38ae69858
BLAKE2b-256 2be0d2dc93571d831eb28672f26fe30f0176f2c9b7cb888d4563cfd16ad961c9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0c4eb9136f5a65494a6f7d92af8716fc03be666c9c4587b8fc2fc692a53b5e35
MD5 14b4088b8c783cc9eaca9403cbf87864
BLAKE2b-256 ee9655b99a0870a9b9a09859eb1621e94fc578a14538f2ea9d961df9475b3f16

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 173d8baea658adc8f4e4d20359780287246159cb48f3b2a8e66e39d3df253389
MD5 1440416ded3873e18e07513042af9613
BLAKE2b-256 e686d129f83b829828938dae544c17bb4e998b9bebe7ed35095bf27a577bc54b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e2c6d09e5f94e2bb1fe8afe18a87659ccb50ad059c68801e5378db03a82c327b
MD5 bf8380dd04ddf8e1a2f22771c81d51b6
BLAKE2b-256 37ac1804dbd74d8a1c1ed1ed0bb23e114189248d746ec8154fcefc254b69788e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1f57d316cf945c01c282a87b5d7a336943a3f21927141696f1139fb61cd4c884
MD5 7207e5e6e8c32724962903f22e268d26
BLAKE2b-256 a7ca15ed5e54d7855be2c4e4d04481b2727cd65c6447128d3b2d4497b9b286ae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9bef34e1767a5f675f8fd3edcccb71c956dded2d50b40db1ca85ef6d6eeac68c
MD5 f52ce9e15ec3a009ca26303d1d3b6d5c
BLAKE2b-256 001e6d99b41233b5c7b5dc8c2a61cc0df5570623dd92e6c95f0b9c27b5e9d9d4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a512bc98e68c88dc3b172411aea4d4d7b892f57a4ede004fcf4408a8effa3ef
MD5 814597652b28e93f9e06339f03cced6d
BLAKE2b-256 acaa1ec7a181be37e6f3b2078d06d6f52c9bf21eb8471311d4ca0ac98661295c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8bb4478398210b42a5bbdefbe4faa68f478da11966e025cc4cc9827d1e0391e8
MD5 30d98ffebd9d37f671c3d958b8db4562
BLAKE2b-256 cfdfa0da1d4960d57bafacbd19cfc56ea323adf6445660da04ee593b8c6c9508

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 045ea19ac8e57ebbfcf1477d72269da561e87ce416e3a486c771ca12161a6aee
MD5 ffa9b1b1b862a340e545f8ff3ddcebc1
BLAKE2b-256 f970e487b086c64bb93b9dab11668c1f7c9347fcc229b9224fe7e6173ff9af81

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.4-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 87be25f7b246c78371de5cdbd99e9ce4ecdc5f3a1c619199868b0088b6b29b6c
MD5 bd470cbc868e3cd9742b7430cce2eac1
BLAKE2b-256 2e04f2699efc4fc19d8749ba427dbc3e3a9521fc593ab6df11d53c63e077a3b0

See more details on using hashes here.

Provenance

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