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

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

Closed
1 task done
drpmma opened this issue Aug 15, 2023 · 0 comments · Fixed by #7190
Closed
1 task done

Comments

@drpmma
Copy link
Contributor

drpmma commented Aug 15, 2023

Before Creating the Enhancement Request

  • I have confirmed that this should be classified as an enhancement rather than a bug/feature.

Summary

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.

Motivation

Optimize performance for a large scale of subscriptions.

Describe the Solution You'd Like

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.

Describe Alternatives You've Considered

No

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant