Skip to content

Conversation

@cxzl25
Copy link
Contributor

@cxzl25 cxzl25 commented Sep 4, 2024

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

@github-actions github-actions bot added the CORE label Sep 4, 2024
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also confirmed that these three are the only instances in main code.

$ git grep ByteBuffer.allocateDirect | grep -v Platform | grep -v test
core/src/main/java/org/apache/spark/io/NioBufferedFileInputStream.java:    byteBuffer = ByteBuffer.allocateDirect(bufferSizeInBytes);
core/src/main/scala/org/apache/spark/storage/DiskStore.scala:  private val buffer = ByteBuffer.allocateDirect(64 * 1024)
core/src/main/scala/org/apache/spark/util/DirectByteBufferOutputStream.scala:    val newBuffer = ByteBuffer.allocateDirect(newCapacity)

dongjoon-hyun pushed a commit that referenced this pull request Sep 4, 2024
…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]>
@dongjoon-hyun
Copy link
Member

Merged to master/3.5 for Apache Spark 3.5.3.

turboFei pushed a commit to turboFei/spark that referenced this pull request Nov 6, 2025
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants