11 nanoseconds per word: Ridiculously Over-Optimizing Anagrams
Summary
Technical exploration of optimizing an anagram solver for a word-ladder game in Rust. The author demonstrates multiple approaches to identifying anagrams efficiently—sorting-based keys, 4-bit packed letter counts in a u128, 64-bit Gödel-numbering with prime products, and a packed 5-bit representation—with benchmark results showing dramatic improvements from 31 ms baseline to around 1.96 ms. The post also discusses memory allocations, hash table choices, and ILP-friendly optimizations.