You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 callingb.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.
The text was updated successfully, but these errors were encountered: