Change pruneNoLongerPending to accept Set instead of Collection Previously while we are looking up the collection using .contains(), it was an O(n) operation and resulting in degredation of pruning performance when the number of tasks in storage is high. Change it to use Set instead. Change-Id: Ibba32198049536177f51a1c19d79a8ed181faa73
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java index 4abb295..5310c14 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/ReplicationQueue.java
@@ -229,7 +229,7 @@ @Override public void onDone() { if (Prune.TRUE.equals(prune)) { - pruneNoLongerPending(taskNamesByReplicateRefUpdate.values()); + pruneNoLongerPending(new HashSet<>(taskNamesByReplicateRefUpdate.values())); } replaying.set(false); } @@ -242,7 +242,7 @@ } } - private void pruneNoLongerPending(Collection<String> prunableTaskNames) { + private void pruneNoLongerPending(Set<String> prunableTaskNames) { // Queue tasks have wrappers around them so workQueue.getTasks() does not return the PushOnes. // We also cannot access them by taskId since PushOnes don't have a taskId, they do have // an Id, but it is not the id assigned to the task in the queues. The tasks in the queue