Xcode Instruments + Metal System Trace — Apple's Nsight equivalent
On Apple Silicon, the profiling tools are part of Xcode rather than a separate download. The relevant instruments:
- Metal System Trace — timeline of command buffers, encoder activity, and CPU/GPU sync.
- Metal GPU Counters — per-kernel hardware counters, the equivalent of Nsight's metrics.
- GPU Performance Counters — lower-level shader debug, useful for hand-rolled kernels.
Real captured numbers from MPSMatrixMultiplication on M3 Ultra (FP32, 4096³):
| Counter | BLAS (avg) | BLAS (max) | Custom hand-rolled (max) |
|---|---|---|---|
| F32 Utilization | 0.679 | 93.9% | 35.1% |
| ALU Utilization | 0.613 | 63.3% | 44.2% |
| Last Level Cache Util | 0.466 | 56.3% | 14.2% |
| GPU Bandwidth (GB/s) | 13.0 | 978.5 | 695.6 |
| Total Occupancy | 1.51 | 100% | 95.1% |
Read this side-by-side: BLAS delivers 3.9× higher F32 utilization, 2.7× better ALU utilization, and 3.1× better cache utilization compared to a hand-rolled kernel of similar quality. Same hardware, dramatically different efficiency. The gap is the five pillars from lesson 1, again.
What to capture for a useful Apple-side profile
- Run the workload twice — once with command-buffer Trace, once with GPU Counters. Don't try to mix.
- Pin frequency: Activity Monitor → Window → GPU History to confirm the GPU is running at boost clock during capture.
- Capture multiple frames; the first frame always pays compile / first-load cost.
- Compare 'avg' and 'max' counter values — the gap tells you about scheduling stability.