Let's pwn!
I had a 4 GiB file that’s almost entirely zeros, exactly one non-zero
int64 is hiding at offset Size - 8 (the last aligned slot). The task: find
that offset, as fast as possible, in Go on Linux.
It’s a deliberately silly problem. There’s no parsing, no indexing, no
cleverness on the algorithm side. The only thing it measures is how much data
we can pull through a CPU per second. Exactly the kind of micro-task that
exposes every layer of the stack: the Go runtime, the standard library, the
kernel, the page cache, the memory hierarchy, and SIMD, including Go 1.26’s
brand-new simd/archsimd package that lets you write AVX-512 in pure Go.
Starting from the most obvious os.ReadFile + for range we get 0.75
GB/s. Thirteen variants later we’re at 49 GB/s, a 66× speedup, and
we’ll know exactly which wall we hit and why.
No, you don't need Oh My Zsh
23 June 2025
Don’t get me wrong – Oh My Zsh is an excellent product. It’s well-maintained, feature-rich, and has helped millions of developers enhance their shell experience. But here’s the thing: you don’t need it to have a great zsh experience.
When I recently set up a new workstation, I decided to skip Oh My Zsh entirely and configure zsh manually. The result? A lightweight, fast, and fully customized shell that does exactly what I need – nothing more, nothing less.
Read More…The case against helper packages named `utils`
9 January 2025
I argued earlier that a function’s signature should never
lie, and then that errors are
values only if you treat them like values. Both
posts circled the same question at different scales: what is this code
for? This one closes the loop at the package level. The short version: if
your package is named utils, you don’t have an answer.
Errors are values, but only if you treat them that way
14 November 2024
Last time I argued that a function’s signature should never
lie. The error return is the
most lied-about part of every Go signature I read. It gets logged,
swallowed, repackaged, panicked on, and printed back to the user as
internal error: internal error: internal error. Three habits keep it
honest.
Self-explained function signatures
26 September 2024
A function I once shipped looked like this:
func Process(data []byte) error
Innocent. You give it bytes, it returns an error. What more do you need?
Plenty, as it turned out. Process also wrote a file to /tmp, posted the
same bytes to a webhook, and stashed a copy in a package-level global so the
next call could “diff against the last one”. None of that was in the
signature. None of it was in the doc comment either, because by the time
anyone read the doc comment they’d already wired the function into a hot path
and were wondering why CI was flaky.
The signature lied. Once a signature lies, every reader has to open the body to find the truth. That’s the cost.
Read More…