Skip to content
Snippets Groups Projects
Commit a612f667 authored by Michael Eischer's avatar Michael Eischer
Browse files

Use ArrayList for update send queue instead of a LinkedList

Unless we need to remove elements in the middle of a list, an array based variant is always faster.
parent 2a2b1e25
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ public class REFITExecutor {
this.enableCheckpoints = false;
this.createLightWeightCheckpoints = false;
this.enableUpdates = false;
this.updateSendQueue = new LinkedList<>();
this.updateSendQueue = new ArrayList<>();
this.nodeProgresses = new long[REFITConfig.ADDRESSES.length];
Arrays.fill(nodeProgresses, -1L);
this.replyHashes = new byte[REFITConfig.ADDRESSES.length][];
......@@ -343,7 +343,7 @@ public class REFITExecutor {
// ###########
private boolean enableUpdates;
private final Queue<REFITUpdate> updateSendQueue;
private final List<REFITUpdate> updateSendQueue;
public void setEnableUpdates(boolean enableUpdates) {
......@@ -409,12 +409,12 @@ public class REFITExecutor {
REFITUpdateMessage update;
if (updateSendQueue.size() > 1) {
// Assign batch update the UID and agreement sequence number of the first individual update
REFITUpdate firstUpdate = updateSendQueue.peek();
REFITUpdate firstUpdate = updateSendQueue.get(0);
update = new REFITBatchUpdate(firstUpdate.agreementSeqNr(), replicaID, updateSendQueue);
updateSendQueue.clear();
} else {
update = updateSendQueue.poll();
update = updateSendQueue.get(0);
}
updateSendQueue.clear();
updateSender.broadcast(update);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment