Rust vs Zig Compilation Time

13th July 2026

I thought Bun’s controversial rewrite from Zig to Rust would be an ideal benchmark for compilation time. Unfortunately neither Anthropic nor Andrew Kelly seem to want to benchmark both, so I have done a quick test.

My hardware is has an AMD Ryzen 9 3950X 16-Core CPU at 3.5 GHz, with 128 GB of RAM (DDR4). This was top of the line about 5 years ago, and is still a powerful machine (no more Moore’s law) but it was very cheap second hand (~£300).

Zig

Bun has a quite complex build system so to get just the Zig times, I built it first (b8ecc78b03c998c228be4520bb8d2f888624e4a1 just before the Rust rewrite) using bun run build, then deleted build/debug/cache/zig and build/debug/bun-zig.*.o, then ran time bun run build.

I’m not too familiar with Zig but this seemed to cause it to do a complete rebuild.

Total real time: 39.1s.

This is a lot slower than Andrew Kelly’s claim of 16s. Maybe he has an enormous machine?

Rust

For Rust (23427dbc12fdcff30c23a96a3d6a66d62fdc091d just after the Rust rewrite) you still build with bun run build, so I did that, and then deleted build/debug/rust-target, which is sufficient to cause a complete Rust rebuild. time bun run build reports

Total real time 1m33s.

Incremental?

What about incremental compilation time? I don’t know how to enable incremental builds in Zig so I’ll take Andrew Kelly’s word that it’s super fast (he claimed 90ms).

For Rust I edited src/runtime/lib.rs (seemed like a reasonable typical case) and this gave a build time of 21.8s. Definitely significantly worse. Although it does seem like Rust only actually takes 10.0s and does some other stuff for 11s, not sure what is going on there.

...
  Compiling bun_bin v0.0.0 (/home/tim/d1/bun/src/bun_bin)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 10.02s
[2/4] link bun-debug
[3/4] bun-debug --revision
1.3.14-debug+23427dbc1
[build] done

real    0m21.487s
user    0m39.053s
sys     0m9.560s

So for clean builds Zig has a way smaller compile time advantage over Rust than I expected, but it looks like for incremental builds Rust still has a way to go.