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 <rovarga@cisco.com>
import com.google.common.collect.ImmutableMap.Builder;
import com.google.protobuf.ByteString;
import java.io.IOException;
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.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;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
private Cancellable heartbeatSchedule = null;
private Cancellable heartbeatSchedule = null;
- private final Collection<ClientRequestTracker> trackerList = new ArrayList<>();
+ private final Collection<ClientRequestTracker> trackerList = new LinkedList<>();
protected final int minReplicationCount;
protected final int minReplicationCount;