Comments (4)
It sounded to me that if the value calculated by new entries is higher than the lowest entry in a random sample, the new entry gets admitted. Otherwise not.
Correct.
won't the number of discarded items go up over time? Imagine if there are only reads for a minute or 10minutes, the frequency of most items increase and they gain a higher value than any new incoming entries.
TinyLFU prevents this with two "freshness" mechanisms:
- Counter Resets: every N increments all counters are halved. Because a counter increment occurs for every Read, in your example of only reads for an extended period of time this mechanism would work as fast as possible (compared to a mixed workload).
- 4-bit Counters: not only are these great for memory usage but due to the small range of values these actually perform better in hit ratio benchmarks due to the opportunities it provides for new items to be admitted (@ben-manes has ran these).
I'm not confident in how the value is calculated, so I apologies if this is way off. Also curious if you have metrics for discarded (new items that was never added) metrics?
No problem, this is a common question, and the freshness mechanisms are a small but important aspect of Ristretto.
We do have metrics for new items that are rejected here.
from ristretto.
Here's an example of checking the rejectSets
metric:
// create cache with Metrics on
cache, err := NewCache(&Config{
NumCounters: 1e7, // 10M
MaxCost: 1 << 30, // 1GB
BufferItems: 64,
Metrics: true,
})
if err != nil {
panic(err)
}
// do your testing
//
//
// get the number of rejected items
rejected := cache.metrics().Get(rejectSets)
Currently we're not publicly exposing the metrics. I don't see a reason not to, so we'll probably add those to the public API.
from ristretto.
Also an admission window can be used to delay the decision, allowing a new entry the chance to build up its frequency. That avoids consecutive misses in recency traces. The amount of space allocated to the window can be dynamically tuned based on the workload.
from ristretto.
The concise answer to this question is: freshness mechanisms (addressed above) and windowing (addressed in #46). I'll close this for now.
from ristretto.
Related Issues (20)
- [QUESTION]: Differentiate between TTL and cost based eviction
- [FEATURE]: Support for Type Parameters, aka, generics HOT 1
- [BUG]: ristretto used about 2 x MaxCost memory?? HOT 5
- benchmark about gc or plan to reduce gc HOT 1
- [BUG]: Expiration map grows without limit HOT 6
- [QUESTION]: Why did you choose ristretto as the project name ? HOT 2
- [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
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.