Increase the rate of topic creation#11148
Increase the rate of topic creation#11148suiyuzeng wants to merge 6 commits intoapache:masterfrom suiyuzeng:master
Conversation
codelipenghui
left a comment
There was a problem hiding this comment.
Nice catch! But I think this will break the current behavior. Currently, we do not allow the duplicate topic name with the persistent or non-persistent domain, with this change it will only check the persistent topic duplication.
I think we should add the non-persistent topic duplication check back.
Got it. I will update later. |
|
@codelipenghui hi, can you please take a look? |
|
|
||
| } else { | ||
| return pulsar().getNamespaceService().getListOfTopics(topicName.getNamespaceObject(), | ||
| CommandGetTopicsOfNamespace.Mode.NON_PERSISTENT) |
There was a problem hiding this comment.
We have multiLayerTopicsMap in BrokerService, we don't need to traverse all topics under the namespace, and then traverse again to determine whether topic exists.
We only need to traverse the bundles, and then directly use map.contains , usually the number of bundles is not too much
eolivelli
left a comment
There was a problem hiding this comment.
very nice catch !
I am happy to see an improvement here
do we have specific test cases around this function ?
|
@315157973 @eolivelli thanks,i will Optimize the code and add some test about this function. |
|
@suiyuzeng Hello, please go on |
Sorry, a little busy recently~ |
@suiyuzeng Nice catch!
|
|
move to 2.8.2 |
|
move to 2.8.3 |
|
@suiyuzeng:Thanks for your contribution. For this PR, do we need to update docs? |
|
Removing the |
|
Closed as stale and conflict. Please rebase and resubmit the patch if it's still relevant. I believe this patch is worth continuing, but holding a stale patch doesn't work. If @suiyuzeng can rebase and resubmit the patch, I'm glad to follow the PR lifecycle. Otherwise, I may pick it up later. Close. |
Motivation
The count of topic created in 1 second is less than 200, when the topic count of the namespace is about 200,000..
Modifications
The reason is that the time cost of topic exist checking is too long when the topic count is large.
In org.apache.pulsar.broker.admin.AdminResource#checkTopicExistsAsync, all the topics would be checked one by one. As the count of topic grows, the time cost will become longer.
Can we use org.apache.pulsar.broker.namespace.NamespaceService#checkTopicExists to check if the topic is exits?
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation
Check the box below and label this PR (if you have committer privilege).
Need to update docs?
doc-required(If you need help on updating docs, create a doc issue)
no-need-doccode optimize
doc(If this PR contains doc changes)