dgraph-io / ristretto

A high performance memory-bound Go cache

Home Page:https://dgraph.io/blog/post/introducing-ristretto-high-perf-go-cache/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sketch implementation does not seem to implement a count-min sketch

romaindoumenc opened this issue · comments

In sketch.go, each row is using a custom seed that is xored with the hash value:
val := s.rows[i].get((hashed ^ s.seed[i]) & s.mask)

Note that the two operations are without any sort of bit shifting, meaning that only the masked bits are xored together.

Unless I am mistaken, this mean that all rows in the count-min sketch are effectively the same (shifted), and this in turn means that only one row would give exactly the same information – the tests currently only tests that the rows are not exactly the same, which a fairly low bar.

An effective solution with minimal changes to the current implementation would be to use different masks on each row.

Use Discuss Issues for reporting issues about this repository.