Zig Profiling on Apple Silicon

  • Mostly unrelated, but I recently built a small utility in Zig, Hare, Go, Odin, and V.

    I never completed the Odin / V implementations since their standard libraries didn't have argon2 (a requirement for me).

    Of the group, I liked Odin's syntax and feel best. Hare was also very nice. But Zig's optimized binary sizes were unbeatable. 96KB vs 500KB for Hare and 2.5MB for Go.

    Zig's standard library and tooling are impressive. Personally, I wish more projects were written in Zig instead of Rust since Zig doesn't seem to have the package explosion problem that Rust has.

  • Just use Instruments. Yes, I know it’s slow, but it’s miles ahead of anything on Linux. If you’re looking for an identical profiling experience on macOS as you get on Linux you’re greatly missing out.

  • For low-overhead Zig profiling on Apple Silicon, you can also use DTrace with the pid provider to sample stacks without modifying your code or relying on Instruments' UI.

  • This is cool! I'm anxious to dig into Zig on an M1, and this helps.

    Side note, the CSS is broken for me in Safari—I get this error:

      Cannot load stylesheet https://blog.bugsiki.dev/assets/css/stylesheet.b609c58d5c11bb90b1a54e04005d74ad1ddf22165eb79f5533967e57df9c3b50.css. Failed integrity metadata check. Content length: 4943, Expected content length: -1, Expected metadata: sha256-tgnFjVwRu5CxpU4EAF10rR3fIhZet59VM5Z+V9+cO1A=