You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/04 23:29:27 UTC

[GitHub] vanzin commented on a change in pull request #23602: [SPARK-26674][CORE]Consolidate CompositeByteBuf when reading large frame

vanzin commented on a change in pull request #23602: [SPARK-26674][CORE]Consolidate CompositeByteBuf when reading large frame
URL: https://github.com/apache/spark/pull/23602#discussion_r253687077
 
 

 ##########
 File path: common/network-common/src/main/java/org/apache/spark/network/util/TransportFrameDecoder.java
 ##########
 @@ -141,10 +153,20 @@ private ByteBuf decodeNext() {
 
     // Otherwise, create a composite buffer.
     CompositeByteBuf frame = buffers.getFirst().alloc().compositeBuffer(Integer.MAX_VALUE);
+    long lastConsolidatedCapacity = 0L;
     while (remaining > 0) {
       ByteBuf next = nextBufferForFrame(remaining);
       remaining -= next.readableBytes();
       frame.addComponent(next).writerIndex(frame.writerIndex() + next.readableBytes());
+      if (frame.capacity() - lastConsolidatedCapacity >= consolidateBufsThreshold) {
 
 Review comment:
   If your goal is really to save memory, shouldn't you be doing the consolidation earlier, before you have all the data for the frame?
   
   Otherwise, because of the return in L139, you basically are wasting this memory anyway until the whole frame arrives.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org