Zig profiling on Apple Silicon

submited by
Style Pass
2025-07-29 02:30:03

If you’re a developer rocking an Apple Silicon Mac and writing in Zig, congratulations - you’ve chosen the scenic route through the desert of profiling tools. It’s just you, your code, and a tumbleweed named Apple Instruments. But don’t worry - we’ll try to find some oases.

I have limited experience using low-level languages, so this article doesn’t provide a deep dive into profiling, but rather serves as an entry point to the world of profiling.

For Linux, we have perf, valgrind, and tracy. These tools cover almost all possible cases. Sadly, that’s not true for Apple Silicon Macs:

Samply is a sampling profiler that collects stack traces, per thread, at a specified sampling interval (default: 1ms or 1000Hz). Both on- and off-CPU samples are collected.

It’s not a joke - it’s the Performance Optimizer Observation Platform, shortened to poop. This tool was created by Andrew Kelley to compare performance based on hardware counters. The upstream version doesn’t support macOS as it relies fully on perf. There is a PR that adds support for macOS, including Apple Silicon. Since the PR hasn’t been merged yet, and its build fails, you can use this fork. Under the hood, it uses Apple’s private framework kperf.

Leave a Comment
Related Posts