Skip to content
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

[ISSUE #7189] Optimize time complexity of loop in ConsumerGroupInfo#updateSubscription #7190

Merged
merged 1 commit into from Aug 16, 2023

Conversation

drpmma
Copy link
Contributor

@drpmma drpmma commented Aug 15, 2023

Which Issue(s) This PR Fixes

Fixes #7189

Brief Description

The current implementation of the updateSubscription method in the code has a potential issue with the time complexity of the loop. The loop iterates over the subscription table to check if a topic exists in the subscription list. This results in a time complexity of O(n) for each iteration.

To optimize the time complexity, we can introduce an additional HashSet to store the new topics. By doing so, we can perform a constant time (O(1)) lookup instead of iterating over the subscription table in the loop. This will significantly reduce the time complexity of the loop.

How Did You Test This Change?

No need.

@codecov-commenter
Copy link

Codecov Report

Merging #7190 (484b67f) into develop (f534501) will decrease coverage by 0.03%.
Report is 5 commits behind head on develop.
The diff coverage is 100.00%.

❗ Current head 484b67f differs from pull request most recent head 96cf0ec. Consider uploading reports for the commit 96cf0ec to get more accurate results

@@              Coverage Diff              @@
##             develop    #7190      +/-   ##
=============================================
- Coverage      42.52%   42.50%   -0.03%     
+ Complexity      9357     9355       -2     
=============================================
  Files           1149     1149              
  Lines          82043    82042       -1     
  Branches       10701    10699       -2     
=============================================
- Hits           34889    34870      -19     
- Misses         42792    42815      +23     
+ Partials        4362     4357       -5     
Files Changed Coverage Δ
...ache/rocketmq/broker/client/ConsumerGroupInfo.java 79.09% <100.00%> (-0.74%) ⬇️
.../org/apache/rocketmq/proxy/config/ProxyConfig.java 54.20% <100.00%> (ø)

... and 19 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@lollipopjin lollipopjin merged commit 5a3de92 into apache:develop Aug 16, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] Optimize time complexity of loop in ConsumerGroupInfo#updateSubscription method
4 participants