Skip to content
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

[IMPROVED] Do not load blocks unnecessarily when checking if we can skip ahead in LoadNextMsg(). #5819

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

derekcollison
Copy link
Member

When we would miss a LoadNextMsg() from the block associated with the starting sequence, we would check if we could skip ahead. The logic for this could load old blocks, behind where we were, if the psim fblk was outdated, causing memory bloat for cache expiration time intervals.

We reworked this to load no blocks in the skip check since this is hot path for LoadNextMsg() and the linear scan, if applicable, properly will expire anything loaded that did not contain a match.

I tested that benchmarks were not affected.

go test -v -run=XXX --bench=Benchmark_FileStoreLoadNext

Signed-off-by: Derek Collison derek@nats.io

…ip on initial miss in LoadNextMsg().

When we would miss a LoadNextMsg() from the block associated with the starting sequence, we would check if we could skip ahead.
The logic for this could load old blocks, behind where we were, if the psim fblk was outdated, causing memory bloat for cache expiration time intervals.

We reworked this to load no blocks in the skip check since this is hot path for LoadNextMsg() and the linear scan, if applicable, properly will expire anything loaded that did not contain a match.

Signed-off-by: Derek Collison <derek@nats.io>
@derekcollison derekcollison requested a review from a team as a code owner August 22, 2024 23:39
Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

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

LGTM

@derekcollison derekcollison merged commit 2cae85d into main Aug 23, 2024
5 checks passed
@derekcollison derekcollison deleted the skip-loads branch August 23, 2024 00:03
wallyqs added a commit that referenced this pull request Aug 23, 2024
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