-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][broker] Choose random thread for consumerFlow in PersistentDispatcherSingleActiveConsumer #20522
[improve][broker] Choose random thread for consumerFlow in PersistentDispatcherSingleActiveConsumer #20522
Conversation
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.
The reason we chooseThread(topicName)
is that we'd like to order all tasks of the same topics.
This patch can introduce new race conditions that different consumers of the same topics now submit tasks that can be run concurrently. Please provide more details on how this patch won't cause such regressions.
why we need to use the same thread with the different sub in the same topic? #1522 only to mmon thread for frequence operations, don't need to promise the different dispatcher with the same topic need to use the same thread |
@congbobo184 Thank you! This is the evidence I ask for fulfilling the description :D |
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.
LGTM
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.
LGTM
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.
LGTM!
725d1b9
to
2c8bc30
Compare
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.
@AnonHxy - do you have any metrics to show how this affects performance?
For what it's worth, I see that the PersistentDispatcherMultipleConsumers
uses this same logic and that the primary synchronization withinPersistentDispatcherSingleActiveConsumer
is on the object itself, so I don't see any reason that we shouldn't make this change.
There is no specific metrcs for this, but this patch solves the problem that too many subscriptions in one topic will consume slow in my in production environment. @michaeljmarshall |
Motivation
Currently, all subscriptions of one topic will do
consuemrFlow
action in a single thread, which is chosen by topicName:If there is a large number of subscriptions in a topic, all the work will focus on one thread ---- the chosen thread, which will reduce the consume performance. So this this patch , I'd like to choose a ramdom thread for
consumerFlow
inPersistentDispatcherSingleActiveConsumer
to improve the consume performance.Modifications
topic.getBrokerService().getTopicOrderedExecutor().chooseThread(topicName);
->topic.getBrokerService().getTopicOrderedExecutor().chooseThread();
this.topicExecutor
->this.executor
Verifying this change
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: AnonHxy#42