Repository navigation
[improve][broker] Speed up auto-split Key_Shared consumer selection - #26654
Merged
Merged
Conversation
lhotari
added this pull request to stack #26656
September 19, 2026 12:50
dao-jun
approved these changes
Sep 19, 2026
merlimat
approved these changes
Sep 19, 2026
lhotari
force-pushed
the
lh-improve-auto-split-select
branch
from
September 19, 2026 18:10
99c5d57 to
9cc7001
Compare
Publish an immutable lookup snapshot after membership changes so the hot selection path uses primitive-bound binary search instead of a concurrent skip-list lookup. Assisted-by: Codex
…okup Assisted-by: Codex
lhotari
force-pushed
the
lh-improve-auto-split-select
branch
from
September 19, 2026 19:41
2c78a0f to
2ddde5f
Compare
1 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The AUTO_SPLIT Key_Shared selector performs a
ConcurrentSkipListMap.ceilingEntrylookup for every dispatched message. Consumer membership changes are rare compared with message selection, and those changes are already serialized. A concurrent ordered-map traversal therefore adds pointer chasing and comparison work to the hot path while membership is stable.Modifications
A selection concurrent with a membership change observes either the complete old snapshot or the complete new snapshot. Once
addConsumerorremoveConsumerreturns, the new snapshot has been published.Performance
JMH compares the actual selector with the previous
ConcurrentSkipListMap.ceilingEntrylookup. Runs used two forks, three 1-second warmups, five 1-second measurements, and GC profiling.Both implementations allocate effectively zero on selection. Membership changes allocate the compact snapshot and remain control-plane operations.
A five-million-message scenario with 500 producers and five ten-consumer Key_Shared subscriptions produced two positive matched comparisons:
Every run delivered all messages to every subscription with zero duplicates, ordering violations, or invalid messages. The whole-host gain is larger than the isolated nanosecond saving directly explains, so the table establishes repeatability and absence of regression rather than attributing the full improvement to this lookup.
Verifying this change
This change added tests and can be verified as follows:
./gradlew :microbench:shadowJar quickCheckDoes this pull request potentially affect one of the following parts: