Skip to content

Commit

Permalink
Optimize consumer messages sequences for multiple subjects
Browse files Browse the repository at this point in the history
If consumer with multiple subjects encountered a sequnece
of messages from the same subject, it tried to load messages
from other subjects in some cases.
This checks for that scenario and optimizes it by early returning.

Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed May 3, 2023
1 parent e7b01c4 commit 0fe17ef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/consumer.go
Expand Up @@ -3295,6 +3295,11 @@ func (o *consumer) getNextMsg() (*jsPubMsg, uint64, error) {
o.updateSkipped(uint64(filter.currentSeq))
}
}

// If we're sure that this filter has continuous sequence of messages, skip looking up other filters.
if filter.currentSeq == nextSeq && sseq == filter.currentSeq && err != ErrStoreEOF {
break
}
}

}
Expand Down

0 comments on commit 0fe17ef

Please sign in to comment.