Skip to content

Blog

A Map of Blocks

How a search engine keeps every word it knows in a few bytes each.

A search engine has to remember every word it has ever seen, keep them in order, and find any one of them in a fraction of a microsecond, often from a file it has not even read yet. The thirtieth familiar is really two: a tiny machine that spells out a whole vocabulary in about six bytes a word, and the dictionary that uses it as a table of contents.

The Bag of Holding

The small, honest tools too little for a post of their own, and a look back at the whole party.

Not every tool earns its own chapter. This is the last of the campaign: the bag of small, honest libraries too little for a post apiece, tipped out onto the table so none of them is lost, and then a look back at the whole party we assembled from one search engine, and what it meant to take it apart.

The Names Enums Throw Away

Getting an enum's name back at compile time, which the language keeps refusing to give you.

The compiler knows the names of your enum members, you just wrote them, and then it throws them away, leaving you to hand-maintain a switch that maps each value back to its own name for every log line and every parse. The twenty-eighth familiar gives the names back, at compile time, through a perfect hash, so an enum and its strings are one constexpr mapping you can even check in a static_assert.