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
Optimize synchronized in PartitionedDispatcher #8640
Optimize synchronized in PartitionedDispatcher #8640
Conversation
Even if the `PartitionedDispatcher.populatedPartitions()` is fast, in-memory, non-blocking operation, its active call from the `dispatch()` on every message sent to the channel may pin the virtual thread. * Optimize the `populatedPartitions()` for double `if` where we will step into a `synchronized` block only for first several concurrent messages **Cherry-pick to `6.1.x`**
c633d97
to
f164fab
Compare
@@ -151,10 +151,16 @@ public boolean dispatch(Message<?> message) { | |||
return partitionDispatcher.dispatch(message); | |||
} | |||
|
|||
private synchronized void populatedPartitions() { | |||
private void populatedPartitions() { | |||
if (this.partitions.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will probably need a // NOSONAR
here (and other unsynchronized uses) to prevent Sonar from complaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how that suppose to complain since this property is final
.
Plus our Sonar instance it out of order for a while.
I'd prefer to look into this when we come back into business with Sonar and it indeed will complain respectively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think being final matters, I believe Sonar will report a smell for inconsistent synchronization of fields.
Even if the `PartitionedDispatcher.populatedPartitions()` is fast, in-memory, non-blocking operation, its active call from the `dispatch()` on every message sent to the channel may pin the virtual thread. * Optimize the `populatedPartitions()` for double `if` where we will step into a `synchronized` block only for first several concurrent messages **Cherry-pick to `6.1.x`**
...and cherry picked as 0350a64 |
Even if the
PartitionedDispatcher.populatedPartitions()
is fast, in-memory, non-blocking operation, its active call from thedispatch()
on every message sent to the channel may pin the virtual thread.populatedPartitions()
for doubleif
where we will step into asynchronized
block only for first several concurrent messagesCherry-pick to
6.1.x