GitHub user caneGuy opened a pull request:
https://github.com/apache/spark/pull/18723
[SPARK-21517][CORE] Avoid copying memory when transfer chunks remotely
## What changes were proposed in this pull request?
In our production cluster,oom happens when NettyBlockRpcServer receive
OpenBlocks message.The reason we observed is below:
When BlockManagerManagedBuffer call ChunkedByteBuffer#toNetty, it will use
Unpooled.wrappedBuffer(ByteBuffer... buffers) which use default
maxNumComponents=16 in low-level CompositeByteBuf.When our component's number
is bigger than 16, it till execute consolidateIfNeeded
int numComponents = this.components.size();
if(numComponents > this.maxNumComponents) {
int capacity =
((CompositeByteBuf.Component)this.components.get(numComponents - 1)).endOffset;
ByteBuf consolidated = this.allocBuffer(capacity);
for(int c = 0; c < numComponents; ++c) {
CompositeByteBuf.Component c1 =
(CompositeByteBuf.Component)this.components.get(c);
ByteBuf b = c1.buf;
consolidated.writeBytes(b);
c1.freeIfNecessary();
}
CompositeByteBuf.Component var7 = new
CompositeByteBuf.Component(consolidated);
var7.endOffset = var7.length;
this.components.clear();
this.components.add(var7);
}
in CompositeByteBuf which will consume some memory.
## How was this patch tested?
Test in production cluster.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/caneGuy/spark zhoukang/fix-chunkbuffer
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/18723.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #18723
----
commit ab82c3ee043fdca6b1da15536c9e28a697856c91
Author: zhoukang <[email protected]>
Date: 2017-07-24T08:15:32Z
[SPARK][CORE] Avoid copying memory when transfer chunks remotely
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]