]> git.sesse.net Git - plocate/commit
Switch trigram lookup from binary search to a hash table.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Wed, 30 Sep 2020 17:44:28 +0000 (19:44 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Wed, 30 Sep 2020 17:46:53 +0000 (19:46 +0200)
commitc41f998855416a8619751653f3cedd9bc6f0f4c0
treed953afe6601673a3c097cca8238bae9d27e2f273
parent3ad645ea17df87005ffe956b8ae85f08af7595d0
Switch trigram lookup from binary search to a hash table.

Binary search was fine when we just wanted simplicity, but for I/O
optimization on rotating media, we want as few seeks as possible.
A hash table with open addressing gives us just that; Robin Hood
hashing makes it possible for us to guarantee maximum probe length,
so we can just read 256 bytes (plus a little slop) for each lookup
and that's it. This kills ~30 ms or so cold-cache.

This breaks the format, so we use the chance to add a magic and
a proper header to provide some more flexibility in case we want
to change the builder.
db.h [new file with mode: 0644]
plocate-build.cpp
plocate.cpp