Watching BLAKE3 run

On Tuesday, 15 September 2026, at a quarter past three in the afternoon, I sat down in Colorado B at CppCon to hear Jody Hagins talk about writing C++ with AI. My own talk was at nine the next morning.

My slides had a couple of static illustrations of BLAKE3, but I really wanted something interactive for my audience. Fable 5.1 had come out two weeks earlier, and I had not given it anything real to do yet. Four prompts later, the demo below existed, written by an AI while Jody was on stage explaining how to get LLMs to write actually good software in C++.

One statement at a time

BLAKE3 cuts its input into 1 KiB chunks, hashes each chunk on its own, and combines the results pairwise up a binary tree. All the work happens in one function, compress(), which mixes a 64-byte block into a state of sixteen 32-bit words. This view runs it one statement at a time.

  • The state is the 4×4 grid. The first two rows hold the chaining value coming in, the third the start of the initialisation vector, the fourth the counter, the block length and the flags.
  • The message is the strip of sixteen words from the block being compressed. The two that the current step reads light up.
  • The source is blake3pp's scalar kernel, src/kernel/kernel.cpp: compress(), the round it is in, and g(), which mixes four state words at a time. The line that is running is highlighted, and its four words are marked a, b, c and d in the grid.
  • The tree fills in as chunks are compressed. A finished chunk shows its chaining value; two finished siblings start their parent. The digest arrives last, because it is the root's chaining value.

Type a message and press run, or step with ‹ and ›. next g() jumps to the next call of the mixing function, which is the unit worth following, and clicking a node in the tree jumps to the compression that produces it.

The walk runs in your browser and needs JavaScript.

A few things to look for:

  • With abc, the last word of the state starts as 0000000b: the flags for chunk start, chunk end and root, all at once, because a three-byte message is one block, one chunk and the whole tree.
  • With three chunks (2500 bytes), the counter word steps from 0 to 1 to 2 as the walk moves from chunk to chunk, and the root flag waits for the very last compression, the parent at the top.
  • In every round, each of the sixteen message words is read exactly once, in a different order each time.

Four prompts

I no longer have the prompts. They were four short requests typed during a talk, and none of them was clever. What came back is more interesting.

The slides are a web page: reveal.js on Vite, with the whole talk in one Markdown file. A slide that runs something holds an empty placeholder, and a small script mounts a Vue 3 component into it. By that afternoon the deck had several, among them blake3pp compiled to WebAssembly and hashing in the browser, buttons that ran the native binaries on the laptop through a small Node server, and a microcontroller board answering over Web Serial. A walk through the algorithm was one more component.

The first prompt asked for the view every C++ developer has grown used to: source on one side, the machine's instructions on the other, the way Compiler Explorer shows them. It came back working, and it showed me why that was the wrong level for a talk. The assembly was long, and it said less than the code it came from.

The second prompt asked for C++ instead: the actual lines of the scalar kernel, highlighted as they run. That is shorter and easier to read, and it is the code the talk was about anyway.

The third prompt added the tree: a progress bar on every chunk, and a highlight on every write, so each statement lands visibly in the state and each chunk visibly fills up.

The fourth prompt asked for the SIMD version. The model thought about it for about fifteen minutes, and then it was done.

One instruction, every lane

A SIMD kernel hashes 4, 8 or 16 chunks at once, one per lane of a vector register. That only works because the sequence of statements in compress() does not depend on the data: in every one of the 473 steps of a compression, every lane runs the same line and writes the same state word. Only the values differ.

So this view draws the lanes as rows and the state words as columns, and the highlight is a column: one instruction crossing every lane at once. The tree outlines all the chunks in flight. Pick 4, 8 or 16 lanes and press run.

The lanes run in your browser and need JavaScript.

The ✓ next to "every lane on the same line, same word" is not decoration. The view compares the traces of all lanes in the batch it shows, and only then claims they ran in lockstep.

Reading the code afterwards

That evening I read what the model had written. I had asked for a demo, and I expected demo code. A few of its decisions were better than that.

The numbers do not come from blake3pp itself. They come from a BLAKE3 implementation in JavaScript that follows kernel.cpp statement by statement, written to be watched rather than to be fast. Every step it records names the line it ran, the state words it read and the one it wrote. That is what lets the view highlight a line of C++ while JavaScript does the arithmetic.

Every step also carries the whole state. A trace is a flat list of steps, each with all sixteen words, so stepping backwards is a lookup, not a replay. At 473 steps per compression, the memory that costs is nothing.

What the view shows is computed from two numbers: which compression, and which step inside it. The grid, the highlighted line, each node's progress and the digest all follow from those. Restarting is setting both to zero, and there is no separate animation state to clean up.

And it checks itself. On every load the JavaScript hashes three inputs and compares the digests with the ones blake3pp computes. If they ever differ, the view says so in red.

It has one weak spot, and it is a very human one: the C++ lines on screen are copied into the page by hand. The self-test checks the digests, not the text, so if kernel.cpp changes, nothing notices that the displayed source no longer matches. A smaller simplification: the SIMD view runs all parent merges after the chunks, while the library merges as it goes. That changes the order, not the result.

The next morning

I was in Red Rock 8/9 half an hour before my nine o'clock slot on Wednesday, which turned out to be half an hour of troubleshooting. The AV setup refused to sync with my laptop, and my backup setup on the second laptop failed as well. So I ran back to my room to grab my third laptop (no joke). I had not planned on needing a second backup, so that one was not set up for the talk: the first fifteen minutes of the talk went into cloning the talk project and rebuilding its Docker container, while I talked without slides.

The deck came back up pretty much exactly at the point in the talk where the interactive demo was supposed to happen. So I ran it, and it went through without a hiccup.

Afterwards, a number of people told me the demo was what made it click for them: how the algorithm works, and why it fits SIMD and multiple threads so well.

If you want to take the two views apart, or put them in front of your own audience, their source is in web/visualization/ of the blake3pp repository, under the same license as the library.

Comments

Loading comments…