jerqi commented on code in PR #811:
URL: https://github.com/apache/incubator-uniffle/pull/811#discussion_r1162704881
##########
client-spark/common/src/main/java/org/apache/spark/shuffle/writer/WriteBufferManager.java:
##########
@@ -204,26 +207,29 @@ public List<ShuffleBlockInfo> addRecord(int partitionId,
Object key, Object valu
}
// transform all [partition, records] to [partition, ShuffleBlockInfo] and
clear cache
- public synchronized List<ShuffleBlockInfo> clear() {
+ public List<ShuffleBlockInfo> clear() {
List<ShuffleBlockInfo> result = Lists.newArrayList();
long dataSize = 0;
long memoryUsed = 0;
- for (Entry<Integer, WriterBuffer> entry : buffers.entrySet()) {
- WriterBuffer wb = entry.getValue();
- dataSize += wb.getDataLength();
- memoryUsed += wb.getMemoryUsed();
- result.add(createShuffleBlock(entry.getKey(), wb));
- copyTime += wb.getCopyTime();
+ synchronized (buffers) {
+ final Set<Entry<Integer, WriterBuffer>> entrySet = buffers.entrySet();
+ for (Entry<Integer, WriterBuffer> entry : entrySet) {
+ WriterBuffer wb = entry.getValue();
+ dataSize += wb.getDataLength();
+ memoryUsed += wb.getMemoryUsed();
+ result.add(createShuffleBlock(entry.getKey(), wb));
+ copyTime += wb.getCopyTime();
+ }
+ LOG.info("Flush total buffer for shuffleId[" + shuffleId + "] with
allocated["
+ + allocatedBytes + "], dataSize[" + dataSize + "], memoryUsed[" +
memoryUsed + "]");
+ buffers.clear();
}
- LOG.info("Flush total buffer for shuffleId[" + shuffleId + "] with
allocated["
- + allocatedBytes + "], dataSize[" + dataSize + "], memoryUsed[" +
memoryUsed + "]");
- buffers.clear();
return result;
}
// transform records to shuffleBlock
protected ShuffleBlockInfo createShuffleBlock(int partitionId, WriterBuffer
wb) {
- byte[] data = wb.getData();
+ byte[] data = wb.finalizeAndGetData();
Review Comment:
> This is a defensive programming. Once the data is gotten, the buffer is
aborted.
Is it necessary? A little weird.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]