Live data from Hacker News

Classical data structures that can outperform learned indexes (2018)

dawn.cs.stanford.edu

41–43 of 43 posts

Re: Classical data structures that can outperform learned indexes (2018)

#41

Earlier quoted context omitted.

> Ok so never mind... Keep reading, specifically the Variations section. 50% occupancy is for constructions with a per-bucket capacity of 1. At a capacity of 2, occupancy improves to a little under 90%, and at 4 to just under 98%. The linked write-up uses 8, which does in fact achieve very high occupancy. They could've done better, though. By using windows instead of buckets (i.e. allowing the buckets to overlap), a…

Thanks, that explains what they're saying now. But I'm still skeptical. How achievable is 98% fill for 4-element buckets in the first place? Intuitively I feel like you'd frequently have to scrap the table and rehash or enlarge it... is that not the case?

Like with Bloom filters (which also draw their power from hashing items into multiple buckets), the statistical guarantees are quite strong, and things work well in practice.

There are other options for the insertion algorithm than the standard random walk, too. E.g. take a look at page 18 of "Load Thresholds for Cuckoo Hashing with Overlapping Blocks" [1] for empirical data on 2-3 hash functions for 2-3 size windows. They don't show 4- or 8-size windows, but you get the gist.

Like nullc says below, it's trivial to tune things for your requirements. Want fast insertions? Overprovision. Want more predictable insertions? Use a smarter insertion algorithm. Want small tables? Use more hash functions and/or larger buckets. Want fast queries? Keep the hash count and bucket sizes small.

Rehashing isn't really a concern beyond the case of 2 hash functions and non-overlapping buckets of size 1.

1. https://arxiv.org/pdf/1707.06855.pdf

Re: Classical data structures that can outperform learned indexes (2018)

#42

Earlier quoted context omitted.

Recently went on a deep dive about sorting algorithm actual predictability and for latency-sensitive workloads, most things you'd use because 'simple/standard' (quicksort, mergesort...) don't shine, with their horrid /worst case/ complexity, but also depending a lot on your input data. Quicksort with a badly chosen pivot, for example, has caused me headaches recently.

Mergesort worst case is O(nlog(n)). If there's a downside to it, it's that you need to allocate memory.

Which is where you get problematic tail latencies. Or your data fits on the stack.

Re: Classical data structures that can outperform learned indexes (2018)

#43
post #39
post #37

Earlier quoted context omitted.

A below transition fullness the insertion process takes N kicks with exponentially decreasing probability (for some constants depending on the fullness level and number of hash functions). E.g. 1/2^n kicks. Not something you can really describe as wildly erratic. If latency is particularly critical in your application, you could couple the hash table with a small "stash" map and perform a constant maximum number of k…

The fact that you're talking about probabilities sort of proves my point. You're instead saying it could be worse, and I'm saying random execution times in your critical paths is generally undesirable. It depends on your application of course, but if you have anything realtime or near realtime, I would definitely take consistent execution times. There is a related e-mail from IdSoft's John Carmack about this at [1] w…

There are 'random' execution times in the critical paths of essentially everything on a modern general purpose computer, unfortunately.

What matters for realtime operation is that the worst case is bounded and that the bound is acceptable.

Post reply on HN