[{"data":1,"prerenderedAt":598},["ShallowReactive",2],{"copyright-first-year":3,"\u002Fblog\u002Ffive-weeks-to-cppcon":4,"\u002Fblog\u002Ffive-weeks-to-cppcon:projects":569,"\u002Fblog\u002Ffive-weeks-to-cppcon:related":572,"project-titles":597},2026,{"id":5,"title":6,"body":7,"category":552,"codeLicense":553,"date":554,"description":16,"extension":555,"meta":556,"navigation":557,"path":558,"projects":559,"readingTime":560,"seo":561,"stem":562,"tags":563,"__hash__":568},"blog\u002Fblog\u002F20261115.five-weeks-to-cppcon\u002Findex.md","Five weeks to CppCon",{"type":8,"value":9,"toc":537},"minimark",[10,17,22,25,59,62,77,84,88,99,106,109,115,124,127,131,134,165,169,172,175,226,230,233,236,239,243,246,249,252,255,259,262,267,270,273,281,320,323,334,338,348,386,390,393,443,447,450,530,533],[11,12,13],"p",{},[14,15,16],"em",{},"An intro to the blog series about blake3pp, my C++ implementation of the BLAKE3 hash function: where it came from, what the series is about, and the vocabulary the later parts use.",[18,19,21],"h2",{"id":20},"an-empty-function-2022","An empty function, 2022",[11,23,24],{},"Back in May 2022 I spent a weekend writing a BLAKE3 implementation in C++. It was scalar, it passed the four test vectors I had generated with the reference C implementation, and on my laptop it hashed about 780 MB\u002Fs. It also contained this hopeful comment:",[26,27,32],"pre",{"className":28,"code":29,"language":30,"meta":31,"style":31},"language-cpp shiki shiki-themes github-light github-dark","\u002F\u002F SIMD things...\nvoid compress_simd() { }\n","cpp","",[33,34,35,44],"code",{"__ignoreMap":31},[36,37,40],"span",{"class":38,"line":39},"line",1,[36,41,43],{"class":42},"sJ8bj","\u002F\u002F SIMD things...\n",[36,45,47,51,55],{"class":38,"line":46},2,[36,48,50],{"class":49},"szBVR","void",[36,52,54],{"class":53},"sScJk"," compress_simd",[36,56,58],{"class":57},"sVt8B","() { }\n",[11,60,61],{},"That was the plan, in its entirety. I wanted to use MIPP, a portable intrinsics wrapper that I found quite elegant. It never happened. Back then I was busy building tipi.build, the company I co-founded, and its source scan engine choked on parts of MIPP. That stopped my weekend project dead.",[11,63,64,65,68,69,72,73,76],{},"Other things took over. My quick-and-dirty BLAKE3 implementation stayed pretty much untouched for four years. The repository sat on that same laptop, with its empty ",[33,66,67],{},"README.md",", a zero-byte file called ",[33,70,71],{},"HellO"," (fast-typing typo included) and that empty ",[33,74,75],{},"compress_simd"," function.",[11,78,79,80,83],{},"The idea never really went away, though. BLAKE3 belongs to a family of cryptographic designs I like (the ChaCha and Salsa20 lineage), where the algorithm's structure ",[14,81,82],{},"invites"," a fast implementation instead of fighting it.",[18,85,87],{"id":86},"the-excuse-2026","The excuse, 2026",[11,89,90,91,94,95,98],{},"By 2026, the parts of C++ I would have needed in 2022 were not just papers anymore: ",[33,92,93],{},"std::execution"," (senders and receivers, P2300) is in C++26, and so is ",[33,96,97],{},"std::simd",". Compilers ship partial versions of both, and there are good libraries standing in where they don't.",[11,100,101,102,105],{},"I wanted to learn both beyond reading the proposals, and the most reliable way I know to make time for something is to promise a conference audience that it will exist. So I submitted a CppCon talk. The abstract said, among other things, that PCIe 5 drives can push 10 GB\u002Fs and that you ",[14,103,104],{},"can"," hash at that speed in portable C++26 without giving up clean architecture.",[11,107,108],{},"I want to be honest about that last sentence: when I wrote it, there was not a single measurement behind it. There was the knowledge that the Rust implementation proves the computing side can go that fast, and a strong opinion that this should be doable with the shiny new libraries in C++26.",[11,110,111],{},[112,113,114],"strong",{},"Then the talk was accepted.",[11,116,117],{},[14,118,119,120,123],{},"And ",[112,121,122],{},"then"," life happened.",[11,125,126],{},"The first commit of the new repository is dated 15 August 2026, about five weeks before my talk at CppCon.",[18,128,130],{"id":129},"the-rules","The rules",[11,132,133],{},"When I finally got to write the first bits of code, I set myself four rules, so that a talk about \"clean and fast\" would not fall apart under deadline pressure:",[135,136,137,144,153,159],"ol",{},[138,139,140,143],"li",{},[112,141,142],{},"One binary, every instruction set."," For each CPU architecture (x86-64, ARM64, RISC-V, ...) the library is compiled once per SIMD instruction set it supports, all into the same binary, and picks the best one for the machine it finds itself on, at run time.",[138,145,146,152],{},[112,147,148,149,151],{},"Threads through ",[33,150,93],{},"."," No hand-rolled thread pool API in the library. Parallel work is a sender.",[138,154,155,158],{},[112,156,157],{},"The fastest I\u002FO each operating system has."," io_uring on Linux, I\u002FO completion ports on Windows, and so on, with a fallback for when the fast path is not available.",[138,160,161,164],{},[112,162,163],{},"The run-time choice is free."," Picking the instruction set at run time costs nothing measurable in the hot path.",[18,166,168],{"id":167},"five-weeks-a-lot-of-machines","Five weeks, a lot of machines",[11,170,171],{},"What followed was five weeks of the kind of engineering that is mostly getting things to build, and then finding out what you actually built by running it on hardware you didn't expect to own an opinion about.",[11,173,174],{},"Some highlights, in no order of importance:",[176,177,178,188,194,200,210,216],"ul",{},[138,179,180,183,184,187],{},[112,181,182],{},"A phone."," The first phone in the test matrix, my Galaxy S26, came back with the ARM kernel (the SIMD code for ARM) running at 79% of the speed of the C reference (the official BLAKE3 implementation), way out of line with every other ARM core I had tested by then. The kernel was fine; the comparison wasn't. The benchmark ran the reference last, and after thirty seconds of load the scheduler had worked out that the phone's one really fast core was the one to use. Pinned to that core with ",[33,185,186],{},"taskset",", the kernel ran at 100%.",[138,189,190,193],{},[112,191,192],{},"Big-endian."," IBM's POWER and z machines joined the list of supported architectures one late night, because \"why not?\". With a one-line source change to the kernel, they produced the same digests under emulation as x86, including on big-endian s390x.",[138,195,196,199],{},[112,197,198],{},"Three RISC-V boards",", one per flavour of vector extension, each picking the right kernel on its own silicon. On one of them the library was 2.1 times faster than the C reference, which has no vectorized RISC-V kernel at all.",[138,201,202,205,206,209],{},[112,203,204],{},"A microcontroller."," At the small end, a Raspberry Pi Pico 2 with its RP2350 running Zephyr, in both of its personalities, Arm Cortex-M33 and Hazard3 RISC-V. No filesystem, no vector unit, and a standard library whose ",[33,207,208],{},"\u003Cthread>"," turned out to be empty.",[138,211,212,215],{},[112,213,214],{},"A Ryzen AI MAX+ 395",", where AVX-512 was mysteriously slow on Windows until it turned out the Windows power plan was clamping the clocks exactly when the 512-bit units light up. +72% from a power setting.",[138,217,218,221,222,225],{},[112,219,220],{},"The browser."," The library compiles to WebAssembly, where the SIMD build is 2.3 times faster than the Rust-compiled ",[33,223,224],{},"blake3-wasm"," package, and the threaded build pushes that lead to 11x.",[18,227,229],{"id":228},"_10-gbs-promised-43-delivered","10 GB\u002Fs, promised; 43 delivered",[11,231,232],{},"Shortly before the talk I rented a bare-metal server with four PCIe 5 drives in a stripe, the first machine I had that could actually test the abstract's claim.",[11,234,235],{},"The drives read at 57 GB\u002Fs. With hand-tuned settings, the library hashed at 43 GB\u002Fs from disk: more than four times the 10 I had promised without a single measurement.",[11,237,238],{},"The talk happened, and it went well after a really rocky start (fighting the A\u002FV equipment is no fun). Then the actual work started: tidying up the shortcuts I had taken to get there. That 43 GB\u002Fs needed settings tuned by hand for one machine, every operating system had its own way of reading a file, and more than one fallback failed without saying so.",[18,240,242],{"id":241},"what-this-series-is","What this series is",[11,244,245],{},"The talk showed what I could achieve in five weeks' worth of evenings, with all my AI subscriptions maxed out. What came after it was turning that into a library I am happy to put my name on: one I\u002FO layer instead of a pile of per-platform ones, kernels that caught up with the reference and passed it on long inputs, tools that behave like the Unix tools they replace, an API that settled, and a lot of measurements, some of which made fun of me.",[11,247,248],{},"Where possible I'll link to the merge commit that holds the work of each article, so you can check out any point of the story and run it.",[11,250,251],{},"Part 1 is about the trace tooling I built first to record where each window's time goes, because everything after it was decided by what it measured. Part 2 is the layer that reads those windows: one contract over every operating system's way of reading a file.",[11,253,254],{},"The rest of this post is reference material. Skim it now, or come back when a later part uses a word you don't know.",[18,256,258],{"id":257},"a-field-guide","A field guide",[11,260,261],{},"The later parts use a handful of words as if everyone knew them. Here they are, once, with the definitions the code uses.",[263,264,266],"h3",{"id":265},"blake3-in-one-picture","BLAKE3 in one picture",[11,268,269],{},"BLAKE3 is a cryptographic hash, the same kind of thing as SHA-256 or SHA-3: any amount of input, a fixed length fingerprint out, and no practical way to find two inputs with the same fingerprint.",[11,271,272],{},"Its shape is a tree:",[26,274,279],{"className":275,"code":277,"language":278},[276],"language-text","                        root\n                   \u002F            \\\n             parent              parent\n            \u002F      \\            \u002F      \\\n        chunk 0  chunk 1    chunk 2  chunk 3      (1 KiB each)\n","text",[33,280,277],{"__ignoreMap":31},[176,282,283,302,313],{},[138,284,285,286,289,290,293,294,297,298,301],{},"The input is cut into ",[112,287,288],{},"chunks"," of 1 KiB. Each chunk is hashed on its own, 64-byte ",[112,291,292],{},"block"," by block, by the ",[112,295,296],{},"compression function",", and comes out as a 32-byte ",[112,299,300],{},"chaining value"," (CV).",[138,303,304,305,308,309,312],{},"Two sibling CVs are combined into a ",[112,306,307],{},"parent"," node, which is compressed into a new CV. Parents pair up in turn until one node is left: the ",[112,310,311],{},"root",", which produces the hash.",[138,314,315,316,319],{},"A ",[112,317,318],{},"subtree"," is any complete part of that tree: a power-of-two run of chunks that reduces to one CV.",[11,321,322],{},"The important property: every chunk is independent of every other chunk. That is what makes the rest of this possible.",[11,324,325,326,329,330,333],{},"If you feed the hash a little at a time (a ",[112,327,328],{},"hasher"," with ",[33,331,332],{},"update()","), it keeps a stack of CVs for the subtrees it has finished so far, and merges them as they complete. One detail matters later: the root has to be marked as the root, so the hasher can't finish the last chunk until it knows the input has ended.",[263,335,337],{"id":336},"going-wide-simd","Going wide: SIMD",[11,339,340,341,344,345,347],{},"A modern CPU core can apply one instruction to several values at once: 4 32-bit words with SSE, 8 with AVX2, 16 with AVX-512. Those slots are ",[112,342,343],{},"lanes",". BLAKE3's compression function works on 32-bit words, so the obvious way to use lanes is to hash 4, 8 or 16 ",[14,346,288],{}," at once, one per lane.",[176,349,350,356,363,377],{},[138,351,315,352,355],{},[112,353,354],{},"kernel"," is the compression function written for a given number of lanes. blake3pp has one source for it, templated on the width, compiled once per instruction set: SSE4.2, AVX2, AVX-512, NEON, SVE, RISC-V vectors, and a few more.",[138,357,358,359,362],{},"The data is in the wrong shape for that kind of data processing though: a chunk's words sit next to each other in memory, but a lane wants word 0 of chunk 0 next to word 0 of chunk 1. Rearranging them is the job of the ",[112,360,361],{},"transpose"," function, and it is a significant cost of its own.",[138,364,365,368,369,372,373,376],{},[112,366,367],{},"Dispatch"," is picking the kernel at run time: the library asks the CPU what it supports and takes the ",[14,370,371],{},"widest"," kernel it has. A binary carrying all the kernels for its architecture (every x86-64 instruction set, say, or every ARM64 one) is a ",[112,374,375],{},"fat binary","; there is still one per architecture.",[138,378,315,379,382,383,385],{},[112,380,381],{},"SIMD provider"," is the library under the kernel's vector types: C++26 ",[33,384,97],{}," where the compiler has it, xsimd where it doesn't, and a couple of others. The kernel is written against a thin facade, so the provider is a build option, not a rewrite.",[263,387,389],{"id":388},"going-parallel-senders-pools-and-parts","Going parallel: senders, pools and parts",[11,391,392],{},"SIMD makes one core fast. The tree's independence also lets you use many of those concurrently.",[176,394,395,418,428,437],{},[138,396,315,397,400,401,403,404,407,408,410,411,414,415,151],{},[112,398,399],{},"sender"," (C++26 ",[33,402,93],{},") describes work without running it: \"on this scheduler, do this, then that\". You connect it to whatever receives the result and start it. An ",[112,405,406],{},"execution provider"," is the implementation of ",[33,409,93],{}," the build uses; in blake3pp, currently ",[33,412,413],{},"stdexec"," or ",[33,416,417],{},"beman.execution",[138,419,315,420,423,424,427],{},[112,421,422],{},"scheduler"," is where work runs. The one that matters here is a parallel scheduler backed by a ",[112,425,426],{},"pool",": a fixed set of threads waiting for work.",[138,429,430,433,434,151],{},[112,431,432],{},"bulk"," is the sender algorithm that runs the same function N times in parallel. Each of those runs, on its pool thread, is an ",[112,435,436],{},"agent",[138,438,315,439,442],{},[112,440,441],{},"part"," is a subtree of at least 16 chunks. A big input is split into parts, and the agents pull parts from a shared counter until none are left, so a slow thread simply takes fewer. Each part comes back as one CV, and the CVs are folded into the tree.",[263,444,446],{"id":445},"reading-a-file-windows-and-engines","Reading a file: windows and engines",[11,448,449],{},"Hashing in memory is a problem of compute alone. Hashing a file is a problem of the whole machine: the drive, the kernel, the memory and the cores all have to keep up with each other.",[176,451,452,462,469,478,496,503,513,519],{},[138,453,315,454,457,458,461],{},[112,455,456],{},"window"," is a fixed-size slice of the file (8 MiB by default in ",[33,459,460],{},"blake3pp","), read into memory and hashed as one subtree. The file is processed as a sequence of windows.",[138,463,464,465,468],{},"The ",[112,466,467],{},"queue depth"," is how many reads are outstanding at once, so the drive always has work while the CPU hashes.",[138,470,464,471,474,475,477],{},[112,472,473],{},"arena"," is the block of memory the windows live in, ",[33,476,460],{}," allocates it once.",[138,479,480,483,484,487,488,491,492,495],{},[112,481,482],{},"Direct I\u002FO"," (",[33,485,486],{},"O_DIRECT"," on Linux, ",[33,489,490],{},"FILE_FLAG_NO_BUFFERING"," on Windows) reads straight from the device into the arena, skipping the operating system's ",[112,493,494],{},"page cache",". It is faster for a big file read once, and it comes with rules: buffers, offsets and lengths must be multiples of 4 KiB.",[138,497,498,499,502],{},"An ",[112,500,501],{},"engine"," is the operating system's asynchronous I\u002FO mechanism: io_uring on Linux, I\u002FO completion ports on Windows, Grand Central Dispatch on macOS, and plain synchronous reads everywhere else. More engines join later in the series.",[138,504,464,505,508,509,512],{},[112,506,507],{},"ladder"," is the sequence of fallbacks when the fast path isn't available: no io_uring, no direct I\u002FO for this file system, a length that isn't a multiple of 4 KiB. Each ",[112,510,511],{},"rung"," is a slower, more general way to read, and the library always says which rung a file ended up on.",[138,514,464,515,518],{},[112,516,517],{},"driver"," is the code (and the thread) that issues the reads, hands windows to the pool and collects them again.",[138,520,521,522,525,526,529],{},"I call the rate at which the device reads with no hashing at all ",[112,523,524],{},"raw",". It is the ceiling: a run at 100% of raw is ",[112,527,528],{},"device-bound",", and anything else is waiting on some piece of code I wrote.",[11,531,532],{},"See you in Part 1.",[534,535,536],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":31,"searchDepth":46,"depth":46,"links":538},[539,540,541,542,543,544,545],{"id":20,"depth":46,"text":21},{"id":86,"depth":46,"text":87},{"id":129,"depth":46,"text":130},{"id":167,"depth":46,"text":168},{"id":228,"depth":46,"text":229},{"id":241,"depth":46,"text":242},{"id":257,"depth":46,"text":258,"children":546},[547,549,550,551],{"id":265,"depth":548,"text":266},3,{"id":336,"depth":548,"text":337},{"id":388,"depth":548,"text":389},{"id":445,"depth":548,"text":446},"blake3pp, one merge at a time","Apache-2.0 WITH LLVM-exception","2026-11-15","md",{},true,"\u002Fblog\u002Ffive-weeks-to-cppcon",[460],11,{"title":6,"description":16},"blog\u002F20261115.five-weeks-to-cppcon\u002Findex",[30,564,565,566,567],"blake3","simd","std-execution","cppcon","xrMy_fAEgnjiyuGMWy1gKpJb3CTks9PkSQnas8iUgNM",[570],{"path":571,"title":460},"\u002Fprojects\u002Fblake3pp",[573,584,587],{"path":574,"title":575,"description":576,"date":577,"readingTime":578,"category":579,"projects":580,"tags":581},"\u002Fblog\u002Fwatching-blake3-run","Watching BLAKE3 run","An interactive walk through BLAKE3, built with an AI coding agent while I sat in a CppCon talk about writing C++ with AI: the C++ kernel executing statement by statement, the tree filling in, and the same walk sixteen lanes wide.","2026-11-28",7,"Making of",[460],[30,564,565,582,567,583],"ai","visualization",{"path":558,"title":6,"description":16,"date":554,"readingTime":560,"category":552,"projects":585,"tags":586},[460],[30,564,565,566,567],{"path":588,"title":589,"description":590,"date":591,"readingTime":39,"category":592,"projects":593,"tags":595},"\u002Fblog\u002Fhello-world","Hello World","Hello, world, I say...","2026-11-09","Meta",[594],"bytetastic",[596],"meta",{"blake3pp":460,"bytetastic":594},1795879063279]