magic-trace logo

magic-trace

High‑resolution, low‑overhead tracing of every function call

magic‑trace captures nanosecond‑scale call‑stack timelines with 2‑10% overhead, requiring no code changes, and visualizes execution history to debug performance and crashes on Linux Intel CPUs.

magic-trace banner

Overview

Overview

magic‑trace records control‑flow with Intel Processor Trace, providing ~40 ns resolution for every function call while adding only 2‑10 % runtime overhead. It works without any instrumentation, simply attaching to a running process or launching a program, and can snapshot a configurable ~10 ms history of execution.

Getting Started

Install the pre‑built binary or Debian package, then run magic‑trace attach -pid and press Ctrl+C to capture a trace file. Open the file in the web UI (magic‑trace.org) to explore an interactive timeline: zoom, pan, and measure call durations, or trigger snapshots on specific symbols for targeted analysis. The tool is ideal for developers, performance engineers, and ops teams needing deep insight into Linux applications on modern Intel CPUs.

Highlights

40 ns resolution tracing of every function call
2‑10 % runtime overhead, no code changes required
Intel PT‑based snapshots with configurable ~10 ms history
Interactive web UI for zoomable call‑stack timelines

Pros

  • Nanosecond‑scale visibility into program execution
  • Minimal performance impact
  • Works with unmodified binaries
  • Rich, zoomable visual analysis

Considerations

  • Supports only Intel CPUs (Skylake or newer)
  • Linux‑only environment
  • Virtual machines are generally unsupported
  • Kernel tracing requires root privileges

Managed products teams compare with

When teams consider magic-trace, these hosted platforms usually appear on the same shortlist.

AWS X-Ray logo

AWS X-Ray

Trace requests through distributed and serverless apps on AWS.

Better Stack Tracing logo

Better Stack Tracing

Tracing correlated with logs and metrics for faster debugging.

Grafana Cloud Traces logo

Grafana Cloud Traces

Managed distributed tracing powered by Grafana Tempo.

Looking for a hosted option? These are the services engineering teams benchmark against before choosing open source.

Fit guide

Great for

  • Diagnosing latency spikes in production services
  • Post‑mortem analysis of crashes to see pre‑crash activity
  • Developers who cannot modify source for instrumentation
  • Teams running Linux on modern Intel hardware

Not ideal when

  • ARM or AMD processor architectures
  • Windows or macOS platforms
  • Containerized workloads inside virtual machines
  • Scenarios demanding zero‑overhead tracing

How teams use it

Investigate intermittent latency spikes

Identify the exact function call chain and hidden page faults causing delays

Post‑mortem crash analysis

View the 10 ms of execution leading up to a crash, revealing the root cause

Validate async runtime scheduler behavior

Capture snapshots at each scheduler tick to measure cycle duration and overhead

Measure third‑party library overhead

Zoom into library calls to see internal function timings and performance impact

Tech snapshot

OCaml100%
C1%
Makefile1%
Shell1%
Dune1%

Tags

introspectionx86profiletracingintelvisualizerperformance-tools

Frequently asked questions

What platforms does magic‑trace support?

Linux on Intel CPUs Skylake (or newer). It does not run on ARM, AMD, Windows, or macOS.

Do I need to modify my application to use magic‑trace?

No. The tool attaches to a running process or launches a binary without any code changes.

How much overhead does magic‑trace introduce?

Typically between 2 % and 10 % of runtime overhead, depending on workload.

Can I trace kernel activity?

Yes, by running as root and adding the `-trace-include-kernel` flag to capture kernel‑mode control flow.

Is a graphical interface required to view traces?

Traces are visualized in a web UI; you can open the generated file in a browser to explore the timeline.

Project at a glance

Active
Stars
5,206
Watchers
5,206
Forks
120
LicenseMIT
Repo age3 years old
Last commitlast week
Primary languageOCaml

Last synced 4 hours ago