Repository navigation
Write constant columns as one chunk - #11400
robert3005 wants to merge 2 commits into
Conversation
The default write strategy splits each column into 8K-row blocks and then into blocks of about 1 MiB of uncompressed data. For a constant column, each block compresses to the same constant, so the splits only add chunks, segments and zone maps. Add ConstantStrategy in front of the per-column repartition. It reads chunks while they all hold the same value. If the stream ends in this state, it writes one ConstantArray with the flat strategy. Otherwise, it gives the stream to the usual pipeline, with the rows read until then first as one ConstantArray. While it reads, it keeps only the most recent sequence ID, so that other columns can continue to write their segments. Part of #3874. Signed-off-by: Robert Kruszewski <github@robertk.io>
Merging this PR will improve performance by 10.85%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
Polar Signals Profiling ResultsLatest Run
Powered by Polar Signals Cloud |
Benchmarks: PolarSignals Profiling 📖Commits: PR datafusion / vortex-file-compressed / ns (0.943x ➖, 2↑ 0↓)
|
Benchmarks: FineWeb NVMe 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.944x ➖, 1↑ 0↓)
datafusion / parquet / ns (1.003x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (0.986x ➖, 0↑ 0↓)
duckdb / parquet / ns (0.989x ➖, 0↑ 0↓)
|
Benchmarks: TPC-H SF=1 on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.998x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.999x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.000x ➖, 0↑ 1↓)
duckdb / parquet / ns (1.000x ➖, 0↑ 0↓)
|
Benchmarks: TPC-H SF=10 on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.993x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.997x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (0.997x ➖, 0↑ 0↓)
duckdb / parquet / ns (0.997x ➖, 0↑ 0↓)
|
Benchmarks: TPC-DS SF=1 on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.993x ➖, 0↑ 0↓)
datafusion / parquet / ns (0.995x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (0.994x ➖, 1↑ 0↓)
duckdb / parquet / ns (0.988x ➖, 1↑ 0↓)
|
Benchmarks: Clickbench on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.995x ➖, 1↑ 0↓)
datafusion / parquet / ns (0.996x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.009x ➖, 0↑ 0↓)
duckdb / parquet / ns (1.014x ➖, 0↑ 1↓)
|
Benchmarks: TPC-H SF=1 on S3 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (1.186x ➖, 0↑ 6↓)
datafusion / parquet / ns (0.963x ➖, 2↑ 0↓)
duckdb / vortex-file-compressed / ns (0.988x ➖, 1↑ 1↓)
duckdb / parquet / ns (0.993x ➖, 1↑ 0↓)
|
Benchmarks: TPC-DS SF=10 on NVME 📖Commits: PR How to read Verdict and Engines
datafusion / vortex-file-compressed / ns (0.996x ➖, 0↑ 0↓)
datafusion / parquet / ns (1.001x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed / ns (1.005x ➖, 1↑ 0↓)
duckdb / parquet / ns (1.006x ➖, 0↑ 0↓)
|
fixes #3874.
The default write strategy splits each column into 8K-row blocks, then into blocks of about 1 MiB of uncompressed data. For a constant column, each block compresses to the same
ConstantArray. The splits only add chunks, segments and a zone map that have no use.Change
ConstantStrategy(vortex-layout/src/layouts/constant.rs). It reads chunks while they all hold the same value:ConstantArraywith the flat strategy. There is no repartition, no zone map and no chunked layout.ConstantArray. The run stores only a scalar and a length, so nothing is materialized.UnionandVariantcolumns skip detection, becauseis_constantcannot examine them.WriteStrategyBuilder::buildputsConstantStrategyin front of the per-column repartition. It writes constant columns with the configured flat strategy, sowith_flat_strategystill applies.