introduce new stats item EvictedBytes#93
Merged
Merged
Conversation
It's incremented on bucket clean up and reports bytes evicted from memory. It should help to understand an amount of extra memory needed for fastcache to serve requests rate on constantly evicted keys. Related PR VictoriaMetrics/VictoriaMetrics#9293
There was a problem hiding this comment.
Pull Request Overview
Introduces a new EvictedBytes metric to track the total amount of bytes evicted from the fastcache when bucket cleanup occurs. This metric helps understand memory pressure and determine how much additional memory would be needed to avoid evictions for a given request rate.
- Added
EvictedBytesfield to theStatsstruct to expose the metric - Added corresponding
evictedBytescounter to the internalbucketstruct - Integrated the counter into bucket operations (reset, stats collection, and eviction tracking)
1 task
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #93 +/- ##
==========================================
+ Coverage 76.68% 76.81% +0.12%
==========================================
Files 4 4
Lines 549 552 +3
==========================================
+ Hits 421 424 +3
Misses 73 73
Partials 55 55 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rtm0
approved these changes
Aug 6, 2025
makasim
reviewed
Aug 6, 2025
valyala
added a commit
that referenced
this pull request
Nov 10, 2025
This reverts commit 1412165. Reason for revert: the exposed EvictedBytes metric is misleading - it doesn't reflect the real eviction rate of the data in the cache, since old data is overwritten by the new data in the cyclic buffer formed from the cache chunks, on the addition of new items to the cache. It is impossible to detect the eviction rate since the code doesn't know when it overwrites the already existing data. The EvictedBytes metric is just increased by the total size of chunks on every wraparound in the shard. This can be used as a rough estimation of the evicted bytes, but it is updated too rarely on large caches. It is possible to add WrittenBytes metric, which will show the number of bytes written to the cache. This metric roughly equals to the EvictedBytes metric after the cache becomes full and old data starts to be overwritten by the new data. Both metrics have zero practical applicability, so it is better to drop the EvictedBytes metric even if it has been already exposed in public, in order to reduce the complexity of the code and reduce the confusion for the users who try using this metric. All the users of this metric must stop using it. Updates #93 Updates VictoriaMetrics/VictoriaMetrics#9293
Collaborator
|
FYI, this pull request has been reverted in the commit f608073 . Reason for revert - the introduced EvictedBytes metric is misleading and it has zero practical sense. |
valyala
added a commit
to VictoriaMetrics/VictoriaMetrics
that referenced
this pull request
Nov 10, 2025
…1.13.2 This is needed for removing the EvictedBytes metric from the fastcache. See the description of VictoriaMetrics/fastcache@f608073 for details. Updates #9293 Updates VictoriaMetrics/fastcache#93
valyala
added a commit
to VictoriaMetrics/VictoriaMetrics
that referenced
this pull request
Nov 10, 2025
…1.13.2 This is needed for removing the EvictedBytes metric from the fastcache. See the description of VictoriaMetrics/fastcache@f608073 for details. Updates #9293 Updates VictoriaMetrics/fastcache#93
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It's incremented on bucket clean up and reports bytes
evicted from memory. It should help to understand an amount of extra memory needed for fastcache to serve requests rate on constantly evicted keys.
Related PR VictoriaMetrics/VictoriaMetrics#9293