Skip to content

Speed up file writes: parallel file stats, single min/max pass - #10856

Merged
robert3005 merged 3 commits into
developfrom
rk/faster-file-write-stats
Oct 27, 2026
Merged

robert3005 merged 3 commits into
developfrom
rk/faster-file-write-stats

Conversation

@robert3005

@robert3005 robert3005 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Profiling the compress benchmark showed that file statistics, not compression, took most of the Vortex write time:

  • File stats ran serially. accumulate_stats ran every column's aggregates in one stream.scan, in front of the parallel compressors. On CMSprovider, this alone was about as long as the full write.
  • Min/max ran twice. Max/Min and BoundedMax/BoundedMin each ran their own min_max scan. String chunks were also converted from VarBin to VarBinView twice.
  • Unsupported aggregates built errors. StatsAccumulator::new called accumulator() and threw the error away for each unsupported aggregate (for example NanCount on non-floats). Each error captures a backtrace. On a table with 10k columns, this took ~200 ms per write, and the CI benchmarks set RUST_BACKTRACE=full.

Results

These numbers also include the SequenceId lock contention fix, which is now in #10867.

Compress time, min of 3 iterations, 16 threads, Apple Silicon:

Dataset Parquet (ms) Vortex before (ms) Vortex after (ms) Speedup
taxi 147 254 152 1.67×
Arade 482 520 311 1.67×
Bimbo 1625 2263 1816 1.25×
CMSprovider 708 1995 723 2.76×
Euro2016 397 210 156 1.34×
Food 212 190 129 1.47×
HashTags 214 401 319 1.26×
TPC-H l_comment chunked 758 611 323 1.89×
TPC-H l_comment canonical 759 607 332 1.83×
wide cols=10000 chunks=1 206 492 246 2.00×
wide cols=10000 chunks=50 219 457 249 1.84×

@codspeed

codspeed Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 0.17%

3 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 2202 untouched benchmarks
⏩ 370 skipped benchmarks1
🗄️ 30 archived benchmarks run2

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation filter_powerlaw_by_random[10000] 765.6 ns 874.1 ns -12.41%
⚡ CPU Simulation take_filter_primitive_small_uncached_random_mask_random_indices[4096, 10] 23.8 µs 20.9 µs +13.79%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rk/faster-file-write-stats (ac13482) with develop (f024b10)

Open in CodSpeed

Footnotes

  1. 370 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. 30 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them. ↩

@robert3005 robert3005 added the changelog/fix A bug fix label Oct 27, 2026
@robert3005
robert3005 enabled auto-merge (squash) October 27, 2026 14:29
Comment on lines +182 to +189
// `min_max` computes both extrema in one pass and caches both on `batch`, so a
// `Max` over the same batch reads the cached value instead of a second scan.
if let Some(result) = min_max(batch, ctx, *args.options)? {
partial.merge(args, result.min);
}
return Ok(true);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a todo to unwind

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

independent please, so we can see perf of each in isolation

robert3005 and others added 3 commits October 27, 2026 15:25
File stats ran serially in front of the parallel compressors and computed
min/max twice per column chunk. Compute each chunk's stats on a CPU task and
merge them in stream order, and let Min/Max/BoundedMin/BoundedMax compute
through `min_max`, which caches both extrema on the batch.

Skip aggregates a dtype does not support before building an accumulator, so
wide schemas do not build (and capture a backtrace for) one error per column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Clone one context per task instead of taking a new kernel snapshot of the
session for each chunk. The tests pass their context to the push helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005
robert3005 force-pushed the rk/faster-file-write-stats branch from 16410cb to ac13482 Compare October 27, 2026 15:26
@robert3005 robert3005 changed the title Speed up file writes: parallel file stats, single min/max pass, less SequenceId contention Speed up file writes: parallel file stats, single min/max pass Oct 27, 2026
@robert3005

Copy link
Copy Markdown
Contributor Author

filed #10868

@robert3005

Copy link
Copy Markdown
Contributor Author

and #10867 is the split

@robert3005
robert3005 enabled auto-merge (squash) October 27, 2026 15:32
@robert3005
robert3005 merged commit 8c87c4c into develop Oct 27, 2026
83 of 84 checks passed
@robert3005
robert3005 deleted the rk/faster-file-write-stats branch October 27, 2026 15:38
robert3005 added a commit that referenced this pull request Oct 27, 2026
Split out of #10856.

- Allocate and free keys outside the lock.
- Skip the waker lookup when no waker is registered. Most sequences
never collapse, so usually no waker waits.
- In `descend`, replace the parent with its child under one lock
acquisition, instead of one to add the child and one to remove the
parent.

Signed-off-by: Robert Kruszewski <github@robertk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants