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

Improve performance of arrayDiff #1737

Open
mhahnenberg opened this issue Feb 18, 2025 · 1 comment
Open

Improve performance of arrayDiff #1737

mhahnenberg opened this issue Feb 18, 2025 · 1 comment

Comments

@mhahnenberg
Copy link

Is your feature request related to a problem? Please describe.
We've observed arrayDiff in some profiling we've done in production when subscribing to a topic with a nontrivial number of partitions (e.g. > 1000) with a relatively high fetch rate. After checking out the code it appears that arrayDiff is written in a way that is O(n*m) since it's iterating over a and calling b.indexOf() for each element.

Describe the solution you'd like
Using a Set could be an easy way to make each of the checks inside the loop O(1) instead of O(n) with indexOf, thus making the overall function O(n+m) rather than O(n*m).

Additional context
I've written a simple PR that does this, will attach after filing this issue.

@mhahnenberg
Copy link
Author

PR for a simple fix is #1738

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

No branches or pull requests

1 participant