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

fix: Avoid potential slow Set#removeAll call in HierarchicalCommunicator (#13746) (CP: 23.0) #13815

Merged
merged 1 commit into from
May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,14 @@ private void passivateInactiveKeys(Set<String> oldActive,
}

// Finally clear any passivated items that have now been confirmed
oldActive.removeAll(newActiveKeyOrder);
/*
* Due to the implementation of AbstractSet#removeAll, if the size
* of newActiveKeyOrder is bigger than oldActive's size, then
* calling oldActive.removeAll(newActiveKeyOrder) would end up
* calling contains method for all of newActiveKeyOrder items which
* is a slow operation on lists. The following avoids that:
*/
newActiveKeyOrder.forEach(oldActive::remove);
if (!oldActive.isEmpty()) {
passivatedByUpdate.put(Integer.valueOf(updateId), oldActive);
}
Expand Down