Modern Perfect Hashing
blog.sesse.net·21h·
Discuss: Hacker News
Flag this post

Wojciech Muła posted about modern perfect hashing for strings and I wanted to make some comments about my own implementation (that sadly never got productionized because doubling the speed compared to gperf wasn’t really that impactful in the end).

First, let’s define the problem, just so we’re all on the same page; the goal is to create code that maps a known, fixed set of strings to a predefined integer (per string), and rejects everything else. This is essentially the same as a hash table, except that since the set of strings is known ahead of time, we can do better than a normal hash table. (So no “but I heard SwissTables uses SIMD and thus cannot be beat”, please. :-) ) My use case is around a thousand strings or …

Similar Posts

Loading similar posts...