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

Improve performance and latency with large number of sparse consumers. #3706

Merged
merged 1 commit into from Dec 13, 2022

Conversation

derekcollison
Copy link
Member

When a stream had a large number of consumers on a server that were sparse, the signaling mechanism would do a linear scan to signal matching consumers. As usage patterns have continued to have more consumers that are filteres and sparse, meaning a message is destined for a single or small number of consumers.

This change moves selection to a sublist that tracks only active consumer leaders for selection, which optimizes selection of consumers to signal when the number of consumers is large.

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

/cc @nats-io/core

Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

Looks good!

Just some tiny nits.

server/norace_test.go Show resolved Hide resolved
server/norace_test.go Outdated Show resolved Hide resolved
server/norace_test.go Show resolved Hide resolved
server/norace_test.go Show resolved Hide resolved
server/stream.go Outdated Show resolved Hide resolved
server/norace_test.go Show resolved Hide resolved
server/norace_test.go Show resolved Hide resolved
server/norace_test.go Show resolved Hide resolved
When a stream had a large number of consumers on a server that were sparse, the signaling mechanism would do a linear scan to signal matching consumers. As usage patterns have continued to have more consumers that are filteres and sparse, meaning a message is destined for a single or small number of consumers.

This change moves selection to a sublist that tracks only active consumer leaders for selection, which optimizes selection of consumers to signal when the number of consumers is large.

Signed-off-by: Derek Collison <derek@nats.io>
Copy link
Member

@Jarema Jarema 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 c27e9b8 into dev Dec 13, 2022
@derekcollison derekcollison deleted the sparse-latency branch December 13, 2022 18:45
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.

None yet

2 participants