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.5.tar.gz (35.3 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.5-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (630.4 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

trace0-0.1.5-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (617.7 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

trace0-0.1.5-cp314-cp314t-macosx_11_0_arm64.whl (563.5 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

trace0-0.1.5-cp314-cp314t-macosx_10_12_x86_64.whl (577.2 kB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

trace0-0.1.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (629.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

trace0-0.1.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (619.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

trace0-0.1.5-cp314-cp314-macosx_11_0_arm64.whl (565.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

trace0-0.1.5-cp314-cp314-macosx_10_12_x86_64.whl (579.4 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

trace0-0.1.5-cp313-cp313t-macosx_11_0_arm64.whl (564.3 kB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

trace0-0.1.5-cp313-cp313t-macosx_10_12_x86_64.whl (577.6 kB view details)

Uploaded CPython 3.13tmacOS 10.12+ x86-64

trace0-0.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (630.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

trace0-0.1.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (619.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

trace0-0.1.5-cp313-cp313-macosx_11_0_arm64.whl (566.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trace0-0.1.5-cp313-cp313-macosx_10_12_x86_64.whl (579.5 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: trace0-0.1.5.tar.gz
  • Upload date:
  • Size: 35.3 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.5.tar.gz
Algorithm Hash digest
SHA256 03ee49073a7d70691ff60d6cbce63ac5a2f3bd7082795860664339e3c0930d76
MD5 18e35fa7871f32b3ee265eb87bfb1d52
BLAKE2b-256 085fdb52a81e117861b42d9ca7fda290d15cc5680a3bda9a8d2b93597bb22393

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 883864469db8545ab7236385d08388ed9a3fbe870dbda2443e9b8bbe7ad86b88
MD5 d1b5e8dfbdb477def128adec96bd155f
BLAKE2b-256 ed32eed58242c0a75f83759d72386827ebd5fafec5bdfa7a791277872747d196

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 271d8bdbf9f2b0a34c6bb80dfb4aaefa17f7fd6249ed432dc9e7ff994652f36a
MD5 837790e85550e7d5eba375c0dfb567c8
BLAKE2b-256 bb376cee543456eb75eb6e20920949ad8c39ec25701fbb63eb4284ee11892c5b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0297dec63bce6dd42789260cc5604372f7c47c284b1652b67ea08d34f0e7a15
MD5 a53e0cde9124f415cb25697cfc2d9e17
BLAKE2b-256 d30743bd9e44eca4fb6120e9e347da990115a035b59bcb05e4c4d93f6f588219

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a3bfd112f98a1d645d792c9b154da29a92fc74fd3b2f2684e7c9dcfda788cf3a
MD5 1b10e1e35de9ec9276f78bdfd798a1ce
BLAKE2b-256 c8ffa369b1d5922e55f0a3877bbad19596164c34bc4f12f927d3e8434972e85e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a6a8c651af8e1bc3ed0e7b0092576aaa6d9783a18da45360824350cbcc0c580b
MD5 a51d0d1ef9691fb33a58774de41fde84
BLAKE2b-256 30681e4c81387914dcecc532a422631b987884c15e2bde02322dd5d026f62777

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6f961a719d63c8b0eb4dd4615c0113a47d238f5e00af839285618f901c67e30d
MD5 7a0f717939dbcf8fcb817e3c80ab2f12
BLAKE2b-256 c56e70bc96173fb98617ac7ce040ae9c9b196ec5f2c58162b7d5bc55bdd5c82f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9bbf988cecac6efcfb0beede1d0e6fb6a842fea43f1453c3f2a14096950a0f72
MD5 c452e88d6c7026aa32cf9039bd2ab3ba
BLAKE2b-256 433ec5a9fac43a68334b1f520440609e96ef16a5ea2aed32bc41d70caa7ea118

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4da8b216f79b0f910891b7dbe6563f974434bf1af333d8486c243b1dbc6bb710
MD5 34ba4d398d45065e9d1273289db68323
BLAKE2b-256 a4c701cd036bf842a5463cc9565c87b22f460d684359809a6316039bd84bc50d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 65c51a1af1e191b25852c94c250187f28e979da8d8bc86e12a1afbfe7f16bc4c
MD5 59a5c588c1c7595894915f2767f755e6
BLAKE2b-256 ad5b06239f6ff7a17a409ddaa2de8a89cf345748cbb8369f04f4abeacca2b9ad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 73f7ea50abefc23ac4403964ef3c49a06fd5b67331248d7e044de75f11a0b12d
MD5 ab1b8dec0e5c48b7bca87e00a3801c03
BLAKE2b-256 452c1cac260f04fbf3f7630e65c5464eecac04590107de62eb61bf45be2f6104

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 906130102a68b73eeb904380c838532cd5903f9c1ff099511724bb18aebd20ca
MD5 23ee4d4c53427566ddb7e20f303ff77d
BLAKE2b-256 bed0cd8fcbcb8b51b101ef03d81aa96dbfa205a3cf91b5cfb15a32a4715db653

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4724152a59494384f9abb2f9a1b36440392d271136982747b432ac96af8e1410
MD5 0c1f6094f2eb1552239e96502b67aee6
BLAKE2b-256 7f5c51ec577695b2419e6d1aa9dcf921dba708cf00bb9fa0fb075542ebbc85cd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4cc01ae48121af64fdb8f55b77281c9d4557215a8c97c7a9a937192fa6faa127
MD5 1de17a8f01d537705b5c4e752cb22cef
BLAKE2b-256 ac865318b738449d9e86f4f6e0bedc33c207121ec413ba9205355bbea138048a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.5-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 79b1441737603cf6ed78febc43bbace88736ae48cb9e9c18ef4fa66effa69a38
MD5 c2ba1265c6981d9228954ef8c8e885ec
BLAKE2b-256 216184ce7b9d0c1fb43ed4e0023eacaac453e3dd211484e24ab4f024f963a7f7

See more details on using hashes here.

Provenance

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