Skip to main content
Lab Grimoire
TW EN
Coffee
← Spell Book

magic-trace

dev-tools

Spell Rating
🔮🔮○○○
Pricing
open-source
Difficulty
advanced

Best For

Systems programmers on Linux with Intel Skylake+ CPUs who need to trace intermittent slow requests or analyze microsecond-level behavior. C/C++, Rust, and OCaml developers get the most complete experience.

How I Actually Used It

Could not use it. My development environment is macOS + Apple Silicon. magic-trace only supports Linux + Intel x86_64, and most cloud VMs do not expose Intel PT.

What It Does Well

The core value is full-fidelity recording rather than statistical sampling. ~40ns time resolution lets you see every function call inside a 70ns function, which perf sampling and Flame Graphs cannot achieve. Overhead is only 2-10% because tracing runs on CPU hardware. The stop indicator pattern lets you leave an empty function in production code with microsecond-level cost only when magic-trace is attached. The Perfetto timeline output renders entirely in the browser with no data leakage risk.

Failure Modes and When Not to Use

Hardware is the biggest barrier: Intel Skylake+ CPUs only, no ARM or AMD support. Software: Linux only, no Windows or macOS. The trace window is limited to ~10ms. Exceptions break call stack reconstruction. Python tracing is limited to the CPython C layer.

Pricing, Learning Curve, and Risk

Free (MIT). Moderate learning curve: installation is simple (single binary), but understanding Intel PT and correctly reading Perfetto timelines requires background knowledge. Low risk with Jane Street maintaining it actively (latest v1.2.4, April 2025).

Verdict

Fills an important gap between statistical sampling and full instrumentation by providing hardware-accelerated complete control flow tracing. Strict hardware and platform requirements limit it to specific Linux + Intel environments. If your setup qualifies, it is the best tool in its class.

Sources