Xcode Instruments + Metal System Trace — Apple의 Nsight equivalent
Apple Silicon에선 프로파일링 도구가 별도 다운로드 아니라 Xcode 일부. 관련 instrument:
- Metal System Trace — command buffer, encoder activity, CPU/GPU sync의 timeline.
- Metal GPU Counters — per-kernel 하드웨어 counter, Nsight metric의 equivalent.
- GPU Performance Counters — 더 낮은 레벨 shader debug, 손코딩 커널에 유용.
M3 Ultra의 MPSMatrixMultiplication에서 캡처한 실제 숫자 (FP32, 4096³):
| Counter | BLAS (avg) | BLAS (max) | 손코딩 Custom (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% |
나란히 읽기: BLAS가 비슷한 품질의 손코딩 커널 대비 F32 utilization 3.9× 높고, ALU utilization 2.7× 좋고, cache utilization 3.1× 좋음. 같은 하드웨어, 극적으로 다른 효율. 격차가 lesson 1의 다섯 기둥, 다시.
유용한 Apple-side 프로파일에 캡처할 거
- 워크로드 두 번 돌리기 — command-buffer Trace 한 번, GPU Counter 한 번. 섞으려고 하지 마.
- Frequency 핀: Activity Monitor → Window → GPU History로 캡처 동안 GPU가 boost clock으로 도는지 확인.
- 여러 frame 캡처; 첫 frame은 항상 compile / first-load 비용.
- 'avg'랑 'max' counter 값 비교 — 격차가 스케줄링 안정성 알려줌.