Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Improve memory usage of SendWorkerOneMessageToManyRequest #72

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,42 @@ public void doRequest(ServerData serverData) {
partitionIdMsgs.put(partitionId, idMsgs);
}
idMsgs.add(vertexId, msg);
}

// Read ByteArrayVertexIdMessages and write to message store
for (Entry<Integer, ByteArrayVertexIdMessages> idMsgs :
partitionIdMsgs.entrySet()) {
if (!idMsgs.getValue().isEmpty()) {
serverData.getIncomingMessageStore().addPartitionMessages(
idMsgs.getKey(), idMsgs.getValue());
// If any of the list of messages reaches the expected initialSize
// threshold, then move everything we have so far to the message store.
// This avoids maintaining large intermediate lists of messages.
if (idMsgs.getSize() >= initialSize) {
addMessagesToStore(partitionIdMsgs,
serverData.getIncomingMessageStore());
partitionIdMsgs.clear();
}
}

// Move any remaining messages to the message store
addMessagesToStore(partitionIdMsgs, serverData.getIncomingMessageStore());
}
}

/**
* Adds the provided per partition messages from the hashmap to the message
* store.
*
* @param partitionIdMsgs Per partition messages
* @param messageStore Message store instance
* @param <I> Vertex ID type
* @param <M> Message type
*/
private static <I extends WritableComparable, M extends Writable> void
addMessagesToStore(
Int2ObjectOpenHashMap<ByteArrayVertexIdMessages> partitionIdMsgs,
MessageStore<I, M> messageStore) {

for (Entry<Integer, ByteArrayVertexIdMessages> idMsgs :
partitionIdMsgs.entrySet()) {

if (!idMsgs.getValue().isEmpty()) {
messageStore.addPartitionMessages(idMsgs.getKey(), idMsgs.getValue());
}
}
}
}
Loading