Skip to content

Commit 07988f1

Browse files
committed
core: Avoid Set.removeAll() when passing a possibly-large List (grpc#11994)
See grpc#11958
1 parent ec98fa1 commit 07988f1

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
@@ -321,7 +321,11 @@ final void reprocess(@Nullable SubchannelPicker picker) {
321321
if (!hasPendingStreams()) {
322322
return;
323323
}
324-
pendingStreams.removeAll(toRemove);
324+
// Avoid pendingStreams.removeAll() as it can degrade to calling toRemove.contains() for each
325+
// element in pendingStreams.
326+
for (PendingStream stream : toRemove) {
327+
pendingStreams.remove(stream);
328+
}
325329
// Because delayed transport is long-lived, we take this opportunity to down-size the
326330
// hashmap.
327331
if (pendingStreams.isEmpty()) {

0 commit comments

Comments
 (0)