Repository navigation
fix(parquet): stop bypassing write_batch_size for compact level data - #12217
siddubakka wants to merge 1 commit into
Conversation
write_batch_internal used data_page_row_count_limit as the mini-batch size when both level vectors were compact, so set_write_batch_size had no effect for columns with compact level data. Batch at write_batch_size unconditionally so page boundaries follow the documented granularity.
|
run benchmark arrow_writer |
|
🤖 Benchmark starting (GKE) | trigger Target: arrow_writer Sharding factor: 4 (4 workers). Comparing fix/10931-write-batch-size (94c8dd6) to cd91f89 (merge-base) diff Run configurationrun benchmark arrow_writer
shards: 4
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: arrow_writer Comparing fix/10931-write-batch-size (94c8dd6) to cd91f89 (merge-base) diff Run configurationrun benchmark arrow_writer
shards: 4
Comparison results: View the complete native critcmp output. The comparison is published in an unlisted Gist because the original inline report exceeded GitHub's comment limit. Per-runner informationarrow_writer — shard 1/4Node: gk3-benchmark-cluster-nap-ty64ekgq-c91a1467-2qwk Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench arrow_writerCPU Details (lscpu)Resource Usagebase (merge-base)
branch
arrow_writer — shard 2/4Node: gk3-benchmark-cluster-nap-ty64ekgq-c91a1467-rbtp Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench arrow_writerCPU Details (lscpu)Resource Usagebase (merge-base)
branch
arrow_writer — shard 3/4Node: gk3-benchmark-cluster-nap-ty64ekgq-c91a1467-4flt Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench arrow_writerCPU Details (lscpu)Resource Usagebase (merge-base)
branch
arrow_writer — shard 4/4Node: gk3-benchmark-cluster-nap-ty64ekgq-c91a1467-x6qs Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench arrow_writerCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
|
As I feared, this PR removes a useful optimization. I don't think matching overflow behavior justifies that loss. I think we should add a section to the |
|
@etseidl Thanks for running these, the numbers are useful. You are right that this removes a real optimization. The regressions sit where I would expect them: One clarification, not a counterargument: the compact level representation from #9831 stays, only the batch granularity in On the tradeoff, I think your read is the right one. The page row count limit is already best effort on the other two paths since pages fill to the next @adriangb said earlier that fixing the implementation was better than documenting it. If you two still prefer the code fix I will keep this PR as is. Otherwise I will close it and open the docs PR against the issue. Which way would you like it? |
|
Lets go with the docs PR for now since there are tradeoffs in the implementation |
Which issue does this PR close?
parquet:write_batch_sizeis bypassed for columns with compact level data, contrary to its documentation #10931Rationale for this change
set_write_batch_sizedocumentswrite_batch_sizeas the granularity at which limits such asset_data_page_row_count_limitare checked. Columns with compact level data did not follow that rule. Their mini-batch size wasdata_page_row_count_limit, soset_write_batch_sizehad no effect on a nullable column whose batch happened to contain no nulls.The condition was on the level data rather than the schema, so the same column with the same writer properties produced different page boundaries depending on whether a batch contained a null. Page boundaries should follow the properties that were set, not the contents of the batch.
What changes are included in this PR?
write_batch_internalnow always batches atwrite_batch_size. The special case for compact level data added in #9831 and the two condition variables behind it are removed, and a short comment explains why the batch size is what it is.The plan comment on the issue proposed taking the smaller of
write_batch_sizeanddata_page_row_count_limit. I built that version first. It still leaves the compact path different from the other two whenwrite_batch_sizeis larger than the row count limit, which is thewrite_batch_size = 100000case in the issue's reproduction. Batching atwrite_batch_sizedirectly matches the documentation and makes all three level shapes produce identical page boundaries at everywrite_batch_sizein the reproduction.Are these changes tested?
Added
test_write_batch_size_bounds_compact_level_batchesinparquet/tests/arrow_writer/layout.rs. It repeats the issue's reproduction: 12000 Int64 rows, row count limit 3000, dictionary disabled, for absent, uniform and materialized level data atwrite_batch_size8, 64, 1024 and 100000. It asserts the page row counts from the issue's table and that the three shapes agree.I also ran
cargo bench -p parquet --bench arrow_writerbefore and after the change for the groups that take this path. This machine cannot compare runs that are separated by a rebuild. Repeating the same commit in a later session moved those benches by 20 to 40 percent, while two runs of the same binary back to back stayed within about 6 percent, so I am not quoting a number for this change because it would not be honest.What does change is the batch size itself. At default settings the compact path used to write 20000 rows per mini-batch, which is the data page row count limit, and it now writes
write_batch_sizerows, which is 1024 by default. The larger batch was an optimization from #9831. This PR gives it back in exchange for the behavior the documentation describes. I can run a cleaner comparison if reviewers want numbers.Are there any significant user-facing changes?
Page layout changes for columns with compact level data. With the same writer properties, pages now end at
write_batch_sizeboundaries like every other column instead of atdata_page_row_count_limitboundaries, so files written before and after this change can have different page boundaries for such columns. There are no API changes.AI usage disclosure
I used an AI assistant to draft the code change, the test and this description. The parquet test suite and clippy were run locally before opening this PR.