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

How many bits tinyLFU uses to count access frequency?

Millione opened this issue · comments

I found the explanation difference between code comments and README. It confuses me.

ristretto/policy.go

Lines 366 to 374 in 3177d9c

// tinyLFU is an admission helper that keeps track of access frequency using
// tiny (4-bit) counters in the form of a count-min sketch.
// tinyLFU is NOT thread safe.
type tinyLFU struct {
freq *cmSketch
door *z.Bloom
incrs int64
resetAt int64
}

* **Admission: TinyLFU** - extra performance with little memory overhead (12 bits per counter).

Hi @Millione Thanks for highlighting, we will take a look at this. Looks like a mismatch between the implementation and the docs. I have added it to our internal tracker, we will update you here. Thanks!