perf: remove implicit ListViewArray rebuild during take and filter operations#8048
perf: remove implicit ListViewArray rebuild during take and filter operations#8048mhk197 wants to merge 19 commits into
ListViewArray rebuild during take and filter operations#8048Conversation
ListViewArray rebuild during take and filter operationsListViewArray rebuild during take and filter operations
c6a1940 to
95ae305
Compare
Polar Signals Profiling ResultsLatest Run
Previous Runs (1)
Powered by Polar Signals Cloud |
Merging this PR will improve performance by 19.44%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | chunked_varbinview_opt_canonical_into[(1000, 10)] |
225.1 µs | 188.5 µs | +19.44% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing mk/explicit-listview-compaction (7413412) with develop (a8fb30e)
Benchmarks: PolarSignals ProfilingVortex (geomean): 1.026x ➖ datafusion / vortex-file-compressed (1.026x ➖, 0↑ 1↓)
|
File Sizes: PolarSignals ProfilingNo file size changes detected. |
Benchmarks: FineWeb NVMeVerdict: No clear signal (low confidence) datafusion / vortex-file-compressed (0.975x ➖, 1↑ 0↓)
datafusion / vortex-compact (1.002x ➖, 1↑ 2↓)
datafusion / parquet (0.974x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed (0.972x ➖, 1↑ 0↓)
duckdb / vortex-compact (0.971x ➖, 0↑ 0↓)
duckdb / parquet (0.969x ➖, 0↑ 0↓)
Full attributed analysis
|
File Sizes: FineWeb NVMeNo file size changes detected. |
Benchmarks: TPC-H SF=1 on NVMEVerdict: No clear signal (environment too noisy confidence) datafusion / vortex-file-compressed (1.042x ➖, 0↑ 1↓)
datafusion / vortex-compact (1.036x ➖, 0↑ 0↓)
datafusion / parquet (1.055x ➖, 1↑ 5↓)
datafusion / arrow (1.072x ➖, 0↑ 6↓)
duckdb / vortex-file-compressed (1.030x ➖, 0↑ 0↓)
duckdb / vortex-compact (1.029x ➖, 0↑ 0↓)
duckdb / parquet (1.031x ➖, 0↑ 3↓)
duckdb / duckdb (1.019x ➖, 0↑ 0↓)
Full attributed analysis
|
File Sizes: TPC-H SF=1 on NVMEFile Size Changes (195 files changed, -98.4% overall, 0↑ 195↓)
Totals:
|
Benchmarks: TPC-DS SF=1 on NVMEVerdict: No clear signal (low confidence) datafusion / vortex-file-compressed (0.911x ➖, 22↑ 0↓)
datafusion / vortex-compact (0.972x ➖, 19↑ 14↓)
datafusion / parquet (1.001x ➖, 2↑ 9↓)
duckdb / vortex-file-compressed (0.983x ➖, 5↑ 5↓)
duckdb / vortex-compact (0.988x ➖, 6↑ 6↓)
duckdb / parquet (0.973x ➖, 5↑ 2↓)
duckdb / duckdb (0.960x ➖, 17↑ 6↓)
Full attributed analysis
|
File Sizes: TPC-DS SF=1 on NVMENo file size changes detected. |
Benchmarks: FineWeb S3Verdict: No clear signal (environment too noisy confidence) datafusion / vortex-file-compressed (0.877x ➖, 1↑ 0↓)
datafusion / vortex-compact (0.928x ➖, 0↑ 0↓)
datafusion / parquet (0.786x ➖, 3↑ 0↓)
duckdb / vortex-file-compressed (0.903x ➖, 0↑ 0↓)
duckdb / vortex-compact (0.893x ➖, 0↑ 0↓)
duckdb / parquet (0.901x ➖, 0↑ 0↓)
Full attributed analysis
|
Benchmarks: Statistical and Population GeneticsVerdict: No clear signal (low confidence) duckdb / vortex-file-compressed (0.995x ➖, 0↑ 0↓)
duckdb / vortex-compact (1.002x ➖, 0↑ 0↓)
duckdb / parquet (0.987x ➖, 0↑ 0↓)
Full attributed analysis
|
File Sizes: Statistical and Population GeneticsNo file size changes detected. |
Benchmarks: Random AccessVortex (geomean): 0.973x ➖ unknown / unknown (0.991x ➖, 0↑ 0↓)
|
Benchmarks: TPC-H SF=10 on NVMEVerdict: No clear signal (low confidence) datafusion / vortex-file-compressed (0.982x ➖, 0↑ 0↓)
datafusion / vortex-compact (0.989x ➖, 0↑ 0↓)
datafusion / parquet (0.979x ➖, 0↑ 0↓)
datafusion / arrow (0.981x ➖, 0↑ 0↓)
duckdb / vortex-file-compressed (0.997x ➖, 1↑ 0↓)
duckdb / vortex-compact (1.002x ➖, 0↑ 0↓)
duckdb / parquet (0.997x ➖, 0↑ 0↓)
duckdb / duckdb (1.003x ➖, 0↑ 0↓)
Full attributed analysis
|
File Sizes: TPC-H SF=10 on NVMENo file size changes detected. |
Benchmarks: Clickbench on NVMEVerdict: No clear signal (low confidence) datafusion / vortex-file-compressed (0.989x ➖, 0↑ 2↓)
datafusion / parquet (0.998x ➖, 0↑ 1↓)
duckdb / vortex-file-compressed (0.996x ➖, 1↑ 3↓)
duckdb / parquet (0.989x ➖, 1↑ 0↓)
duckdb / duckdb (1.021x ➖, 0↑ 3↓)
Full attributed analysis
|
File Sizes: Clickbench on NVMEFile Size Changes (1 files changed, -0.0% overall, 0↑ 1↓)
Totals:
|
Benchmarks: TPC-H SF=1 on S3Verdict: No clear signal (environment too noisy confidence) datafusion / vortex-file-compressed (0.535x ✅, 21↑ 0↓)
datafusion / vortex-compact (0.564x ✅, 18↑ 0↓)
datafusion / parquet (0.768x ➖, 7↑ 0↓)
duckdb / vortex-file-compressed (0.795x ➖, 3↑ 0↓)
duckdb / vortex-compact (0.847x ➖, 0↑ 0↓)
duckdb / parquet (0.774x ➖, 5↑ 0↓)
Full attributed analysis
|
Benchmarks: CompressionVortex (geomean): 1.003x ➖ unknown / unknown (0.993x ➖, 7↑ 2↓)
|
Benchmarks: TPC-H SF=10 on S3Verdict: No clear signal (environment too noisy confidence) datafusion / vortex-file-compressed (0.844x ➖, 3↑ 0↓)
datafusion / vortex-compact (0.958x ➖, 0↑ 1↓)
datafusion / parquet (0.828x ➖, 4↑ 0↓)
duckdb / vortex-file-compressed (0.871x ➖, 0↑ 0↓)
duckdb / vortex-compact (0.873x ➖, 0↑ 0↓)
duckdb / parquet (0.806x ➖, 3↑ 0↓)
Full attributed analysis
|
f8b4f2e to
933bdc1
Compare
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
57908ab to
cd7c97e
Compare
joseph-isaacs
left a comment
There was a problem hiding this comment.
looks. good overall
did you do this for duckdb too? that is important. since that might be passed sparse element lists.
also a single definitive comment explaining what you did.
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
Signed-off-by: Matthew Katz <katz@spiraldb.com>
|
|
||
| /// Walks parallel `(offset, size)` slices and sets each range `[offset, offset + size]` in `buf`. | ||
| /// | ||
| /// **Preconditions** |
There was a problem hiding this comment.
Nit: I think the Rust idiomatic practice is to label this # Panics
(also below)
| // and any compute pass over that buffer wastes work on data nothing references. | ||
| let density = array.upper_bound_density(ctx)?; | ||
| let array = if density < DEFAULT_REBUILD_DENSITY_THRESHOLD { | ||
| array.rebuild(ListViewRebuildMode::MakeZeroCopyToList)? |
There was a problem hiding this comment.
Might as well do ::MakeExact here?
Now that I think about this, do all Arrow implementations allow offsets that don't start at 0? @joseph-isaacs do you know?
https://arrow.apache.org/docs/format/Columnar.html#variable-size-list-layout
| /// Returns the value of `stat` by either fetching it from cache if it exists and is [`Precision::Exact`], or falling back to | ||
| /// computation. The underlying compute kernels will cache the computed stat in the latter case. |
Summary
Removes implicit rebuilds from
ListViewArraytakeandfiltercompute kernels, adds density-introspection methods to support deciding when to rebuild explicitly at materialization boundaries, and defers rebuilding until array export to duckdb and arrow.Motivation. The previous code rebuilt the elements buffer eagerly on every
takeorfilterwhose row-fraction dropped belowREBUILD_DENSITY_THRESHOLD. In an execution tree liketake → take → ..., an eager mid-pipeline rebuild costs an allocation and a full copy of referenced ranges that the next operator may immediately sparsify away.The row-fraction heuristic was also inaccurate. It doesn't account for per-row size variance, unreferenced elements, and duplicate references. Instead,
ListViewArray::estimate_densityuses sum ofsizesinstead of row-fraction. This will overestimate density when there are overlapping references, but it is typically preferable to not compact.Changes:
TakeReduce::takeandTakeExecute::takefilter_listviewcompute_referenced_elements_mask,compute_density, andestimate_densityAPI Changes
Adds
ListViewArray::estimate_density,ListViewArray::compute_density, andListViewArray::compute_referenced_elements_mask.Testing
vortex-array/src/arrays/listview/tests/density.rs