# Chessnix (04) the 0.16 performance drama

**URL:** <https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206>\
**Category:** Explain\
**Tags:** zig-0-16\
**Created:** [April 27, 2026, 9:18pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206 "2026-04-27T21:18:01Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 27, 2026, 9:18pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/1 "2026-04-27T21:18:01Z")

</div>

No questions. Just a message.  
I got chessnix compiling for 0.16 and it is exactly twice as slow.  
Drama… I resign.

Edit: Anyone who can port my code to 0.16 with the same speed will get eternal glory 🙂

---

<div class="post-metadata">

**Author:** ![andrewrk](https://ziggit.dev/user_avatar/ziggit.dev/andrewrk/32/7011_2.png) [@andrewrk](https://ziggit.dev/u/andrewrk)\
**Post date:** [April 27, 2026, 9:19pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/2 "2026-04-27T21:19:14Z")

</div>

What have you been doing to measure performance until now? Do those tool(s) provide any insight as to what is different?

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 27, 2026, 9:23pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/3 "2026-04-27T21:23:31Z")

</div>

I have a simple benchmark getting many millions of positions and measuring the time that costs.

With 0.15.2 that is:

```zig
Total nodes: 18999768562 13.780s 1378.7580 Mnodes/s (1.378.758.004)

```

With 0.16.0 it takes double the time. (670 Mnodes/s).

Not a _real_ benchmark but enough indication something went terribly wrong (with just a few little changes actually in the source).

It took me ages to get it fast… now I am sad.

---

<div class="post-metadata">

**Author:** ![andrewrk](https://ziggit.dev/user_avatar/ziggit.dev/andrewrk/32/7011_2.png) [@andrewrk](https://ziggit.dev/u/andrewrk)\
**Post date:** [April 27, 2026, 9:26pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/4 "2026-04-27T21:26:55Z")

</div>

Looks like the next step for you is to invest into learning additional performance measurement tools and techniques. Not only will such things potentially shed light on what happened across Zig versions, but likely there are other optimization opportunities to claim, once you find out where those bottlenecks are. These skills will continue to serve you not only for this project but for your entire career.

Here’s a picture I have hanging on the wall in my office to inspire you:

 ![debugging-manifesto](https://ziggit.dev/uploads/default/original/2X/d/d7b9abe2b9fde6a3aec6bb350ea37edb9c6d4704.jpeg)

---

<div class="post-metadata">

**Author:** ![Kass](https://ziggit.dev/user_avatar/ziggit.dev/kass/32/6557_2.png) [@Kass](https://ziggit.dev/u/Kass)\
**Post date:** [April 27, 2026, 9:49pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/5 "2026-04-27T21:49:51Z")

</div>

Eric, please. The first rule of ~~nerd sniping~~ asking for help with profiling code is you have to provide a one-liner we can all easily run.

Both

```zig
❯ nix run nixpkgs#zig build run

```

and

```zig
❯ nix run nixpkgs#zig_0_15 build run

```

result in compile errors for me on a freshly cloned `ericlangedijk/chessnix` repo (because `mtg` is missing from `time.TimeManager`.

Can you please provide the hash of the most recent known-to-compile commit, and also the exact command to run to clock the program? Is it just running the main exe and typing `bench` in the CLI prompt? Or one of the `perft`/`qperft`commands, and if so, with which argument?

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 27, 2026, 10:24pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/6 "2026-04-27T22:24:07Z")

</div>

That error i solved (hour ago). just forgot one file update. it should compile for 0.15.2.  
The last commit is the newest actual version.  
And the command in the terminal is “bench”, which executes 4 perfts.

Edit: I don’t know what nerd-sniping is. But I added that line out of total despair 🙂  
As written: it took me _ages_ to get it fast, by trial and error. And I am noob in many fields. I am not able to look at 1.5 km of assembly and find out what is going on,

---

<div class="post-metadata">

**Author:** ![Kass](https://ziggit.dev/user_avatar/ziggit.dev/kass/32/6557_2.png) [@Kass](https://ziggit.dev/u/Kass)\
**Post date:** [April 27, 2026, 10:55pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/7 "2026-04-27T22:55:34Z")

</div>

Ok ok, thank you, the current version at the time of this comment is `7153bf06` and it indeed compiles with Zig 0.15.2! But also not with any other version:

 ![image](https://ziggit.dev/uploads/default/original/2X/c/cbeb1c8d45b43d7077ec0070460ea994d87b69bf.png)

But that’s ok, because we smort. And can remove the check.

Also, sorry, the term “nerd sniping” is a reference from a [webcomic](https://xkcd.com/356/) that old people like. It basically means posing a puzzle to people who, when in presence of puzzles, go “Oh, I think I might solve this!”

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 27, 2026, 11:21pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/8 "2026-04-27T23:21:32Z")

</div>

yes, it will not compile with 0.14.x.  
0.15.0 i don’t know.  
0.16.0 not at all. Because of Io and timer stuff.

---

<div class="post-metadata">

**Author:** ![Kass](https://ziggit.dev/user_avatar/ziggit.dev/kass/32/6557_2.png) [@Kass](https://ziggit.dev/u/Kass)\
**Post date:** [April 27, 2026, 11:27pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/9 "2026-04-27T23:27:29Z")

</div>

No worries!! Just wondering since you mentioned a performance degradation with Zig 0.16 in the OP, is the latest commit on GitHub what you were testing with? Because any additional changes to the code to get it to compile might have had an impact.

---

<div class="post-metadata">

**Author:** ![npc1054657282](https://ziggit.dev/user_avatar/ziggit.dev/npc1054657282/32/5790_2.png) [@npc1054657282](https://ziggit.dev/u/npc1054657282)\
**Post date:** [April 28, 2026, 2:39am UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/10 "2026-04-28T02:39:38Z")

</div>

I haven’t studied it carefully, but considering that [due to an upstream LLVM bug Zig 0.16 had to disable loop vectorization](https://ziglang.org/download/0.16.0/release-notes.html#Loop-Vectorization-Disabled-to-Work-Around-Regression), it is predictable that some performance regressions would occur.

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 28, 2026, 6:02am UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/11 "2026-04-28T06:02:41Z")

</div>

No changes! The current situation is the exact situation here at my home.

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 28, 2026, 6:04am UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/12 "2026-04-28T06:04:40Z")

</div>

Ouch ok… My expectations were set on “it will be faster” because of array access. So I will have to skip a zig version or 2

---

<div class="post-metadata">

**Author:** ![IntegratedQuantum](https://ziggit.dev/user_avatar/ziggit.dev/integratedquantum/32/782_2.png) [@IntegratedQuantum](https://ziggit.dev/u/IntegratedQuantum)\
**Post date:** [April 28, 2026, 5:38pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/13 "2026-04-28T17:38:44Z")

</div>

I just saw that [parameter reference optimization was removed in 0.16.0](https://github.com/ziglang/zig/issues/5973#issuecomment-4334852241), could this affect you?

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 28, 2026, 6:47pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/14 "2026-04-28T18:47:05Z")

</div>

Well… I think hardly or not at all. Structs bigger than 8 bytes I pass by  
`*Ref` and if readonly `*const Ref`. (I was prepared for this one).

I guess the non-vectorized loops are the main thing. I have quite some little inline loops.

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 28, 2026, 7:12pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/15 "2026-04-28T19:12:16Z")

</div>

Thank you Andrew.

**1. inspect, don’t squash**  
I am uncapable of reviewing kilometers of assembly output. I try this and try that and measure time.

**2. being stuck is temporary**  
Yes.

**3. trust nobody \* nothing**  
That’s the main thing. I trust the compiler or otherwise work around it.  
[example](https://github.com/ericlangedijk/chessnix/blob/893b16b1be0143a5a4a02e1c6d9de562a89d754a/src/position.zig#L1557)  
Would you ever have thought this was possible? Not me. By pure coincidence I discovered this.

With a chess engine every squeezed out microsecond gives a bit of playing-strength.  
Then things change in Zig and it’s gone. But I chose myself for this.  
chessnix with zig 0.16.0 loses big time from chessnix 0.15.2.

**4. it’s probably your code**  
Of course.

**6. there’s always a reason**  
Agree.

**7. build your toolkit**  
Chess programming is insane. The engine itself takes so much testing. But yes i need to do that. and 1 extra lifetime.

**8. it can be an adventure**  
It certainly is. and despite this fallback, I am a big zig-fan. waiting for 0.18.0.

---

<div class="post-metadata">

**Author:** ![IntegratedQuantum](https://ziggit.dev/user_avatar/ziggit.dev/integratedquantum/32/782_2.png) [@IntegratedQuantum](https://ziggit.dev/u/IntegratedQuantum)\
**Post date:** [April 28, 2026, 7:33pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/16 "2026-04-28T19:33:49Z")

</div>

Have you tried running it in a profiler? If it’s at least somewhat localized you should be getting a more precise location than “kilometers of assembly output”

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [April 28, 2026, 9:15pm UTC](https://ziggit.dev/t/chessnix-04-the-0-16-performance-drama/15206/17 "2026-04-28T21:15:50Z")

</div>

I did that once or twice. With a profiler of visual studio. Most of the time (for movegenerattion) was spent in…  
`fn gen_anon_xxx` 🙂  
I did not profile with the search engine.  
The problem was - for me - that I could not find anything useful in the list of functions and times used. No bottlenecks either.

(edit: btw. i did not profile the 0.16 version at all. later on i will maybe try and find out what is going on)
