Skip to content

Commit 1a895cc

Browse files
authored
core: Avoid Set.removeAll() when passing a possibly-large List (#11994) (#12002)
See #11958
1 parent 5d55fc1 commit 1a895cc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/src/main/java/io/grpc/internal/DelayedClientTransport.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,11 @@ final void reprocess(@Nullable SubchannelPicker picker) {
316316
if (!hasPendingStreams()) {
317317
return;
318318
}
319-
pendingStreams.removeAll(toRemove);
319+
// Avoid pendingStreams.removeAll() as it can degrade to calling toRemove.contains() for each
320+
// element in pendingStreams.
321+
for (PendingStream stream : toRemove) {
322+
pendingStreams.remove(stream);
323+
}
320324
// Because delayed transport is long-lived, we take this opportunity to down-size the
321325
// hashmap.
322326
if (pendingStreams.isEmpty()) {

0 commit comments

Comments
 (0)