OpenSource-Hub
M

magic-trace

5.9k stars·Developer Tools·SHA-256 checksum verified

A low-overhead, Intel PT-based tracing tool that captures all control flow with ~40ns resolution, enabling post-mortem and performance debugging via interactive timelines.

A high-resolution tracing tool using Intel PT to capture all function calls with ~40ns granularity, enabling interactive post-mortem debugging without code changes.

Core Features

  • Captures every function call in compiled languages (C, C++, Rust, etc.) with ~40ns resolution
  • No application modifications required – attach to a running process
  • Two snapshot triggering modes: manual Ctrl+C or automatic by calling a specific function
  • Interactive trace viewer with zoom, measurement, and call-stack navigation
  • Low overhead of 2-10% thanks to hardware-assisted Intel Processor Trace

What It Can't Do

  • Requires Intel Skylake or newer CPU and Linux (no virtual machines supported)
  • Kernel tracing needs root privileges
  • The trigger function must be a non-inlined empty function
  • Overhead of 2-10% is typical; evaluate impact for latency-sensitive workloads

Use Cases

  • Identify root cause of latency spikes in production services by comparing fast vs. slow requests
  • Reconstruct the last milliseconds of execution before a crash, providing context beyond a single stack frame

Detailed Introduction

magic-trace is a high-resolution tracing tool from Jane Street that leverages Intel Processor Trace to record every function call executed by a process into a ring buffer. Upon a trigger (Ctrl+C or a designated function), it snapshots the last ~10ms of control flow and renders an interactive call-stack timeline. Unlike traditional sampling profilers like perf, magic-trace captures 100% of control flow, making it possible to see exactly what happened in the microseconds leading up to an event. It requires no application code changes, runs with 2-10% overhead, and supports multiple triggers including fuzzy symbol matching. Ideal for investigating production performance anomalies, understanding complex code execution, and crash recovery scenarios.

Tags

tracingprofilingIntel PTperformancedebuggingcall-stacklow-overhead

Getting Started

1

Download installer

Click the button above to download the installer for your system

2

Install the software

Install the appropriate package for your distro (dpkg / rpm / AppImage)

3

Download the latest binary and make it executable with 'chmod +x magic-trace'

4

Launch your target program and run 'magic-trace attach -pid $(pidof your_program)'

5

Wait a few seconds, then press Ctrl+C to stop tracing – a file 'trace.fxt.gz' is created

Install Guide
  1. Download the latest binary and make it executable with 'chmod +x magic-trace'
  2. Launch your target program and run 'magic-trace attach -pid $(pidof your_program)'
  3. Wait a few seconds, then press Ctrl+C to stop tracing – a file 'trace.fxt.gz' is created

Latest Release Notes

## What's Changed

* Add support for compressed output files, whether gzip (supported by Pe… by @bnigito in https://github.com/janestreet/magic-trace/pull/306

* Handle TSX transactions by @bnigito in https://github.com/janestreet/magic-trace/pull/308

* Fix symbol resolution for Rust binaries by @JosiahWhite in https://github.com/janestreet/magic-trace/pull/321

* Reap zombie `perf` processes from capability detection by @Xyene in https://github.com/janestreet/magic-trace/pull/316

* Recognize `int3` instructions in trace parser by @Xyene in https://github.com/janestreet/magic-trace/pull/322

* Add a `MAGIC_TRACE_NO_OCAML_EXCEPTION_DEBUG_INFO` environment variable by @bnigito in https://github.com/janestreet/magic-trace/pull/305

## New Contributors

* @bnigito made their first contribution in https://github.com/janestreet/magic-trace/pull/305

* @JosiahWhite made their first contribution in https://github.com/janestreet/magic-trace/pull/321

**Full Changelog**: https://github.com/janestreet/magic-trace/compare/v1.2.3...v1.2.4

File Integrity

Checksum not available

This project has not published a SHA-256 checksum on its GitHub Release page

SHA256 Checksum

No checksum available

Download directly from GitHub Releases and verify file integrity yourself

All SHA-256 checksums on this platform are extracted from the project's official GitHub Release page, without any modification. You can independently verify them on the GitHub Releases page.

Open Source Transparency

View GitHub Source
Environment Guide

Uninstall Info

Delete the downloaded binary – no other system files are created during installation.

No Extra Dependencies

Ready to use after download. No additional runtime required.

Project Info
LicenseMIT
Last Updated2026-05-24T06:13:43Z
GitHub RepositoryOfficial Website

Similar Projects