[SPARK-14290][SPARK-13352][CORE][backport-1.6] avoid significant memory copy in Netty's tran… #12296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
When netty transfer data that is not
FileRegion, data will be in format ofByteBuf, If the data is large, there will occur significant performance issue because there is memory copy underlying insun.nio.ch.IOUtil.write, the CPU is 100% used, and network is very low.In this PR, if data size is large, we will split it into small chunks to call
WritableByteChannel.write(), so that avoid wasting of memory copy. Because the data can't be written within a single write, and it will calltransferTomultiple times.How was this patch tested?
Spark unit test and manual test.
Manual test:
sc.parallelize(Array(1,2,3),3).mapPartitions(a=>Array(new Array[Double](1024 * 1024 * 50)).iterator).reduce((a,b)=> a).lengthFor more details, please refer to SPARK-14290