Tech News
← Back to articles

Zig Profiling on Apple Silicon

read original related products more articles

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.

Okay, it’s not that bad, but we’re far away from the rich ecosystem of profiling tools available on Linux.

Note:

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.

We focus only on these types of profilers:

CPU time profilers: Statistical (timer-based) sampling: periodically samples stacks to estimate where time is spent. Hardware event–based sampling (PMU): samples on counter overflows (cycles, cache-misses, branches) to attribute microarchitectural stalls.

Instrumentation profilers: insert probes at function entry/exit or around code regions to mark scopes.

There are many other types of profilers, like memory profilers, network profilers, etc., but we won’t cover them here.

Many profilers combine methods from both categories.

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

... continue reading