Repository navigation
Open
Labels
Description
Parked design for a concurrent reader scan. Follow-up to #474 (writer side, shipped).
Reference behavior
- Rust (
vortex-layout/src/scan/scan_builder.rs): the scan is split into row-range tasks (SplitBy), each spawned onto the session runtime, up toconcurrency * num_workersin flight (default 4 per worker).ordered(default) uses.buffered(n), otherwise.buffer_unordered(n). A per-splitmapfunction runs on the spawned task. - .NET (Vorticity):
MaxDegreeOfParallelismper session or per scan,MaxConcurrentReadsfor I/O, sharedSegmentCache, concurrent scans over one open file. - vortex-java today:
ScanIteratoris single-threaded, every arena isofConfined.
Proposed shape
A confined Arena per worker thread, so the callback runs on the worker and the caller never touches decoded memory from another thread:
scan.parallel(executor) // executor + bounded in-flight window on ScanOptions
.map(chunk -> r) // runs on the worker; chunk and its arena close on returnRmust not reference chunk memory (aggregates, copied-out values); Javadoc states the contract.- Results delivered ordered (Rust
buffered, default) or unordered (buffer_unordered). - The file mapping becomes
ofShared(one close at the end), since workers must read it. Alternative: each worker maps its own view. scan()/ScanIterator/Chunklifetime rules stay unchanged.
Pros
- Rust-shaped (map on the spawned task, ordered/unordered, bounded window), so parity with the reference.
- Confined arenas keep the cheap alloc/close path;
Arena.ofShared().close()needs a cross-thread handshake per chunk. - No change to the existing single-threaded API or its safety checks.
- Same bounded-window idea as the writer's
pendingqueue /MAX_IN_FLIGHT_SEGMENTS. - Overlaps decode with consumption; wide files and slow consumers benefit most.
Cons
- No ordered, parallel, zero-copy
Iterator<Chunk>for a consumer thread: a chunk decoded on a worker cannot be read elsewhere. That case would need a shared per-chunk arena (slower close, and relaxes the "secondnext()while aChunkis open is rejected" rule). - Callback API is less ergonomic than an iterator; callers who must keep data have to copy out.
- Mapping arena goes shared; any cross-thread use after
close()becomes a hazard to test (ADR 0003 security contract still applies on worker threads: onlyVortexExceptionmay escape). - Worker exceptions must be propagated and in-flight work cancelled/drained on failure (the writer's
discardPendingequivalent). - Needs A/B on all 7 real files (
RealFileScanBenchmark, interleaved): memory-bandwidth-bound scans may not scale, and oversubscribing the pool gains nothing.
Out of scope / not planned
- Per-column parallel decode within a chunk: not a Rust pattern, so it would be a deliberate divergence needing an explicit decision.
- Parallel I/O for
VortexHttpReader(concurrent range requests): independent of this, worth its own ticket if pursued. - Writer follow-ups (parallel scheme trials in
CascadingCompressor.chooseBest): comment on Writer: compress columns/chunks concurrently #474.
Activity
dfa1 commentedon Oct 24, 2026
Revised design (2026-10-24): parallel decode-ahead behind the existing iterator
Context:
ParquetVsVortexReadBenchmarkcompares Hardwood's multi-core page decode (a fixed pool ofavailableProcessors()threads plus two virtual threads per column) with our single-threaded scan. Two taxi columns, single fork: on one CPU (-XX:ActiveProcessorCount=1) Vortex 163 vs Parquet 106 ops/s; on all CPUs Vortex 143 vs Parquet 165. The wall-clock gap is concurrency, not decode cost.Rust's default is an ordered stream whose splits are decoded on spawned tasks (
.buffered(n)), which is an iterator with decode-ahead. So instead of a callback API, keepscan()/ScanIteratorand make it decode ahead:Iterator<Chunk>": measureArena.ofShared()allocate+close against a chunk's decode (milliseconds) before ruling it out. If the close is cheap, use a shared arena per chunk. If not, one shared slab per in-flight slot, bump-allocated by the worker and reset when the consumer closes the chunk (one close per scan, a fresh arena for an oversized chunk). The "close aChunkbefore the nextnext()" rule stays, since workers decode into other slots.ScanOptions.withExecutor(executor)(likeWriteOptions#executor(), Writer: compress columns/chunks concurrently #474) turns on decode-ahead; existing code is unchanged.map(chunk -> r)is optional for aggregations.IllegalStateException, never read freed memory.ScanIterator.close()/VortexReader.close()cancel and drain in-flight decodes before closing the mapping. Worker boundary maps anything else toVortexException(ADR 0003); a test closes the reader mid-scan.next()rethrows the first error asVortexException.RealFileScanBenchmarkA/B on all seven files (sequential vs parallel), plus single-core numbers; one worker already overlaps decode with consumption.Order: shared-arena close cost first, then decode-ahead behind
withExecutor, then the A/B and the taxi two-column read against Parquet on all cores.