Skip to content

Fast-path check for empty block on filestore cache lookup#7381

Merged
neilalexander merged 1 commit intomainfrom
neil/cachelookupex
Oct 1, 2025
Merged

Fast-path check for empty block on filestore cache lookup#7381
neilalexander merged 1 commit intomainfrom
neil/cachelookupex

Conversation

@neilalexander
Copy link
Copy Markdown
Member

This should improve the error reporting and reduce more expensive lookup operations when we know that the block is empty.

Signed-off-by: Neil Twigg neil@nats.io

Signed-off-by: Neil Twigg <neil@nats.io>
@neilalexander neilalexander requested a review from a team as a code owner October 1, 2025 10:22
Copy link
Copy Markdown
Member

@MauriceVanVeen MauriceVanVeen left a comment

Choose a reason for hiding this comment

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

LGTM

if seq < atomic.LoadUint64(&mb.first.seq) || seq > atomic.LoadUint64(&mb.last.seq) {
fseq, lseq := atomic.LoadUint64(&mb.first.seq), atomic.LoadUint64(&mb.last.seq)
switch {
case lseq == fseq-1:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The lock is held, so using mb.msgs == 0 could be a simpler condition.

@neilalexander neilalexander merged commit 0651b51 into main Oct 1, 2025
89 of 92 checks passed
@neilalexander neilalexander deleted the neil/cachelookupex branch October 1, 2025 15:11
neilalexander added a commit that referenced this pull request Oct 3, 2025
Includes the following:

- #7374
- #7373
- #7377
- #7380
- #7382
- #7381
- #7364
- #7384
- #7385
- #7388
- #7386
- #7391
- #7242

Signed-off-by: Neil Twigg <neil@nats.io>
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