GeistHaus
log in · sign up

Why does an extraneous build step make my Zig app 10x faster?

mtlynch.io

For the past few months, I’ve been curious about two technologies: the Zig programming language and Ethereum cryptocurrency. To learn more about both, I’ve been using Zig to write a bytecode interpreter for the Ethereum Virtual Machine. Zig is a great language for performance optimization, as it gives you fine-grained control over memory and control flow. To motivate myself, I’ve been benchmarking my Ethereum implementation against the official Go implementation.

2 pages link to this URL
Zig build run is 10x faster than compiled binary?

I’m running into strange behavior with zig build run, and I’m hoping others might help explain what’s happening. I have a simple Zig app that I can run with zig build run. But if I run the compiled binary afterwards, the performance is 10x worse than with zig build run. src/main.zig const std = @import("std"); pub fn countBytes(reader: anytype) !u32 { var count: u32 = 0; while (true) { _ = reader.readByte() catch |err| switch (err) { error.EndOfStream => { ...

2 inbound links website en build-system