perf(exec): parallelize lance exec scan across fragments - #236
Conversation
Split the Lance exec scan into min(threads, fragment_count) fragment partitions (round-robin) so scan+filter parallelize across cores. - Carry the DuckDB thread budget into lance exec via a new LanceExecContext (repr(C) struct passed through the exec FFI, null-compatible so existing callers that pass NULL keep the previous single-partition behavior) - Scope each partition's scan to its fragment subset with with_fragments, keeping a single-partition full scan as fallback
Benchmark results (A/B)Validated against TPC-H SF10 (
Method: each build deployed independently, same Head-to-head at threads = 4
Threads sweep (median seconds)Q6 (scan+filter dominated):
Q1 (aggregate dominated):
Key observations:
CorrectnessCompared value-by-value against standard DuckDB reading the same SF10 parquet:
No regression in multi-fragment partitioning; results identical vs single partition. |
|
Hi @Xuanwo — your Context: When Key question for you: the pushdown is registered unconditionally with no cost gate or hint. Since the exec path now parallelizes correctly, does that change your thinking on whether the unconditional rewrite is acceptable, or should a cost threshold still be considered? Would be great to get your read on whether this fix aligns with how you intended the pushdown path to scale. Benchmark + correctness details are in the comment above. Thanks for taking a look! |
Parallelize the Lance exec scan by splitting it into fragment partitions.
What
LanceExecContext(repr(C) struct passed through the exec FFI, null-compatible — existing callers that passNULLkeep the previous single-partition behavior).min(threads, fragment_count)fragment partitions (round-robin) so scan+filter parallelize across cores.with_fragments; keep a single-partition full scan as fallback.Why
Previously the exec scan ran as a single partition on one core. For large multi-fragment datasets, scan+filter now parallelize across the DuckDB thread budget.
Verification
__LANCE_EXECpushdown viaEXPLAIN (FORMAT JSON).