r/programming • u/alexeyr • Oct 27 '26
Billion-query-per-second lookup tables in C++
https://x.com/lemire/status/2115046718039306377
32
Upvotes
r/programming • u/alexeyr • Oct 27 '26
43
u/bzbub2 Oct 27 '26
the normal non-x link https://lemire.me/blog/2026/10/26/billion-query-per-second-lookup-tables-in-c/
29
u/creeper6530 Oct 28 '26
It's not billion database/HTTP queries or even a traditional lookup table, just a fast compile time prepared hash map.
The title could use a rewrite
5
u/barr520 Oct 28 '26 edited Oct 28 '26
I found that if the differentiating bytes in the keys are close enough(within some 8 byte window), you can do a single load of the relevant 8 byte part of the key and a bit extract instruction(pext on x86) to pick relevant bits to construct an index, and it can be even faster than this method(and if the differentiating bytes aren't close enough, you can do this multiple times with different windows).
1
u/Solid_Error_6401 24d ago
fyi, this lib is optimized for ARM, x86 wont perform as good as it would.
You could get better results using similar approaches.