From ab82c3ee043fdca6b1da15536c9e28a697856c91 Mon Sep 17 00:00:00 2001 From: zhoukang Date: Mon, 24 Jul 2017 16:15:32 +0800 Subject: [PATCH 1/2] [SPARK][CORE] Avoid copying memory when transfer chunks remotely --- .../main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala b/core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala index 2f905c8af0f63..69c3ea0286b87 100644 --- a/core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala +++ b/core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala @@ -66,7 +66,7 @@ private[spark] class ChunkedByteBuffer(var chunks: Array[ByteBuffer]) { * Wrap this buffer to view it as a Netty ByteBuf. */ def toNetty: ByteBuf = { - Unpooled.wrappedBuffer(getChunks(): _*) + Unpooled.wrappedBuffer(chunks.length + 1, getChunks(): _*) } /** From 4c576a4d81c6af744fab28a9363061885a8aeb91 Mon Sep 17 00:00:00 2001 From: zhoukang Date: Tue, 25 Jul 2017 14:05:38 +0800 Subject: [PATCH 2/2] Use chunks.length instead --- .../main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala b/core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala index 69c3ea0286b87..f48bfd5c25f77 100644 --- a/core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala +++ b/core/src/main/scala/org/apache/spark/util/io/ChunkedByteBuffer.scala @@ -66,7 +66,7 @@ private[spark] class ChunkedByteBuffer(var chunks: Array[ByteBuffer]) { * Wrap this buffer to view it as a Netty ByteBuf. */ def toNetty: ByteBuf = { - Unpooled.wrappedBuffer(chunks.length + 1, getChunks(): _*) + Unpooled.wrappedBuffer(chunks.length, getChunks(): _*) } /**