Posts

The Regex Monster Revisited: a Lazy DFA for Go's regexp

Last February I wrote about taming a regex monster : an alternation of a hundred 8-letter literals from a Gophers Slack discussion. The DFA of modernc.org/regexp matched it about 28x faster than the standard library. The catches were a compile tax of about 200x, and a hand-written proof-of-concept VM around NewMatchDFA , because the DFA choked on the .* s around the literals and had to be fed the bare alternation. Rob Pike pointed out that a list of literals is a job for Aho-Corasick, not for regular expressions, and he was right. Since then the DFA has been rewritten, and the tax is gone. Since v1.10.0 the package runs a lazy DFA, in the style of RE2’s and of Rust’s regex-automata, behind the ordinary Regexp API. v1.11.2 is the current release. This post revisits the monster, sketches how the DFA works, and lists what I learned on the way. Some of the lessons were embarrassing. The monster, revisited Same pattern, same inputs, plain regexp.MustCompile and MatchString . One CPU...

What the GitHub Secure Open Source Fund changed in modernc.org/sqlite

GitHub has published a post today that ends with the list of all alumni of its Secure Open Source Fund . modernc.org/sqlite is one of them: it took part in Session 5, three weeks of security training for maintainers, from 14 September to 1 October 2026. This post is about what came out of it for people who use the module, and for anyone maintaining something like it. Why this project modernc.org/sqlite is SQLite without cgo. The C amalgamation is transpiled to Go by modernc.org/ccgo and the result is committed, for 20 GOOS/GOARCH targets. pkg.go.dev counts thousands of known importers, and many programs carry it without their authors knowing, as a transitive dependency. Until this spring it had one maintainer; now it has two. A widely used library, a small team and an unusual build are the case the fund exists for. If you use the module Reporting a vulnerability. SECURITY.md lists three private channels: private vulnerability reporting on the GitHub mirror, a confidenti...

p2-11, Part Two: Faster Than a Real PDP-11/40, With a Little PASM

Image
The first post about p2-11 ended with the same computer fifty years apart, and the new one running “at a quarter of the speed”. On the Parallax forum , Chip Gracey asked whether that could be surpassed: “Sounds like you’re up against limits, but maybe there’s some fundamental matter that could be improved.” My guess was: not in pure OctoGo. The next morning, the guess has held, and the 11/40 is surpassed anyway. p2-11 runs its benchmark about one and a half times as fast as a real 11/40, and the recorded session with Unix V6 takes 45 seconds from ogo run to the last sync , where it took 95. Here it is, recorded on the board at real speed, in the default checked build at 160 MHz: That is ogo run , the four packs found on the card, the benchmark at 755,620 instructions a second, V6’s bootstrap, root logging in, and cc compiling hello, world, which runs and is removed again before two sync s. 8.5 of the 45 seconds are the build, the load, ...

Writing Something Real in OctoGo: A PDP-11/40 That Boots Unix V6

Image
Update, 3 October 2026: the emulator below is p2-11 v0.1.0 . It has since got a core in PASM that makes it five times faster, about one and a half times an 11/40 on the same benchmark; the follow-up tells how. The OctoGo post in July ended with a question: whether the zero-allocation constraints feel workable once you try to write something real. This post is the something real. p2-11 is a PDP-11/40 emulator for the Propeller 2, written in OctoGo. It boots Unix V6 and RT-11 from RK05 disk packs kept as files on the SD card of a P2 Edge. V6 logs in, and compiles and runs C with its own compiler. Here it is doing that, recorded on the board at real speed: That is 95 seconds from ogo run to the last sync . The first twelve are the build, the load, and the emulator timing itself; then V6 boots, root logs in, and cc takes about half a minute over hello, world. How it was built Plainly: with AI help, and a lot of it. Claude, Anthropic’s model, working in Claude Code sessions, wro...

Building OctoGo: A Go-like Language Where Goroutines Are Cores

The last few posts here have been about pieces of a toolchain without saying what they were for. egg , the LL(1) parser generator. The flat AST and the ergonomics of walking one when you have decided that allocation is the enemy. And underneath both, ccgo, which turns C into Go. This post is what they were (also) for. OctoGo is a Go-like language for the Parallax Propeller 2. egg generates its parser. Its AST is a flat []int32 . Its backend is a C compiler that ccgo transpiled into the binary you install. And the thing that makes it worth writing about is not any of that plumbing - it is that on this target, a goroutine is not a scheduler entry. It is a core. The target, briefly Most readers will not have met a Propeller 2, so: it is an eight-core microcontroller with no interrupts in the usual sense, no MMU, and no operating system. The cores are called cogs. There are eight of them, they are symmetric, and they run genuinely in parallel. There is 512 KB of shared hub RAM, ea...

Taming the Regex Monster: Optimizing Massive Literal Alternations

Image
Update, November 2026: the DFA has since been rewritten as a lazy DFA behind the ordinary Regexp API, with no compile tax. This pattern now matches about 420x faster than the standard library with plain MatchString. See The Regex Monster Revisited: a Lazy DFA for Go's regexp .

Taming the Flat AST: Ergonomics in the Age of Zero Allocations

Image
Last week, I introduced egg , a modern LL(1) parser generator for Go. The response from the community was insightful, particularly regarding egg 's most distinct feature: the flat AST. To achieve high performance and low garbage collection pressure, egg encodes the entire Abstract Syntax Tree (AST) into a single []int32 slice. While this is excellent for the CPU cache, it can be intimidating for the developer. One commenter on the Gophers Slack put it perfectly: "The 'Traversing the AST' section really dissuades me from using this tool... I think coming up with a clean, well-typed API might be harder than I think." They were right. In my previous post, I showed a raw recursive walker that involved manual index arithmetic. It was fast, but it wasn't pretty. However, shortly after that post, I implemented ImportEBNF —a feature allowing egg to bootstrap itself by reading EBNF from HTML files. In doing so, I had to "eat my own dog food"...