Skip to content

Limit the number of in-memory cached blocks per store #6898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

neilalexander
Copy link
Member

The cache expiry timer may not be fast enough to expire blocks from the cache when a stream is under either heavy ingest or a high-speed readout, so try to cap the number of cached blocks to a set number. The evict IPQ will start to pop entries for eviction once we reach defaultCacheEvictionThreshold.

Signed-off-by: Neil Twigg [email protected]

@neilalexander
Copy link
Member Author

Ran this through Gauge and it makes virtually no difference to the JetStream, KV, object store or filestore benchmarks.

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss, agree we need to do something here.

@@ -313,6 +314,8 @@ const (
maxBufReuse = 2 * 1024 * 1024
// default cache buffer expiration
defaultCacheBufferExpiration = 10 * time.Second
// deault cache size before eviction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling


// If loading this block into the cache caused us to reach the eviction
// threshold for cached blocks, evict the oldest one.
if n, _ := mb.fs.evict.push(mb); n == defaultCacheEvictionThreshold {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we remove from evict on normal cache timeout? Don't see that code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants