-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-21527][CORE] Use buffer limit in order to use JAVA NIO Util's buffercache #18730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
7cbadc5
fc91f96
bab91db
72aef67
4789772
aeabe1d
ca77b51
e84a6d7
d708142
33a2796
ab384d4
b669351
717f886
9d3004d
e48f44f
fc184aa
f1d67a3
14ca824
a02575e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,8 @@ private[spark] class ChunkedByteBuffer(var chunks: Array[ByteBuffer]) { | |
| require(chunks != null, "chunks must not be null") | ||
| require(chunks.forall(_.position() == 0), "chunks' positions must be 0") | ||
|
|
||
| private val NIO_BUFFER_LIMIT = 64 * 1024 * 1024 // Chunk size in bytes | ||
|
|
||
| private[this] var disposed: Boolean = false | ||
|
|
||
| /** | ||
|
|
@@ -62,6 +64,19 @@ private[spark] class ChunkedByteBuffer(var chunks: Array[ByteBuffer]) { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Write this buffer to a channel with slice. | ||
| */ | ||
| def writeWithSlice(channel: WritableByteChannel): Unit = { | ||
|
||
| for (bytes <- getChunks()) { | ||
| val capacity = bytes.limit() | ||
|
||
| while (bytes.position() < capacity) { | ||
| bytes.limit(Math.min(capacity, bytes.position + NIO_BUFFER_LIMIT.toInt)) | ||
|
||
| channel.write(bytes) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Wrap this buffer to view it as a Netty ByteBuf. | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tested with different numbers? is 64mb the best choice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually i did not tested too much, it depends on value from our cluster.And i do some simple test then found 64mb will not affect perfomance compared with logic before.And benifit is we only need one buffer cache for block larger than 64 mb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we make it configurable? we can add a new entry in
org.apache.spark.internal.config, and mark it as an internal config first.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i will refactor later.Thanks for your suggestion.