Repository navigation
fix(jni): retain Java Arrow buffers independently - #11069
Merged
robert3005 merged 6 commits intoNov 3, 2026
Merged
robert3005 merged 6 commits into
robert3005 merged 6 commits into
Conversation
robert3005
reviewed
Nov 2, 2026
Contributor
|
We can merge this once you rebase - I have been merging fixes to the jni bindings |
robert3005
approved these changes
Nov 2, 2026
Signed-off-by: Christopher Wirt <cwirt@quantcast.com>
Only native code should retain or release the wrapped allocation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Christopher Wirt <cwirt@quantcast.com>
Signed-off-by: Christopher Wirt <cwirt@quantcast.com>
ChristopherWirt
force-pushed
the
cwirt/upstream-jni-independent-buffers
branch
from
November 2, 2026 19:06
46de578 to
8e2e3b6
Compare
robert3005
enabled auto-merge (squash)
November 2, 2026 19:10
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
Signed-off-by: Christopher Wirt <cwirt@quantcast.com>
auto-merge was automatically disabled
November 2, 2026 20:28
Head branch was pushed to by a user without write access
robert3005
enabled auto-merge (squash)
November 3, 2026 12:19
Signed-off-by: Christopher Wirt <cwirt@quantcast.com>
auto-merge was automatically disabled
November 3, 2026 13:17
Head branch was pushed to by a user without write access
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.
Summary
Tracking issue: #11068
Problem: An Arrow C Data Interface import gives every buffer in a batch one shared release callback. The writer keeps small slices of each batch (e.g. validity bitmaps) until
finish, so each slice keeps its whole batch allocated. In a 615-column Spark job this held ~4.7 GB untilfinish.Fix: A new
VortexWriter.writeBatch(VectorSchemaRoot, BufferAllocator)overload retains each Java Arrow allocation separately. It points the imported Rust buffers at those owners, with the same addresses and no copy. A retained bitmap now keeps only its own allocation alive. Spark uses the new overload.Result: In a synthetic nested-string workload (16 × 8,192 rows), memory held before
finishdrops from ~65 MiB to 8.1 MiB. Everything is released atfinish. The production workload has not been rerun yet.Changes
writeBatch(root, allocator)overload. It validates the root against the writer's stored schema, so there is no schema export per batch.vortex-jni/src/buffer): Retain each Java allocation and make it the owner of the matching imported buffers. The last Rust reference releases it, including from native worker threads.VortexOutputWriteruses the new overload.writeBatchoverloads are now serialized withfinish. The builder now releases its temporaryArrowSchema(previously leaked).API notes
writeBatch(long, long)is unchanged and still uses the producer's shared release callback.Testing
New tests cover independent buffer lifetimes, cleanup after a partial import or sink failure, empty batches, string views, unaligned inputs, schema mismatch, release from native threads, and concurrent write/
finish. The string and nested-map round-trip tests now run against both APIs.On the fork (quantcast#49, same change):
testParquetVariantRoundTripwas already@Disabled)VortexDataSourceWriteTest: 11 passed-D warnings), pinned rustfmt, Java format checks andgit diff --checkpassedThis branch ports that change onto
develop. The Spark conflict was resolved by keeping upstream's row-building code and replacing only the export/write block. Onlygit diff --checkhas been run on the port.Known issue (not fixed here)
String-view concatenation reads metadata from null view slots. The view round-trip test initializes those slots to work around it.
AI assistance
Disclosed per the AI policy: AI tools helped write and review the source change. Codex prepared this upstream port, issue and PR description at my request. I am the responsible contributor.