Repository navigation
Default duckdb-bench to the V2 scan for TPC-DS and ClickBench - #11047
Conversation
Fix wrong DuckDB results when a validity bitmap starts at a bit offset: the copy path ignored the bit buffer's own offset, shifting nulls. V2 scans produce such bitmaps often (TPC-DS Q61, Q93 and Q98 were wrong). Make the DuckDB V2 driver match V1's work distribution: - The thread that initializes a file prunes it and queues its parts, so a file takes threads only while parts are left and spare threads move on to the next file instead of waiting on the file's root. - Cut parts on the file's layout splits, as V1 does, so one thread exports each layout chunk and DuckDB evaluates expressions over its dictionary once. - Prune each part again when it is taken, so a dynamic filter such as a top-N bound skips more of the parts taken later. The second pruning reuses the zone maps the first read. - Export each chunk of a chunked V2 batch on its own instead of canonicalizing it, which decoded its dictionaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MZ3d6HFyGGeUGy8brEr6BM Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Merging this PR will improve performance by 13.02%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing |
Polar Signals Profiling ResultsLatest Run
Powered by Polar Signals Cloud |
🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨Benchmark |
🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨Benchmark |
🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨Benchmark |
🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨Benchmark |
🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨Benchmark |
🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨Benchmark |
🚨🚨🚨❌❌❌ SQL BENCHMARK FAILED ❌❌❌🚨🚨🚨Benchmark |
| //! The root cuts the scanned rows into parts of whole 65,536-row blocks, a few per thread, and | ||
| //! spawns a chunk planner per part. A filtered scan's chunks are up to 1,048,576 rows, so without | ||
| //! parts a file of a few million rows would keep only a few threads busy. | ||
| //! DuckDB's own threads run all of it. Each file is prepared once, and the thread that initializes |
There was a problem hiding this comment.
Once again I think we don't need these verbose comments
There was a problem hiding this comment.
how would you like this flow explained?
The scan-wide pruning ran in reader_initialize, under the file's lock, so on selective queries over few files it sat on the critical path. It only pays off for a dynamic filter, whose bound tightens while parts are taken. A static filter now prunes each part on the thread that takes it, so a file's pruning runs in parallel. A dynamic filter still prunes the scan first and each part again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MZ3d6HFyGGeUGy8brEr6BM Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Switches
duckdb-benchto the planner-driven V2 scan by default for TPC-DS and ClickBench (TPC-H already uses it). Pass--scan-v2 falseor setVORTEX_SCAN_V2=0to use V1.Wrong results fix
With V2, TPC-DS Q61, Q93 and Q98 returned different results than Parquet and V1. The DuckDB exporter's copy path in
set_validity_zero_copypassed the bit offset within the export tocopy_from_slicebut ignored theBitBuffer's own bit offset. A validity bitmap that starts at a nonzero bit offset was therefore exported shifted, moving nulls by a few rows. V2 produces such bitmaps often, but V1 can hit the same bug. Regression test:test_set_validity_values_with_bit_buffer_offset.DuckDB V2 driver changes
REGEXP_REPLACEover it twice. ClickBench Q28 used 22% more CPU than V1. Parts now useScanBuilder::full_file_splits, the boundaries V1 uses.pruning_again_reuses_the_first_reads).ChunkedArray, whichconvert_resultcanonicalized, decoding their dictionaries. Each chunk is now exported on its own.