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

crate role
trace0-core clock, event model, event queue, exporter contract
trace0-json Chrome Trace Event output
trace0-proto Perfetto protobuf output

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.2.tar.gz (49.8 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.2-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (634.1 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64

trace0-0.1.2-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (619.1 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

trace0-0.1.2-cp314-cp314t-macosx_11_0_arm64.whl (566.8 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

trace0-0.1.2-cp314-cp314t-macosx_10_12_x86_64.whl (580.0 kB view details)

Uploaded CPython 3.14tmacOS 10.12+ x86-64

trace0-0.1.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (635.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

trace0-0.1.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (619.8 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

trace0-0.1.2-cp314-cp314-macosx_11_0_arm64.whl (569.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

trace0-0.1.2-cp314-cp314-macosx_10_12_x86_64.whl (580.3 kB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

trace0-0.1.2-cp313-cp313t-macosx_11_0_arm64.whl (566.9 kB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

trace0-0.1.2-cp313-cp313t-macosx_10_12_x86_64.whl (578.8 kB view details)

Uploaded CPython 3.13tmacOS 10.12+ x86-64

trace0-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (635.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

trace0-0.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (619.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

trace0-0.1.2-cp313-cp313-macosx_11_0_arm64.whl (569.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

trace0-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl (579.2 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: trace0-0.1.2.tar.gz
  • Upload date:
  • Size: 49.8 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.2.tar.gz
Algorithm Hash digest
SHA256 67283d6f06f9bc5cccb999dedc572220cfb28daaa500c776b864115763d43787
MD5 f480daf17d94f5432482fd15dd303fce
BLAKE2b-256 a314a0d0eb449eec0e09aff78025d3bb28822e2bc87fe9adc18104e23eefd8b4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1625f117d8d75538ba586b35c8e6498f25a770b4e7c1bbc408c559d376ea46f6
MD5 e80dfd46c54e41b4a393c15626b1fbc8
BLAKE2b-256 b729caf96a48ff75a31181d7aa2dadc8c04a41f1070935a5373df11c7d2e32b8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ea90ae1f93eee67290295a7ecb502aad4fe3a30e056fd31d18987eaffd14cf1b
MD5 02e5b5d2a79b7532cb619317111dfe52
BLAKE2b-256 3e2d1f8a51396b17e77d593d3f0b6b02484277a62d0bf56625c05fcd8d0ae02b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9ed9a4122d939b930a0a6777e6728c3178d2fd0b45b352f6f333c2ae49451669
MD5 5febd604b60d0dbc69c551402d09c62f
BLAKE2b-256 6f77b1c12ff5223d6915775b59ee7f0a3abe9abd363662fe5faf223dfff1b729

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp314-cp314t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c7e158186775e95fda693b9e3986b6e3b7403af23fa7695ccbbb6b2c5ced3cec
MD5 27942b35c1629d7070b065120668ce07
BLAKE2b-256 fe76d9be9addc926950767b296ae57202cd14dd794ac45abb382da0e94e7c5d1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 727f92bd77be8919761f275468045d0025c2cc1884d1ae3f87b70241f72eae73
MD5 577c85bdb6cf8ee0cf1f671611a71fa6
BLAKE2b-256 76f62d90be4847a1e94525c61cebf3cefdb4f934c760de472b8ab0c234792b0a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c8a7cb7ce457048398968e3063d77409dc3c9482a6351d2ed200c143194c0b3e
MD5 6e5200465f007da9c5b80d6d2b1ee3d4
BLAKE2b-256 a1fa2be92887913745ec9b72812e9081db30f9cda154364d8994086d0698bd8e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec85ff32a502af4fc654f9fad18b6919cd8fa26f62ebfc80650e6071cbf3911c
MD5 b6b43deb1a948fe7474d87b1ddded294
BLAKE2b-256 7d211f1cab52036195acfb4f44512714ebd8546d99d989d86e0dd134b7b3e548

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 84600afddd608fbe1a90718e89ddae293bfa9bc287f60f61b06840cfe481139a
MD5 eb761c2adc56473c51cf674ffd14d096
BLAKE2b-256 e3dcceb0fbebcbadd4755f38a931903365b118a3744dec93c5a82e3ed79c8814

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f84634a224661cad9a3e70028b35448f05473a5b3ca6039b5a788031582bb40b
MD5 11f90caa40570c0ae446b5f5fbd80ff0
BLAKE2b-256 d150878932879049a742864acf8b2011379c46541609f9129320eca5634e4368

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp313-cp313t-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8c1fb1cb04f679230127666ac7bcfcd4b8c0a1cd3362a8126550a270d3e893c1
MD5 f53bc543d8c231d7f8df7bd007f5d745
BLAKE2b-256 e7f3d3179a36a0f218c5a2f5d71cdb157ba502806f8c4c727ff4d7a676679bb1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 746fb596421d7516b8477fc0fe525af64c5f937dd921a48ad30f7635c2346f5d
MD5 91eb0284af728b69d79bb329e6e3bf38
BLAKE2b-256 c15b3f2846f948a9a9518a17141a2968eda5f27a1bdce3017ab656fddee5fc83

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ef2c09c07d86fade9eb78be98014c8f000e062e3d747a32dd03e44c76a9c1765
MD5 5a3b90e0f582a88bef5e2ca49ec0d98c
BLAKE2b-256 0b89b3e5da96d9fa46f66ecb0a9c94bc1132bfff7ff2ff4579fcfbee9097f235

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 344db44ccda1b4fbef3dc6c74c3e23ab427dcf47ec2b66f82c76ca129d7d7279
MD5 02c71497b207244cd5e67410f042926f
BLAKE2b-256 2460989dffc2f619a8ae9b7ccc6a9d3c2ef3fb872fd68c14b69052b5408637c1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for trace0-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 86ba431c6d57c412281d3a36d1732d32337f824bbcc811ea362d64a9ae41b889
MD5 b17f8dc5765da6991b1eb9593c0045bb
BLAKE2b-256 52082b7565aba60bef2eb11fabd1c73d29d0539b9547caa7f18c7ebfe67e0ba2

See more details on using hashes here.

Provenance

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