feat: account JVM UDF Arrow allocations in Spark task memory - #5027
Open
peterxcli wants to merge 12 commits into
Open
feat: account JVM UDF Arrow allocations in Spark task memory#5027peterxcli wants to merge 12 commits into
peterxcli wants to merge 12 commits into
Conversation
…r-for-jvmdispatch
…r-for-jvmdispatch
…r-as-spark=memory-consumer-for-jvmdispatch
…r-for-jvmdispatch
…r-for-jvmdispatch
Member
Author
|
@sunchao would you like to take a look at this? TIA! |
sunchao
reviewed
Aug 22, 2026
sunchao
left a comment
Member
There was a problem hiding this comment.
Two P2 findings in task-allocator concurrency, detailed inline. Validated with targeted JVM reproductions against this exact head and Arrow 18.3.0. The native producer/cleanup paths were source-traced, not run end-to-end.
Member
|
@peterxcli can you check the CI failures? |
Member
Author
@sunchao I opened a fix for it |
Member
|
Ah thanks! Approved the PR and will merge soon |
…r-for-jvmdispatch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which issue does this PR close?
Closes #4174.
Rationale for this change
CometScalaUDFCodegen, currently the onlyCometUDFimplementation, creates output Arrow vectors from the process-wideCometArrowAllocator. These JVM allocations bypass Spark’s task memory accounting.FFI input vectors only wrap native-owned buffers that are already accounted by Comet, so they must not be charged again. Output buffers, however, are created on the JVM and may remain alive through the FFI release callback after the Java vector closes.
What changes are included in this PR?
MemoryConsumer.CometUDFinterface and codegen output path.How are these changes tested?
Added
CometUdfBridgeTestcovering allocation accounting, FFI retention, task completion, and final cleanup. The focused test passes with Spark 4.1 and Spark 3.5/Scala 2.12.Also ran few scala script with spark shell to verify: