The ZJIT team (Ruby's new JIT compiler) integrated Perfetto tracing to visualize and analyze JIT side-exits — moments when compiled code falls back to the interpreter. The post explains why side-exits matter for performance, shows how --zjit-stats provides aggregate counters but lacks spatial/temporal context, and demonstrates how Perfetto's UI and SQL interface reveal hotspots in Rails app code. Implementation details cover writing traces in Chromium JSON format (which ballooned to 8GB) versus the more compact Fuchsia Trace Format (FXT) with string interning (~100MB), plus sampling via --zjit-trace-exits-sample-rate to reduce output further. The Rust-based trace writer is linked on GitHub.
Table of contents
The rulesLies, damned lies, and statisticsBuilding intuitionA look at PerfettoImplementationTracing more thingsConclusionSort: