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.6.tar.gz (37.5 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.6-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.6-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (617.6 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

trace0-0.1.6-cp314-cp314t-macosx_11_0_arm64.whl (563.8 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

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

Uploaded CPython 3.14tmacOS 10.12+ x86-64

trace0-0.1.6-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.6-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (617.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

trace0-0.1.6-cp314-cp314-macosx_10_12_x86_64.whl (576.4 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

trace0-0.1.6-cp313-cp313t-macosx_11_0_arm64.whl (564.5 kB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

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

Uploaded CPython 3.13tmacOS 10.12+ x86-64

trace0-0.1.6-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.6-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.6-cp313-cp313-macosx_11_0_arm64.whl (566.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trace0-0.1.6-cp313-cp313-macosx_10_12_x86_64.whl (576.8 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: trace0-0.1.6.tar.gz
  • Upload date:
  • Size: 37.5 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.6.tar.gz
Algorithm Hash digest
SHA256 4d577cf36e88742ffb96dfe58f251d6a380a89aaa6772651808a57c6a0c64e2e
MD5 37d215eb96b0cb7d675fb185d21d44b8
BLAKE2b-256 cf05cc9ae6229ddc99fa6fc17fe825341e0a2b90d1de6ce54a42d258075ca15e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c01aeb88ad84c420032019eaef6559c1a347d39963e4aed57396db97d896622
MD5 cae471018f7900e17fd747f366faa354
BLAKE2b-256 2ceb35596c0acdce7739065bb7bd7e3d897e970d39ddb831cfc18e77915b4d67

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d2be92d5ca9f9e5301c411bcb87cd6aa57ee3cca7e56a7779a3c2802a817d576
MD5 05fdc70ca05f75842f723b744432abbe
BLAKE2b-256 f90a8675a89e96204ab51f7a901c67e867f5bb536fd76fd1681c85139f844289

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5bdfb3c616eb8316452f4a3afca37161b6dc845aa492d5fca10e7aef49fe95a4
MD5 11ec5d861d9c631fc0f37dcd6d7be624
BLAKE2b-256 8764597d00999ec63d12b34ce56215845b553273b426be136167b5037fdb4789

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 542ef3ea66737cb9f9f6bf1451eab5523d710a74d6e05f4eb83d4386d3a2d001
MD5 f43a3c262fcd811c2566326271b43f09
BLAKE2b-256 d29c93ebe3fad33a87a431f60e3a7b96bd92ea02cd3380e30f5f67e3bcf9d4f1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 39dadc5af02906eeace6f4b6c7a31fc282be951469c548291713ff0efbd2019b
MD5 699744a1204d1ecdad111e856a203a82
BLAKE2b-256 59a713cf053be4085c005c44e4e6e7595225a7507a10c1eb5e8ae529e32a352c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 886232f4f94807f17fd4bde21d8f9b0fc2aa2083ff266951363644ab33d2961c
MD5 6940bbe728e0d34878c23483425601e0
BLAKE2b-256 8dbc7928e9fe7142d2151b6afd228169608a8abc6b80663b7c3003cc5ea03006

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6527ffb1062d714820919c7c50ef6faf502d8085453a8502e791473f8045a3b
MD5 d67cece1ea860e3742ee710d867b9b8e
BLAKE2b-256 8a3c04a22da791bebc384dff7d113dfbd58da0b99847b802f4c1680f893922a8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 02f2d9adb42aecbeb11588430a86d4b352c5042d0f724893b103b9ea89bd04a7
MD5 c482f82d3a2f12736a84168de341d6b4
BLAKE2b-256 5cfdc25389c83b719065a8e097d02e1a02e132a1f3ffb0f345752924d0178865

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3295e4f9295e79fa3dcda322b64c7aec5787bc982ad4b1cbe7a2625b3659e26c
MD5 2e8e2f8e0a7e91c7bedf11a64f3bbc32
BLAKE2b-256 23033e23b44dde3cd17d5b628b23b2b9c2d4a6ce7860646f20a7179594476ad8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 359e761cf094129350be38499a853991c0288d96b4cf0f09776b2e2fc31a6a1e
MD5 a0ea3040e2f820a953f447a26c8bfa62
BLAKE2b-256 3859db94709532f7586d996bd36ffd533470f1258a78a27d47e5213a3767084a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 02ac24afb252a1307176e7d87c75e8322f2c3b2d16a72987b74554a06ec59e2a
MD5 3fb0418c8faaf5cf438c28561db73dd0
BLAKE2b-256 424d32a67e01f4a143b5aebefbf14dbde0e7b8ee6a00b4e0f35da2adbc06df7b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 83b5ef4a457e9d180383646e9fd258b526c23d5e77997961a478011cf0b3b21a
MD5 ad2323ace7bc110ed864e95863cbdd9f
BLAKE2b-256 5c8f2a9e1251b3094b22e214fb43d5f6e4ac5cdf4b82ad252108f4a48a9edcb6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72d783e5dab2518e19b79ec202ccdcfe9ba77c3fb2bdd8a6f9e8bd924f19c27a
MD5 43c23311b608abf40ac972744d87102a
BLAKE2b-256 95f7b284eaaf47d6d1c541cf04227ecd82f4a68994d5b87a201ea4e5dfd9b420

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.6-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f3d05ba97fa09e94dc5e533827b8ca04a903bf7f945a7f71b229eda849b71e31
MD5 51a88fc54ff67b83a5c33bf93f6a09cf
BLAKE2b-256 e78300d1a472ddb556c4d34991bb89a148bd4e095f3c1a5a629a143f6665d6e2

See more details on using hashes here.

Provenance

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