Repository navigation
fix(jni): cache each open file's segments and merge reads across small gaps only - #66
Merged
Merged
Conversation
…l gaps only Signed-off-by: gitRasheed <[email protected]>
Collaborator
|
this looks good |
ChristopherWirt
approved these changes
Nov 2, 2026
ChristopherWirt
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the cache wiring, ownership and existing Python precedent. No blocking correctness findings. The per-open cache safely isolates segment IDs, and both JNI opening paths install it. Non-blocking follow-ups: clarify that the 64 MiB budget counts segment lengths rather than retained backing allocations, and add focused coverage for the 64 KiB coalescing change; the added regression currently covers caching with coalescing disabled. No additional tests were run during this review.
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
Closes #65. Spark reads of list-layout files read several times the bytes they need, because the JNI data
source opens files without a segment cache and a list column's element segments are requested once per row range
of a scan. On a 47 MB list-layout file of nested event data, a 29-column read now reads 13.7 MB instead of 39.5 MB,
and 15.7 MB instead of 68.8 MB when Spark splits the file in four. Before this change, the same read of the file
written without the list layout read 30.0 MB, so the list layout now pays off instead of costing more.
Changes
Both
NativeDataSource.openandopenFilesuse it.JavaReadablemerges reads across gaps of at most 64 KiB instead of 1 MiB. With a cache, a merged read thatspans a segment the cache already holds reads it again; at 1 MiB that left list-layout reads at 1.3x to 1.8x
the bytes they need, at 64 KiB 1.0x to 1.2x.
Testing
writer::tests::list_layout_scan_reads_each_segment_once: writes a list-of-struct column with the list layout,scans it as four row ranges through the data source, and checks that no segment is read twice with the JNI open
options. It also checks that without them some segments are, so the test keeps reproducing the problem.
cargo test -p vortex-jni,cargo clippy -p vortex-jni --all-targets.29-column read: list layout 21.5 to 25.0 MB before, 14.5 MB after; split in four, 77 to 92 MB before, 48.4 MB
after. Without the list layout: 30.6 MB before, 29.5 MB after. Row counts match.
Not fixed here
Spark reads each split of a file in its own task, so splits can't share a cache, and an elements segment that
spans the whole file is read once per split. Reading a list-layout file in one split avoids that
(
vortex.splitFiles=false); writing list elements in chunks that line up with the outer row chunks would fix itfor split reads too.