Conversation
Use the existing per-batch permit map keys to identify consumers selected while filtering entries. This removes a HashSet insertion for every selected entry while preserving look-ahead membership. Assisted-by: Codex
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 Key_Shared dispatcher records every consumer selected while filtering a read batch in a dedicated
HashSet. It only queries that set if the batch dispatches no entries, to decide whether another consumer could make progress through look-ahead.The existing per-batch permit map is populated for the same selected consumer before every dispatch decision. Its keys therefore carry the same membership, making the extra set and one hash-table insertion per selected entry redundant.
In an exact post-warmup broker profile, the redundant
HashSet.addpath accounted for 201 CPU leaf samples insidefilterAndGroupEntriesForDispatching.Modifications
Verifying this change
The focused sticky dispatcher, slow-consumer, and shared permit-accounting suites passed, as did broker Spotless, Checkstyle, and
./gradlew quickCheck --no-daemon.An actual production-path JMH benchmark with 1,000 entries and ten consumers improved the healthy dispatchable batch from 84.3 to 77.2 us (-8.4%). Allocation fell from 67.38 to 67.12 KB/op.
An end-to-end run used 500 producer connections and five Key_Shared subscriptions with ten consumers each. All 30 million fanout deliveries completed with no duplicates, ordering violations, or invalid messages. The targeted
HashSet.addpath fell from 201 CPU leaf samples in the preceding exact profile to zero. The single full run is used as correctness and CPU-attribution evidence rather than an end-to-end capacity claim.Does this pull request potentially affect one of the following parts: