[X-2692] Vortex Segment Cache#4
Closed
ch-sc wants to merge 6 commits into
Closed
Conversation
Signed-off-by: Christoph Schulze <christoph.schulze@polygon.io>
…rtex-datafusion-segment-cache Signed-off-by: Christoph Schulze <christoph.schulze@polygon.io>
Signed-off-by: Christoph Schulze <christoph.schulze@polygon.io>
Signed-off-by: Christoph Schulze <christoph.schulze@polygon.io>
Signed-off-by: Christoph Schulze <christoph.schulze@polygon.io>
Collaborator
Author
|
Closing this as we need to merge into vortex 0.65.0 and this one is way ahead. Switched to new PR: #5 |
ch-sc
pushed a commit
that referenced
this pull request
Jun 1, 2026
## Summary Fix for the second part of: vortex-data#7808 ``` (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x000076a38cc4527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x000076a38cc288ff in __GI_abort () at ./stdlib/abort.c:79 #5 0x000076a38cc297b6 in __libc_message_impl (fmt=fmt@entry=0x76a38cdce8d7 "%s\n") at ../sysdeps/posix/libc_fatal.c:134 #6 0x000076a38cca8ff5 in malloc_printerr ( str=str@entry=0x76a38cdd1bf0 "free(): double free detected in tcache 2") at ./malloc/malloc.c:5775 #7 0x000076a38ccab55f in _int_free (av=0x76a38ce03ac0 <main_arena>, p=<optimized out>, have_lock=0) at ./malloc/malloc.c:4541 vortex-data#8 0x000076a38ccaddce in __GI___libc_free (mem=0x5be5cd9632c0) at ./malloc/malloc.c:3398 vortex-data#9 0x000076a38eb6807e in alloc::alloc::dealloc (ptr=0x5be5cd9632c0, layout=...) at /home/ubuntu/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:114 vortex-data#10 alloc::alloc::{impl#1}::deallocate (self=0x5be5cd95f708, ptr=..., layout=...) at /home/ubuntu/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:271 vortex-data#11 0x000076a38ead9a64 in alloc::boxed::{impl#8}::drop<dyn vortex_scan::Partition, alloc::alloc::Global> (self=0x5be5cd95f6f8) at /home/ubuntu/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1666 vortex-data#12 0x000076a38ead349e in core::ptr::drop_in_place<alloc::boxed::Box<dyn vortex_scan::Partition, alloc::alloc::Global>> () at /home/ubuntu/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:804 vortex-data#13 0x000076a38e8764de in core::ptr::drop_in_place<vortex_ffi::scan::VxPartitionScan> () at /home/ubuntu/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:804 vortex-data#14 0x000076a38e876fb8 in core::ptr::drop_in_place<alloc::boxed::Box<vortex_ffi::scan::VxPartitionScan, alloc::alloc::Global>> () at /home/ubuntu/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:804 vortex-data#15 0x000076a38e87f2f5 in core::mem::drop<alloc::boxed::Box<vortex_ffi::scan::VxPartitionScan, alloc::alloc::Global>> (_x=0x5be5cd95f6f0) at /home/ubuntu/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:961 vortex-data#16 0x000076a38e84efa7 in vortex_ffi::scan::vx_partition_free (ptr=0x5be5cd95f6f0) at vortex-ffi/src/macros.rs:295 vortex-data#17 0x00005be5b0c81126 in operator() (__closure=0x7fff2208a8b0) at /home/ubuntu/vortex/vortex-ffi/test/scan.cpp:940 ``` ## Testing Verifying existing behavior is maintained. Signed-off-by: Dergousov Maksim <dergousovmaxim99@gmail.com>
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
VortexSource had no way to share segment bytes across queries. Every DataFusion query re-read the same zone-map and data segments from object storage, even though for an unchanged file those bytes are identical. This change adds a cross-query, cross-file segment cache, plumbed end-to-end from VortexSource down to VortexOpenOptions.
The naive approach of passing one
Arc<dyn SegmentCache>for all files is unsafe:SegmentIdis a file-localu32index, e.g., segment 5 from file A and segment 5 from file B would alias to the same cache entry and silently serve wrong data.This PR introduces a SegmentCacheBuilder indirection that namespaces per-file caches by a
FileIdentity(path + content version) so a single shared cache is correct across many files.The
SegmentCacheBuilderbuilder hands out per-fileSegmentCacheviews from one shared backing store, namespaced byFileIdentity(path + etag/size-mtime).VortexSource::with_segment_cache_builder(...)wires it through. Build oneNamespacedMokaSegmentCacheBuilderper process, reuse for every query — file-safe, overwrite-safe, cross-query reuse.The
InstrumentedSegmentCacheBuilderdecorator SegmentCacheBuilder — it wraps another builder and adds hit/miss/store metrics to every per-file cache that builder produces.Usage