From db4f9d10a8b2ddb46300635b9993c6fffeb9b394 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sun, 25 Jan 2015 09:50:11 +0100 Subject: [PATCH] Change trackerList to a LinkedList The trackers are being added to the end and usually remove in a linear fashion. An ArrayList's remove() method makes sure the backing array is packed -- which means we end up copying the array over and over again. Changing the trackerList to a LinkedList removes the need for copying at the expense of memory footprint and cache locality. Change-Id: I3e40487798eb64713ed4526f53a0a8c385a9a778 Signed-off-by: Robert Varga --- .../controller/cluster/raft/behaviors/AbstractLeader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java index ab11c5bd84..462c94ec8a 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java @@ -18,11 +18,11 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import com.google.protobuf.ByteString; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -85,7 +85,7 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { private Cancellable heartbeatSchedule = null; - private final Collection trackerList = new ArrayList<>(); + private final Collection trackerList = new LinkedList<>(); protected final int minReplicationCount; -- 2.36.6