Conversation
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
Key_Shared dispatch creates an
EntryAndMetadatawrapper for each entry and subscription. The wrapper keeps the parsed metadata and computed sticky-key hash local to that dispatcher, but it currently becomes garbage after the entry is sent or moved to replay.In a five-subscription Key_Shared workload, these short-lived wrappers accounted for 486 MiB of sampled broker allocation in the post-warmup measurement window.
Modifications
Recycle each wrapper after its single owned entry release. Clear the wrapped entry, metadata reference, and cached sticky-key hash before returning it to Netty's recycler.
This preserves independent hash state across subscriptions and does not change entry reference counting or dispatch behavior.
Validation
The targeted sampled allocation fell from 486 MiB to 4 MiB, a 99.2% reduction. No replacement recycler-handle allocation was sampled.
A 500-producer workload with five Key_Shared subscriptions and ten consumers per subscription delivered all 30 million fanout messages with zero duplicates, ordering violations, or invalid messages.
The following checks passed:
SharedConsumerAssignorTestPersistentStickyKeyDispatcherMultipleConsumersTestPersistentStickyKeyDispatcherMultipleConsumersClassicTest./gradlew quickCheck