Skip to content

[QUESTION]: Why is Ristretto so slow and has such a small hit ratio? #363

Open
@maypok86

Description

@maypok86

Question.

Hi, I am currently writing a similar package and tried to compare my implementation https://github.com/maypok86/otter with Ristretto. In the end I found that Ristretto loses very badly (about 5-7 times) and has a hit ratio on most traces around zero. I can roughly understand why there is a terrible loss in speed (Ristretto even though it says it is contention-free, it actually locks its shards very often which ends up not giving enough perfomance to fight Otter).

I attached benchmarks with the best cache libraries at the moment.

goos: darwin
goarch: arm64
pkg: github.com/maypok86/benchmarks
BenchmarkCache/Zipf_Otter_reads=100%,writes=0%-10         	21643555	        46.95 ns/op	       1 B/op	       0 allocs/op
BenchmarkCache/Zipf_Theine_reads=100%,writes=0%-10        	12177036	        97.41 ns/op	       0 B/op	       0 allocs/op
BenchmarkCache/Zipf_Ristretto_reads=100%,writes=0%-10     	20823691	        54.00 ns/op	      16 B/op	       1 allocs/op
BenchmarkCache/Zipf_Otter_reads=75%,writes=25%-10         	17760416	        66.58 ns/op	       6 B/op	       0 allocs/op
BenchmarkCache/Zipf_Theine_reads=75%,writes=25%-10        	 2540319	       462.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkCache/Zipf_Ristretto_reads=75%,writes=25%-10     	 2442692	       464.9 ns/op	      51 B/op	       2 allocs/op
BenchmarkCache/Zipf_Otter_reads=50%,writes=50%-10         	13647469	        78.17 ns/op	      11 B/op	       0 allocs/op
BenchmarkCache/Zipf_Theine_reads=50%,writes=50%-10        	 2298838	       537.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkCache/Zipf_Ristretto_reads=50%,writes=50%-10     	 2603936	       444.1 ns/op	      72 B/op	       2 allocs/op
BenchmarkCache/Zipf_Otter_reads=25%,writes=75%-10         	10211748	       100.6 ns/op	      16 B/op	       0 allocs/op
BenchmarkCache/Zipf_Theine_reads=25%,writes=75%-10        	 2140611	       563.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkCache/Zipf_Ristretto_reads=25%,writes=75%-10     	 2401822	       571.2 ns/op	     102 B/op	       3 allocs/op
BenchmarkCache/Zipf_Otter_reads=0%,writes=100%-10         	19658750	        57.54 ns/op	       0 B/op	       0 allocs/op
BenchmarkCache/Zipf_Theine_reads=0%,writes=100%-10        	 1958818	       656.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkCache/Zipf_Ristretto_reads=0%,writes=100%-10     	 2606988	       450.6 ns/op	     124 B/op	       3 allocs/op
PASS
ok  	github.com/maypok86/benchmarks	171.538s

But I would still like to hear an answer about the small hit ratio in Ristretto because in README there are some numbers but in practice they are around 0. This was also asked here and remained unanswered😢

I also attach the results of my hit ratio calculations, it seems several people and different benchmark implementations can't be wrong...😔
oltp

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/questionSomething requiring a response.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions