Comments (6)
@manishrjain by read-your-writes I mean:
cache.Set("key", "value", 1) // set a value
value, found := cache.Get("key")
// expecting found to be true
without sleeping as in the example here: https://blog.dgraph.io/post/introducing-ristretto-high-perf-go-cache/
from ristretto.
Read buffer should be lossy, but write buffer should not be.
I believe the difference is that Caffeine writes to the HashMap immediately, then into the buffer, replays, and evicts. This means that the cache can temporarily exceed its capacity by a small margin. The bounded write buffer adds backpressure to ensure this does not have a runaway effect.
If I understand correct, Risretto writes into a channel first and then into the map later, which means you lose visibility. I think that was to improve write performance because Golang lacks a good, concurrent map, so they took the write buffer idea as a means to avoid the coarse locking. Regardless, I think this flow should be flipped to always have a consistent map view for more obvious code / usage. If there are performance concerns those should be tackled separately.
from ristretto.
By read-your-writes, you mean read ALL your writes? Ristretto has admission policy so it would drop Sets, that's part of the design. However, if a key is already present in the cache, then any Sets for that key would definitely get the updated value.
from ristretto.
+1
Currently you cannot use ristretto for deduplication with very high insert rate because set's might take a few milliseconds.
from ristretto.
I looked into this. Our plan was do something similar to what Caffeine is doing to get immediate writes. Caffeine uses a small LRU whose items are either accepted or rejected into the main LRU with the use of the TinyLFU policy.
However, for this to work correctly, the write and read buffers should be lossless. This is not the case currently because we are using sync.Pool
to take advantage of its internal thread-local storage. So this feature has been de-prioritized until we find an optimal way to go about this.
Most of the limitations are due to the lack of some of the features that Caffeine uses in golang.
from ristretto.
Github issues have been deprecated.
This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.
from ristretto.
Related Issues (20)
- [FEATURE]: Loading or Compute If key is not present
- 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?
- [QUESTION]: Why is Ristretto so slow and has such a small hit ratio?
- 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`
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.