feat(#1798) Performance fix for topic send#1792
Conversation
…mprove concurrency Also remove the dispatch out of the lock.
8cf513f to
be653cb
Compare
|
@jeanouii - This is an interesting find, I didn't even notice that synchronized keyword on that method. Most of the synchronization happens internally on the various collections etc. and I looked and I didn't see synchronized use anywhere else on the topic object itself internally. Did you look around the broker to see if anything happens to synchronize the topic externally? The destinations often get referred to more generic as RegionDestination plus there's various wrappers so saerching might be tricky. I will search too, I just am curious if anything else is synchronizing on the Topic's intrinsic lock that would now break if we switch the lock. I guess there's always the risk of breaking existing plugins (if they were synchronizing for some reason on the topic) but we can't control any custom code so not much we could do in that scenario. |
|
@cshannon thanks for the review Chris.
Queue.doMessageSend() is already NOT synchronized I agree about the external plugin risk. There is nothing we can reallly do right? |
|
@jeanouii do you have any benchmark numbers b/w the current and the proposed change? I'd like to consider this for v6.3.0 (and 5.x backport) |
| <dependency> | ||
| <groupId>org.openjdk.jmh</groupId> | ||
| <artifactId>jmh-core</artifactId> | ||
| <version>1.37</version> |
There was a problem hiding this comment.
dependency versions should be moved to top-level pom.xml
|
M3 benchmark output |
|
Thanks @mattrpav for the review and microbenchmark run. Is it with the PR or without? |
|
@jeanouii - I just wanted to add a comment that this hasn't been forgotten about and will still be targeted for 6.3.0 at least (and possible backport). We've just gotten hammered with all the AI generated reports the last few months (like every other open source project) so everyone's focus has been on that and 6.3.0 has gotten delayed. |
|
@jeanouii - can you rebase this with main? |
cshannon
left a comment
There was a problem hiding this comment.
I'm doing some testing now but this looks pretty good.
This narrows the lock further and the previous intrinsic lock wasn't used anywhere else anyways. This is only on the doSend() method and not the top level send so Id on't see any risk of deadlocks or other weirdness with destination interceptors
Originally I was wondering if this would still work to guarantee ordering for async producers because they would not wait for a response. But I realized that every TransportConnection is going to process commands in order it receives them per connection, so the broker should never be calling the send method for two different messages from the same producer at the same time.
cshannon
left a comment
There was a problem hiding this comment.
I'll merge and do a follow on update for the versions
|
@mattrpav - I removed 5.19.x as I think we should consider this a feature and we need to only be back porting fixes at this point to 5.19.x with the plan to EOL at some point |
To be discussed