mph is a Go package for that implements a minimal perfect hash table over strings. It uses the "Hash, displace, and compress" algorithm and the circlehash hash function.
Some quick benchmark results (Apple M1 Pro):
Build
constructs a minimal perfect hash table from a 350k word dictionary in 100ms (construction time is linear in the size of the input).Lookup
s on that dictionary take about 30ns and are 50% faster than amap[string]uint32
:
name time/op
Build 51.4ms ±12%
Table 13.7ns ± 0%
TableMap 42.1ns ± 1%