Comments (5)
Everything indicates at the moment that the latest versions of ristretto have very serious bugs that have not been fixed for a long time. (everything is fine with hit ratio on v0.0.2).
from ristretto.
Unfortunately, this is not how it works.
MaxCost
is the number of entries stored in the cache (if the cost of each entry in the cache is 1). If you specifyMaxCost
= 1 << 30, then 1 << 30 = 1073741824 entries will be stored in the cache. This will lead to huge memory usage and unfairness of benchmarks.
There's a thing in ristretto called InternalCost
, so even when you specify the cost to 1
in the code, the underlying cost
for each item saved is much bigger than that. I think ristretto does not have a config field for 'exact' capacity.
In my case where memory usage is not a limiting factor, ristretto works well as long as a big enough MaxCost
like 1<<30
is used.
from ristretto.
the underlying cost for each item saved is much bigger than that.
Oh my God, I realized what happened and it's not good at all.
The fact is that at some point ristretto added the IgnoreInternalCost flag to its config. This led to the fact that all its clients (which specified cost = 1) broke down. Moreover, they even broke their tests. And I have not seen the use of IgnoreInternalCost
in the vast majority of new clients, that is, they are also broken... And it's not obvious from the README either. It's not described there and you have to read the library code to figure it out.
In my case where memory usage is not a limiting factor
Unfortunately, this is not a common scenario and you do not understand the size of the cache.
Yes, hit ratio performance improves with this flag but it still does not give ristretto the opportunity to fight against the canonical W-TinyLFU.
But the throughput has decreased significantly and now ristretto loses ccache on some types of load.
goos: darwin
goarch: arm64
pkg: github.com/maypok86/benchmarks/throughput
BenchmarkCache/zipf_otter_reads=100%,writes=0%-8 207136872 5.118 ns/op 195404670 ops/s
BenchmarkCache/zipf_theine_reads=100%,writes=0%-8 10925358 107.3 ns/op 9323651 ops/s
BenchmarkCache/zipf_ristretto_reads=100%,writes=0%-8 39178822 30.47 ns/op 32814142 ops/s
BenchmarkCache/zipf_ccache_reads=100%,writes=0%-8 35809983 44.41 ns/op 22518921 ops/s
BenchmarkCache/zipf_gcache_reads=100%,writes=0%-8 4137457 301.5 ns/op 3316661 ops/s
BenchmarkCache/zipf_ttlcache_reads=100%,writes=0%-8 2556433 454.4 ns/op 2200669 ops/s
BenchmarkCache/zipf_golang-lru_reads=100%,writes=0%-8 5192370 238.2 ns/op 4197925 ops/s
BenchmarkCache/zipf_otter_reads=75%,writes=25%-8 152412055 8.296 ns/op 120545846 ops/s
BenchmarkCache/zipf_theine_reads=75%,writes=25%-8 10727758 115.2 ns/op 8681015 ops/s
BenchmarkCache/zipf_ristretto_reads=75%,writes=25%-8 19170259 63.38 ns/op 15778332 ops/s
BenchmarkCache/zipf_ccache_reads=75%,writes=25%-8 19926837 56.00 ns/op 17857662 ops/s
BenchmarkCache/zipf_gcache_reads=75%,writes=25%-8 4015016 302.1 ns/op 3309800 ops/s
BenchmarkCache/zipf_ttlcache_reads=75%,writes=25%-8 3016176 418.7 ns/op 2388181 ops/s
BenchmarkCache/zipf_golang-lru_reads=75%,writes=25%-8 4415922 256.2 ns/op 3903844 ops/s
BenchmarkCache/zipf_otter_reads=50%,writes=50%-8 100895930 11.46 ns/op 87245999 ops/s
BenchmarkCache/zipf_theine_reads=50%,writes=50%-8 10697534 110.6 ns/op 9044843 ops/s
BenchmarkCache/zipf_ristretto_reads=50%,writes=50%-8 11715498 89.41 ns/op 11184716 ops/s
BenchmarkCache/zipf_ccache_reads=50%,writes=50%-8 11967110 101.7 ns/op 9831291 ops/s
BenchmarkCache/zipf_gcache_reads=50%,writes=50%-8 3883863 307.1 ns/op 3256162 ops/s
BenchmarkCache/zipf_ttlcache_reads=50%,writes=50%-8 3125329 357.5 ns/op 2797596 ops/s
BenchmarkCache/zipf_golang-lru_reads=50%,writes=50%-8 4535643 275.1 ns/op 3635185 ops/s
BenchmarkCache/zipf_otter_reads=25%,writes=75%-8 53571258 25.38 ns/op 39397649 ops/s
BenchmarkCache/zipf_theine_reads=25%,writes=75%-8 9444111 122.7 ns/op 8149415 ops/s
BenchmarkCache/zipf_ristretto_reads=25%,writes=75%-8 7211848 186.4 ns/op 5365390 ops/s
BenchmarkCache/zipf_ccache_reads=25%,writes=75%-8 8722424 133.6 ns/op 7482404 ops/s
BenchmarkCache/zipf_gcache_reads=25%,writes=75%-8 3865218 310.9 ns/op 3216943 ops/s
BenchmarkCache/zipf_ttlcache_reads=25%,writes=75%-8 3390970 308.0 ns/op 3247153 ops/s
BenchmarkCache/zipf_golang-lru_reads=25%,writes=75%-8 4562470 267.2 ns/op 3742059 ops/s
BenchmarkCache/zipf_otter_reads=0%,writes=100%-8 3237279 348.8 ns/op 2866629 ops/s
BenchmarkCache/zipf_theine_reads=0%,writes=100%-8 4302932 370.5 ns/op 2698702 ops/s
BenchmarkCache/zipf_ristretto_reads=0%,writes=100%-8 2302149 495.7 ns/op 2017283 ops/s
BenchmarkCache/zipf_ccache_reads=0%,writes=100%-8 2053848 640.9 ns/op 1560212 ops/s
BenchmarkCache/zipf_gcache_reads=0%,writes=100%-8 3781105 323.3 ns/op 3093007 ops/s
BenchmarkCache/zipf_ttlcache_reads=0%,writes=100%-8 4412658 275.7 ns/op 3626876 ops/s
BenchmarkCache/zipf_golang-lru_reads=0%,writes=100%-8 4986291 232.8 ns/op 4295432 ops/s
PASS
ok github.com/maypok86/benchmarks/throughput 59.164s
I will try to update the README in otter soon and ideally I need to come with a pull request to ristretto of course but I doubt that this will fix anything with the current level of support.
from ristretto.
In your graph, tests are run using capacities
under 2000, according to the code I assume that this will result in a NumCounters
<20000 and a MaxCost
<2000 for the ristretto
cache instance which is absurdly far from the normal settings of it. In the readme.md they used
NumCounters: 1e7, // number of keys to track frequency of (10M).
MaxCost: 1 << 30, // maximum cost of cache (1GB).
So I assume that this might be the reason. I look forward to see your updated tests result.
from ristretto.
I assume that this will result in a NumCounters<20000 and a MaxCost <2000 for the ristretto cache instance which is absurdly far from the normal settings of it.
Unfortunately, this is not how it works. MaxCost
is the number of entries stored in the cache (if the cost of each entry in the cache is 1). If you specify MaxCost
= 1 << 30, then 1 << 30 = 1073741824 entries will be stored in the cache. This will lead to huge memory usage and unfairness of benchmarks.
from ristretto.
Related Issues (20)
- How many bits tinyLFU uses to count access frequency? HOT 1
- [QUESTION]: Ristretto hit ratio benchmark result HOT 2
- [BUG]: <sync.Pool GC>
- [QUESTION]: Too high missed rate?
- [FEATURE]: Jemalloc 5.3.0
- [FEATURE]: use system jemalloc
- [Non-hashed key values in Item]: onEvict should send the non hashed key values HOT 1
- [BUG]: compilation reports asm error when -buildmode=plugin
- [QUESTION]: Is there any way to implement an expired map counter with ristretto?
- [QUESTION]: How can I pre warm the cache ?
- [QUESTION]: When get v.0.1.2 tag and it's release note?
- Update projects using ristretto
- [SERIOUS BUG]: negative key cache hit problem HOT 3
- [BUG]: Can't use Google's uuid.UUID (a byte array rather than slice) as a key HOT 6
- [BUG]: cost added always differ by 56 HOT 2
- new release
- Missing commits/PRs on main
- Cache configuration checks should consider negative values for `NumCounters`/`MaxCost`/`BufferItems`
- [BUG]: <Title>Cannot correctly view a transparent png file, which is very long
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ristretto.