perf: Native batch passthrough for native_iceberg_compat V1 scans [EXPERIMENTAL]#3410
Closed
andygrove wants to merge 1 commit intoapache:mainfrom
Closed
perf: Native batch passthrough for native_iceberg_compat V1 scans [EXPERIMENTAL]#3410andygrove wants to merge 1 commit intoapache:mainfrom
andygrove wants to merge 1 commit intoapache:mainfrom
Conversation
mbutrovich
reviewed
Feb 5, 2026
| * nextBatch() in passthrough mode so that CometBatchIterator.advancePassthrough() can retrieve | ||
| * it. | ||
| */ | ||
| public static final ThreadLocal<Long> CURRENT_READER_HANDLE = ThreadLocal.withInitial(() -> 0L); |
Contributor
There was a problem hiding this comment.
Claude really loves thread local variables and I always need to sit and think for a long time how it could blow up in our faces.
Eliminate the JVM data round trip for data columns in native_iceberg_compat scans. Data columns are read directly from the native BatchContext via zero-copy Arc::clone, while only partition columns cross the JVM boundary via Arrow FFI. Previously, data made a wasteful round trip: Rust ParquetSource → per-column JNI export to JVM → JVM wraps as CometVector → JVM exports ALL cols back to Rust via Arrow FFI → Rust ScanExec deep-copies every column Now in passthrough mode: Rust ParquetSource → batch stays in native BatchContext → Rust ScanExec reads data cols directly (zero-copy) → Only partition cols imported from JVM FFI (small, constant) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75750af to
57ea80b
Compare
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
native_iceberg_compatV1 scansBatchContextvia zero-copyArc::clonecurrentColumnBatchJNI export remains; theexportBatchFFI round-trip andcopy_arraydeep copy are eliminated)How it works
When
native_batch_passthroughis enabled in the Scan protobuf (auto-detected fornative_iceberg_compatCometScanExec):NativeBatchReader.nextBatch()reads the batch natively and sets a ThreadLocal handleScanExec.get_next_passthrough()callsCometBatchIterator.advancePassthrough()instead of the normalhasNext()+next()pathArc::clonefromBatchContext.current_batch(zero-copy)Files changed
native_batch_passthroughandnum_data_columnsfields toScanmessageCURRENT_READER_HANDLEThreadLocal, set after eachloadNextBatch()advancePassthrough()andnextPartitionColumnsOnly()methodsget_next_passthrough()that reads data cols from BatchContext (zero-copy)ScanExec::new()native_iceberg_compatscans and sets passthrough fieldsBatchContextandget_batch_contextpublicTest plan
ParquetReadV1Suite- all 88 tests passParquetReadV2Suite- all tests pass🤖 Generated with Claude Code