-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-49217][CORE] Support separate buffer size configuration in UnsafeShuffleWriter #47733
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
Conversation
mridulm
left a comment
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.
The change looks reasonable.
+CC @JoshRosen as well.
As a side note, should we be using Platform.allocateDirectBuffer for NioBufferedFileInputStream as well @JoshRosen ?
JoshRosen
left a comment
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.
LGTM, as this looks reasonable to me as well: this is a bit of a low-level configuration but it seems fine to allow it to be tuned.
As a side note, should we be using Platform.allocateDirectBuffer for NioBufferedFileInputStream as well @JoshRosen ?
The difference between ByteBuffer.allocateDirect and Platform.allocateDirectBuffer is that the latter bypasses / ignores the JVM's -XX:MaxDirectMemorySize limit.
Given that almost all other Spark-initiated allocations use the Platform version, we probably should make that change.
That said, I also spot another ByteBuffer.allocateDirect usage at
spark/core/src/main/scala/org/apache/spark/storage/DiskStore.scala
Lines 327 to 328 in 9b9a7a7
| private val buffer = ByteBuffer.allocateDirect(64 * 1024) | |
| buffer.flip() |
StorageUtils.dispose() calls for that other call in ReadableChannelFileRegion (which is only used by EncryptedBlockData, as far as I know, though), so perhaps it would be better to update both of those in a separate PR instead of doing it here.
|
I also found another one, which uses We can do this in another PR. spark/core/src/main/scala/org/apache/spark/util/DirectByteBufferOutputStream.scala Lines 31 to 32 in 4ceacbe
spark/core/src/main/scala/org/apache/spark/util/DirectByteBufferOutputStream.scala Lines 60 to 63 in 4ceacbe
|
|
Merged to master. |
|
@cxzl25, please do verify if the jira has been updated correctly - thanks ! |
…yteBuffer.allocateDirect` ### What changes were proposed in this pull request? This PR aims to use `Platform.allocateDirectBuffer` instead of `ByteBuffer.allocateDirect`. ### Why are the changes needed? #47733 (review) Allocating off-heap memory should use the `allocateDirectBuffer` API provided `by Platform`. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? GA ### Was this patch authored or co-authored using generative AI tooling? No Closes #47987 from cxzl25/SPARK-49509. Authored-by: sychen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
…yteBuffer.allocateDirect` This PR aims to use `Platform.allocateDirectBuffer` instead of `ByteBuffer.allocateDirect`. #47733 (review) Allocating off-heap memory should use the `allocateDirectBuffer` API provided `by Platform`. No GA No Closes #47987 from cxzl25/SPARK-49509. Authored-by: sychen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 2ed6c3e) Signed-off-by: Dongjoon Hyun <[email protected]>
…afeShuffleWriter ### What changes were proposed in this pull request? This PR aims to support separate buffer size configuration in UnsafeShuffleWriter. Introduce `spark.shuffle.file.merge.buffer` configuration. ### Why are the changes needed? `UnsafeShuffleWriter#mergeSpillsWithFileStream` uses `spark.shuffle.file.buffer` as the buffer for reading spill files, and this buffer is an off-heap buffer. In the spill process, we hope that the buffer size is larger, but once there are too many files in the spill, `UnsafeShuffleWriter#mergeSpillsWithFileStream` needs to create a lot of off-heap memory, which makes the executor easily killed by YARN. https://github.com/apache/spark/blob/e72d21c299a450e48b3cf6e5d36b8f3e9a568088/core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java#L372-L375 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Production environment verification ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47733 from cxzl25/SPARK-49217. Authored-by: sychen <[email protected]> Signed-off-by: Mridul Muralidharan <mridul<at>gmail.com>
…yteBuffer.allocateDirect` ### What changes were proposed in this pull request? This PR aims to use `Platform.allocateDirectBuffer` instead of `ByteBuffer.allocateDirect`. ### Why are the changes needed? apache#47733 (review) Allocating off-heap memory should use the `allocateDirectBuffer` API provided `by Platform`. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? GA ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47987 from cxzl25/SPARK-49509. Authored-by: sychen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
…afeShuffleWriter ### What changes were proposed in this pull request? This PR aims to support separate buffer size configuration in UnsafeShuffleWriter. Introduce `spark.shuffle.file.merge.buffer` configuration. ### Why are the changes needed? `UnsafeShuffleWriter#mergeSpillsWithFileStream` uses `spark.shuffle.file.buffer` as the buffer for reading spill files, and this buffer is an off-heap buffer. In the spill process, we hope that the buffer size is larger, but once there are too many files in the spill, `UnsafeShuffleWriter#mergeSpillsWithFileStream` needs to create a lot of off-heap memory, which makes the executor easily killed by YARN. https://github.com/apache/spark/blob/e72d21c299a450e48b3cf6e5d36b8f3e9a568088/core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java#L372-L375 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Production environment verification ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47733 from cxzl25/SPARK-49217. Authored-by: sychen <[email protected]> Signed-off-by: Mridul Muralidharan <mridul<at>gmail.com>
…yteBuffer.allocateDirect` ### What changes were proposed in this pull request? This PR aims to use `Platform.allocateDirectBuffer` instead of `ByteBuffer.allocateDirect`. ### Why are the changes needed? apache#47733 (review) Allocating off-heap memory should use the `allocateDirectBuffer` API provided `by Platform`. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? GA ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47987 from cxzl25/SPARK-49509. Authored-by: sychen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
…afeShuffleWriter ### What changes were proposed in this pull request? This PR aims to support separate buffer size configuration in UnsafeShuffleWriter. Introduce `spark.shuffle.file.merge.buffer` configuration. ### Why are the changes needed? `UnsafeShuffleWriter#mergeSpillsWithFileStream` uses `spark.shuffle.file.buffer` as the buffer for reading spill files, and this buffer is an off-heap buffer. In the spill process, we hope that the buffer size is larger, but once there are too many files in the spill, `UnsafeShuffleWriter#mergeSpillsWithFileStream` needs to create a lot of off-heap memory, which makes the executor easily killed by YARN. https://github.com/apache/spark/blob/e72d21c299a450e48b3cf6e5d36b8f3e9a568088/core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java#L372-L375 ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Production environment verification ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47733 from cxzl25/SPARK-49217. Authored-by: sychen <[email protected]> Signed-off-by: Mridul Muralidharan <mridul<at>gmail.com>
…yteBuffer.allocateDirect` ### What changes were proposed in this pull request? This PR aims to use `Platform.allocateDirectBuffer` instead of `ByteBuffer.allocateDirect`. ### Why are the changes needed? apache#47733 (review) Allocating off-heap memory should use the `allocateDirectBuffer` API provided `by Platform`. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? GA ### Was this patch authored or co-authored using generative AI tooling? No Closes apache#47987 from cxzl25/SPARK-49509. Authored-by: sychen <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
…yteBuffer.allocateDirect` (apache#557) This PR aims to use `Platform.allocateDirectBuffer` instead of `ByteBuffer.allocateDirect`. apache#47733 (review) Allocating off-heap memory should use the `allocateDirectBuffer` API provided `by Platform`. No GA No Closes apache#47987 from cxzl25/SPARK-49509. Authored-by: sychen <[email protected]> (cherry picked from commit 2ed6c3e) Signed-off-by: Dongjoon Hyun <[email protected]> Co-authored-by: sychen <[email protected]>
What changes were proposed in this pull request?
This PR aims to support separate buffer size configuration in UnsafeShuffleWriter.
Introduce
spark.shuffle.file.merge.bufferconfiguration.Why are the changes needed?
UnsafeShuffleWriter#mergeSpillsWithFileStreamusesspark.shuffle.file.bufferas the buffer for reading spill files, and this buffer is an off-heap buffer.In the spill process, we hope that the buffer size is larger, but once there are too many files in the spill,
UnsafeShuffleWriter#mergeSpillsWithFileStreamneeds to create a lot of off-heap memory, which makes the executor easily killed by YARN.spark/core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java
Lines 372 to 375 in e72d21c
Does this PR introduce any user-facing change?
No
How was this patch tested?
Production environment verification
Was this patch authored or co-authored using generative AI tooling?
No