From the README:
(It's not entirely clear why the Zig baseline implementation is twice as fast as the Rust implementation. The compiled assembly (godbolt) show that Rust saves five registers on the stack while Zig only saves three, but why? For the purpose of this benchmark it shouldn't matter since we're only comparing against the baseline of each language.)
The difference is that the linked Zig program produces an internal LLVM function, which can call itself directly, while the Rust program produces a non-internal LLVM function, which calls itself through the GOT. If you mark the Rust function non-pub and call it from a pub function (like the Zig main), you will get essentially the same assembly: https://godbolt.org/z/x73v9zKb9
From the README:
The difference is that the linked Zig program produces an
internalLLVM function, which can call itself directly, while the Rust program produces a non-internalLLVM function, which calls itself through the GOT. If you mark the Rust function non-puband call it from apubfunction (like the Zigmain), you will get essentially the same assembly: https://godbolt.org/z/x73v9zKb9