Repository navigation
bench(parquet): add wide-schema writer benchmark with repeated batches - #10878
Merged
Jefffrey merged 2 commits intoAug 27, 2026
Merged
Conversation
…tches
`writer_overhead` writes a single one-row batch per file, so it measures
column writer construction and metadata assembly and nothing that repeats
per batch.
Add `writer_overhead/{n}_cols/repeated_batches`, which holds the number of
column writers fixed and writes 32 batches of 32 rows into one row group.
That isolates the per-`write` work of a wide schema, which the existing
cases do not reach.
Jefffrey
reviewed
Aug 27, 2026
Comment on lines
+89
to
+97
| /// Column counts for [`bench_writer_repeated_batches`]. Kept below the widest | ||
| /// case in [`COLUMN_COUNTS`] so the benchmark stays a few hundred milliseconds | ||
| /// per iteration. | ||
| const REPEATED_COLUMN_COUNTS: &[usize] = &[1_000, 5_000]; | ||
|
|
||
| /// Number of batches written per file by [`bench_writer_repeated_batches`], and | ||
| /// the number of rows in each of them. | ||
| const REPEATED_BATCH_COUNT: usize = 32; | ||
| const REPEATED_BATCH_ROWS: usize = 32; |
Contributor
There was a problem hiding this comment.
might as well inline them (or at least bring them inside) if the comments state theyre meant to be used by bench_writer_repeated_batches
Comment on lines
+102
to
+105
| /// [`bench_writer_overhead`] writes one batch per file, so it is dominated by | ||
| /// column writer construction and metadata assembly. This benchmark keeps the | ||
| /// number of column writers fixed and increases the number of `write` calls, | ||
| /// isolating the work that repeats on every batch. |
Contributor
There was a problem hiding this comment.
this part about bench_writer_overhead should be moved to bench_writer_overhead instead of being here
Move the repeated-batch constants inside `bench_writer_repeated_batches`, inlining the column counts into the loop, and move the description of `bench_writer_overhead` onto `bench_writer_overhead` itself. Co-Authored-By: Claude Opus 5 <[email protected]>
Contributor
Author
|
Thanks @Jefffrey , addressed |
Jefffrey
approved these changes
Aug 27, 2026
Contributor
|
thanks @adriangb |
Jefffrey
pushed a commit
that referenced
this pull request
Aug 31, 2026
…10880) # Which issue does this PR close? - Contributes to #9722. - Builds on #10878, which adds the `repeated_batches` benchmark cases used below. # Rationale for this change `WriterProperties` keeps per-column overrides in a `HashMap<ColumnPath, ColumnProperties>`. Every accessor that takes a `&ColumnPath` — `compression`, `encoding`, `dictionary_enabled`, `statistics_enabled`, `write_page_header_statistics`, `column_data_page_size_limit`, `column_dictionary_page_size_limit`, `column_data_page_v2_compression_ratio_threshold` and `bloom_filter_properties` — hashes that path and searches the map. `ColumnPath` is a `Vec<String>`, so each search hashes every part of the path and then compares strings on a hit. The column writers call those accessors repeatedly for the same leaf column: - 6 times while a column writer is constructed (`GenericColumnWriter::new` plus `ColumnValueEncoder::try_new`); - 2 more on every `write`, in `ByteBudgetChunker::new`; - 1 per mini-batch in `should_add_data_page`, and another in `should_dict_fallback` when a dictionary encoder is active; - 1 per page in `add_data_page`, plus one more for Data Page v2. `WriterProperties` is immutable once built, so all of that recomputes an answer that was already available when the column writer was created. Counting the searches directly (temporary instrumentation on the map access) over the `writer_overhead` shapes: | benchmark case | searches before | searches after | | --- | --- | --- | | `writer_overhead/1000_cols` | 10,000 | 1,000 | | `writer_overhead/5000_cols` | 50,000 | 5,000 | | `writer_overhead/10000_cols` | 100,000 | 10,000 | | `writer_overhead/1000_cols/repeated_batches` | 103,000 | 1,000 | | `writer_overhead/5000_cols/repeated_batches` | 515,000 | 5,000 | After the change it is exactly one search per leaf column per row group. # What changes are included in this PR? - Adds `WriterProperties::resolve_column_properties`, which searches the per-column map once and returns a `ResolvedColumnProperties` holding every per-column setting already resolved against the file-wide defaults. The struct is `pub(crate)`; no public API is added. - `GenericColumnWriter::new` calls it once and stores the result. The per-batch and per-page paths, `ByteBudgetChunker::new`, and both `ColumnValueEncoder` implementations read from it instead of searching the map again. `ColumnValueEncoder::try_new` and `create_bloom_filter` now take the resolved settings; that trait is not nameable outside the crate. - The existing per-column accessors keep their behaviour and are reimplemented on top of the same resolution helpers, so the "column override, else file default, else constant" rule has one definition rather than one per accessor. # Are these changes tested? Yes. - The existing suite passes unchanged, with and without `encryption`: `cargo test -p parquet --features "arrow async encryption test_common experimental"`. - New `test_resolve_column_properties_matches_individual_accessors` asserts the one-pass resolution agrees with every individual accessor, for a column with overrides, a column that inherits the file defaults, and properties left entirely at their defaults. - To check the writer is byte-for-byte unchanged I wrote the same file from a build before and after this change, with a workload covering the settings this PR touches: per-column compression, encoding, dictionary on and off, page and dictionary page size limits, page-header statistics, a bloom filter, dictionary fallback on multi-KB values, and both writer versions. The two files are identical. Benchmark: cargo bench -p parquet --bench writer_overhead I did not have an idle machine, and criterion's wall-clock intervals were too wide there to be usable. I measured CPU time (user + sys) per iteration instead, which is far less sensitive to competing load: the minimum over 40 alternating runs of the two builds, with a separately measured ~13.3 ms of fixed benchmark setup subtracted. | benchmark case | before | after | | | --- | --- | --- | --- | | `writer_overhead/1000_cols` | 2.7 ms | 2.1 ms | see note | | `writer_overhead/5000_cols` | 20.2 ms | 18.5 ms | −8 % | | `writer_overhead/10000_cols` | 38.8 ms | 34.2 ms | −12 % | | `writer_overhead/1000_cols/repeated_batches` | 12.9 ms | 8.6 ms | −34 % | | `writer_overhead/5000_cols/repeated_batches` | 88.0 ms | 70.1 ms | −20 % | Note: at 1,000 columns with a single batch the remaining figure is close enough to the spread of the setup subtraction that I would not read a percentage into it. The other four imply about 40 ns per map search, consistently across all four shapes, which matches the search counts above. A run on an idle machine would be worth having, and the benchmark from #10878 makes that easy. `ColumnWriterImpl<Int32Type>` grows from 1312 to 1376 bytes to hold the resolved settings. Peak RSS on the 10,000 column benchmark was unchanged. # Are there any user-facing changes? No. No public API is added, removed or changed, and the bytes written are unchanged. # AI usage This PR was written with Claude Code and reviewed by a human. The byte-for-byte output comparison and the map-search counts above are the checks run to confirm the behaviour is unchanged. --------- Co-authored-by: Claude <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 2, 2026
apache#10878) # Which issue does this PR close? - Contributes to apache#9722. # Rationale for this change `parquet/benches/writer_overhead.rs` writes a single one-row batch per file. That measures column writer construction, allocation and metadata assembly, and it measures them well, but it never reaches the work a wide schema repeats on every batch: the per-column setup inside `ColumnWriter::write_batch`, and the per-mini-batch and per-page checks below it. With one `write` call per file, a change to that per-batch path is invisible here. # What changes are included in this PR? Adds `writer_overhead/{1000,5000}_cols/repeated_batches`. It holds the number of column writers fixed and writes 32 batches of 32 rows into a single row group, reusing the same wide schema and the same per-column `WriterProperties` as the existing cases, so the only difference from `writer_overhead/{n}_cols` is the number of `write` calls. The 10,000 column case is deliberately left out of the new benchmark so that one iteration stays well under a second. On the machine used here an iteration is roughly 13 ms at 1,000 columns and 90 ms at 5,000 columns. # Are these changes tested? No, this is a benchmark-only change. Run it with: cargo bench -p parquet --bench writer_overhead # Are there any user-facing changes? No. # AI usage This PR was written with Claude Code and reviewed by a human. --------- Co-authored-by: Claude Opus 5 <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 2, 2026
…pache#10880) # Which issue does this PR close? - Contributes to apache#9722. - Builds on apache#10878, which adds the `repeated_batches` benchmark cases used below. # Rationale for this change `WriterProperties` keeps per-column overrides in a `HashMap<ColumnPath, ColumnProperties>`. Every accessor that takes a `&ColumnPath` — `compression`, `encoding`, `dictionary_enabled`, `statistics_enabled`, `write_page_header_statistics`, `column_data_page_size_limit`, `column_dictionary_page_size_limit`, `column_data_page_v2_compression_ratio_threshold` and `bloom_filter_properties` — hashes that path and searches the map. `ColumnPath` is a `Vec<String>`, so each search hashes every part of the path and then compares strings on a hit. The column writers call those accessors repeatedly for the same leaf column: - 6 times while a column writer is constructed (`GenericColumnWriter::new` plus `ColumnValueEncoder::try_new`); - 2 more on every `write`, in `ByteBudgetChunker::new`; - 1 per mini-batch in `should_add_data_page`, and another in `should_dict_fallback` when a dictionary encoder is active; - 1 per page in `add_data_page`, plus one more for Data Page v2. `WriterProperties` is immutable once built, so all of that recomputes an answer that was already available when the column writer was created. Counting the searches directly (temporary instrumentation on the map access) over the `writer_overhead` shapes: | benchmark case | searches before | searches after | | --- | --- | --- | | `writer_overhead/1000_cols` | 10,000 | 1,000 | | `writer_overhead/5000_cols` | 50,000 | 5,000 | | `writer_overhead/10000_cols` | 100,000 | 10,000 | | `writer_overhead/1000_cols/repeated_batches` | 103,000 | 1,000 | | `writer_overhead/5000_cols/repeated_batches` | 515,000 | 5,000 | After the change it is exactly one search per leaf column per row group. # What changes are included in this PR? - Adds `WriterProperties::resolve_column_properties`, which searches the per-column map once and returns a `ResolvedColumnProperties` holding every per-column setting already resolved against the file-wide defaults. The struct is `pub(crate)`; no public API is added. - `GenericColumnWriter::new` calls it once and stores the result. The per-batch and per-page paths, `ByteBudgetChunker::new`, and both `ColumnValueEncoder` implementations read from it instead of searching the map again. `ColumnValueEncoder::try_new` and `create_bloom_filter` now take the resolved settings; that trait is not nameable outside the crate. - The existing per-column accessors keep their behaviour and are reimplemented on top of the same resolution helpers, so the "column override, else file default, else constant" rule has one definition rather than one per accessor. # Are these changes tested? Yes. - The existing suite passes unchanged, with and without `encryption`: `cargo test -p parquet --features "arrow async encryption test_common experimental"`. - New `test_resolve_column_properties_matches_individual_accessors` asserts the one-pass resolution agrees with every individual accessor, for a column with overrides, a column that inherits the file defaults, and properties left entirely at their defaults. - To check the writer is byte-for-byte unchanged I wrote the same file from a build before and after this change, with a workload covering the settings this PR touches: per-column compression, encoding, dictionary on and off, page and dictionary page size limits, page-header statistics, a bloom filter, dictionary fallback on multi-KB values, and both writer versions. The two files are identical. Benchmark: cargo bench -p parquet --bench writer_overhead I did not have an idle machine, and criterion's wall-clock intervals were too wide there to be usable. I measured CPU time (user + sys) per iteration instead, which is far less sensitive to competing load: the minimum over 40 alternating runs of the two builds, with a separately measured ~13.3 ms of fixed benchmark setup subtracted. | benchmark case | before | after | | | --- | --- | --- | --- | | `writer_overhead/1000_cols` | 2.7 ms | 2.1 ms | see note | | `writer_overhead/5000_cols` | 20.2 ms | 18.5 ms | −8 % | | `writer_overhead/10000_cols` | 38.8 ms | 34.2 ms | −12 % | | `writer_overhead/1000_cols/repeated_batches` | 12.9 ms | 8.6 ms | −34 % | | `writer_overhead/5000_cols/repeated_batches` | 88.0 ms | 70.1 ms | −20 % | Note: at 1,000 columns with a single batch the remaining figure is close enough to the spread of the setup subtraction that I would not read a percentage into it. The other four imply about 40 ns per map search, consistently across all four shapes, which matches the search counts above. A run on an idle machine would be worth having, and the benchmark from apache#10878 makes that easy. `ColumnWriterImpl<Int32Type>` grows from 1312 to 1376 bytes to hold the resolved settings. Peak RSS on the 10,000 column benchmark was unchanged. # Are there any user-facing changes? No. No public API is added, removed or changed, and the bytes written are unchanged. # AI usage This PR was written with Claude Code and reviewed by a human. The byte-for-byte output comparison and the map-search counts above are the checks run to confirm the behaviour is unchanged. --------- Co-authored-by: Claude <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 18, 2026
apache#10878) # Which issue does this PR close? - Contributes to apache#9722. # Rationale for this change `parquet/benches/writer_overhead.rs` writes a single one-row batch per file. That measures column writer construction, allocation and metadata assembly, and it measures them well, but it never reaches the work a wide schema repeats on every batch: the per-column setup inside `ColumnWriter::write_batch`, and the per-mini-batch and per-page checks below it. With one `write` call per file, a change to that per-batch path is invisible here. # What changes are included in this PR? Adds `writer_overhead/{1000,5000}_cols/repeated_batches`. It holds the number of column writers fixed and writes 32 batches of 32 rows into a single row group, reusing the same wide schema and the same per-column `WriterProperties` as the existing cases, so the only difference from `writer_overhead/{n}_cols` is the number of `write` calls. The 10,000 column case is deliberately left out of the new benchmark so that one iteration stays well under a second. On the machine used here an iteration is roughly 13 ms at 1,000 columns and 90 ms at 5,000 columns. # Are these changes tested? No, this is a benchmark-only change. Run it with: cargo bench -p parquet --bench writer_overhead # Are there any user-facing changes? No. # AI usage This PR was written with Claude Code and reviewed by a human. --------- Co-authored-by: Claude Opus 5 <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 18, 2026
…pache#10880) # Which issue does this PR close? - Contributes to apache#9722. - Builds on apache#10878, which adds the `repeated_batches` benchmark cases used below. # Rationale for this change `WriterProperties` keeps per-column overrides in a `HashMap<ColumnPath, ColumnProperties>`. Every accessor that takes a `&ColumnPath` — `compression`, `encoding`, `dictionary_enabled`, `statistics_enabled`, `write_page_header_statistics`, `column_data_page_size_limit`, `column_dictionary_page_size_limit`, `column_data_page_v2_compression_ratio_threshold` and `bloom_filter_properties` — hashes that path and searches the map. `ColumnPath` is a `Vec<String>`, so each search hashes every part of the path and then compares strings on a hit. The column writers call those accessors repeatedly for the same leaf column: - 6 times while a column writer is constructed (`GenericColumnWriter::new` plus `ColumnValueEncoder::try_new`); - 2 more on every `write`, in `ByteBudgetChunker::new`; - 1 per mini-batch in `should_add_data_page`, and another in `should_dict_fallback` when a dictionary encoder is active; - 1 per page in `add_data_page`, plus one more for Data Page v2. `WriterProperties` is immutable once built, so all of that recomputes an answer that was already available when the column writer was created. Counting the searches directly (temporary instrumentation on the map access) over the `writer_overhead` shapes: | benchmark case | searches before | searches after | | --- | --- | --- | | `writer_overhead/1000_cols` | 10,000 | 1,000 | | `writer_overhead/5000_cols` | 50,000 | 5,000 | | `writer_overhead/10000_cols` | 100,000 | 10,000 | | `writer_overhead/1000_cols/repeated_batches` | 103,000 | 1,000 | | `writer_overhead/5000_cols/repeated_batches` | 515,000 | 5,000 | After the change it is exactly one search per leaf column per row group. # What changes are included in this PR? - Adds `WriterProperties::resolve_column_properties`, which searches the per-column map once and returns a `ResolvedColumnProperties` holding every per-column setting already resolved against the file-wide defaults. The struct is `pub(crate)`; no public API is added. - `GenericColumnWriter::new` calls it once and stores the result. The per-batch and per-page paths, `ByteBudgetChunker::new`, and both `ColumnValueEncoder` implementations read from it instead of searching the map again. `ColumnValueEncoder::try_new` and `create_bloom_filter` now take the resolved settings; that trait is not nameable outside the crate. - The existing per-column accessors keep their behaviour and are reimplemented on top of the same resolution helpers, so the "column override, else file default, else constant" rule has one definition rather than one per accessor. # Are these changes tested? Yes. - The existing suite passes unchanged, with and without `encryption`: `cargo test -p parquet --features "arrow async encryption test_common experimental"`. - New `test_resolve_column_properties_matches_individual_accessors` asserts the one-pass resolution agrees with every individual accessor, for a column with overrides, a column that inherits the file defaults, and properties left entirely at their defaults. - To check the writer is byte-for-byte unchanged I wrote the same file from a build before and after this change, with a workload covering the settings this PR touches: per-column compression, encoding, dictionary on and off, page and dictionary page size limits, page-header statistics, a bloom filter, dictionary fallback on multi-KB values, and both writer versions. The two files are identical. Benchmark: cargo bench -p parquet --bench writer_overhead I did not have an idle machine, and criterion's wall-clock intervals were too wide there to be usable. I measured CPU time (user + sys) per iteration instead, which is far less sensitive to competing load: the minimum over 40 alternating runs of the two builds, with a separately measured ~13.3 ms of fixed benchmark setup subtracted. | benchmark case | before | after | | | --- | --- | --- | --- | | `writer_overhead/1000_cols` | 2.7 ms | 2.1 ms | see note | | `writer_overhead/5000_cols` | 20.2 ms | 18.5 ms | −8 % | | `writer_overhead/10000_cols` | 38.8 ms | 34.2 ms | −12 % | | `writer_overhead/1000_cols/repeated_batches` | 12.9 ms | 8.6 ms | −34 % | | `writer_overhead/5000_cols/repeated_batches` | 88.0 ms | 70.1 ms | −20 % | Note: at 1,000 columns with a single batch the remaining figure is close enough to the spread of the setup subtraction that I would not read a percentage into it. The other four imply about 40 ns per map search, consistently across all four shapes, which matches the search counts above. A run on an idle machine would be worth having, and the benchmark from apache#10878 makes that easy. `ColumnWriterImpl<Int32Type>` grows from 1312 to 1376 bytes to hold the resolved settings. Peak RSS on the 10,000 column benchmark was unchanged. # Are there any user-facing changes? No. No public API is added, removed or changed, and the bytes written are unchanged. # AI usage This PR was written with Claude Code and reviewed by a human. The byte-for-byte output comparison and the map-search counts above are the checks run to confirm the behaviour is unchanged. --------- Co-authored-by: Claude <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 21, 2026
apache#10878) # Which issue does this PR close? - Contributes to apache#9722. # Rationale for this change `parquet/benches/writer_overhead.rs` writes a single one-row batch per file. That measures column writer construction, allocation and metadata assembly, and it measures them well, but it never reaches the work a wide schema repeats on every batch: the per-column setup inside `ColumnWriter::write_batch`, and the per-mini-batch and per-page checks below it. With one `write` call per file, a change to that per-batch path is invisible here. # What changes are included in this PR? Adds `writer_overhead/{1000,5000}_cols/repeated_batches`. It holds the number of column writers fixed and writes 32 batches of 32 rows into a single row group, reusing the same wide schema and the same per-column `WriterProperties` as the existing cases, so the only difference from `writer_overhead/{n}_cols` is the number of `write` calls. The 10,000 column case is deliberately left out of the new benchmark so that one iteration stays well under a second. On the machine used here an iteration is roughly 13 ms at 1,000 columns and 90 ms at 5,000 columns. # Are these changes tested? No, this is a benchmark-only change. Run it with: cargo bench -p parquet --bench writer_overhead # Are there any user-facing changes? No. # AI usage This PR was written with Claude Code and reviewed by a human. --------- Co-authored-by: Claude Opus 5 <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 21, 2026
…pache#10880) # Which issue does this PR close? - Contributes to apache#9722. - Builds on apache#10878, which adds the `repeated_batches` benchmark cases used below. # Rationale for this change `WriterProperties` keeps per-column overrides in a `HashMap<ColumnPath, ColumnProperties>`. Every accessor that takes a `&ColumnPath` — `compression`, `encoding`, `dictionary_enabled`, `statistics_enabled`, `write_page_header_statistics`, `column_data_page_size_limit`, `column_dictionary_page_size_limit`, `column_data_page_v2_compression_ratio_threshold` and `bloom_filter_properties` — hashes that path and searches the map. `ColumnPath` is a `Vec<String>`, so each search hashes every part of the path and then compares strings on a hit. The column writers call those accessors repeatedly for the same leaf column: - 6 times while a column writer is constructed (`GenericColumnWriter::new` plus `ColumnValueEncoder::try_new`); - 2 more on every `write`, in `ByteBudgetChunker::new`; - 1 per mini-batch in `should_add_data_page`, and another in `should_dict_fallback` when a dictionary encoder is active; - 1 per page in `add_data_page`, plus one more for Data Page v2. `WriterProperties` is immutable once built, so all of that recomputes an answer that was already available when the column writer was created. Counting the searches directly (temporary instrumentation on the map access) over the `writer_overhead` shapes: | benchmark case | searches before | searches after | | --- | --- | --- | | `writer_overhead/1000_cols` | 10,000 | 1,000 | | `writer_overhead/5000_cols` | 50,000 | 5,000 | | `writer_overhead/10000_cols` | 100,000 | 10,000 | | `writer_overhead/1000_cols/repeated_batches` | 103,000 | 1,000 | | `writer_overhead/5000_cols/repeated_batches` | 515,000 | 5,000 | After the change it is exactly one search per leaf column per row group. # What changes are included in this PR? - Adds `WriterProperties::resolve_column_properties`, which searches the per-column map once and returns a `ResolvedColumnProperties` holding every per-column setting already resolved against the file-wide defaults. The struct is `pub(crate)`; no public API is added. - `GenericColumnWriter::new` calls it once and stores the result. The per-batch and per-page paths, `ByteBudgetChunker::new`, and both `ColumnValueEncoder` implementations read from it instead of searching the map again. `ColumnValueEncoder::try_new` and `create_bloom_filter` now take the resolved settings; that trait is not nameable outside the crate. - The existing per-column accessors keep their behaviour and are reimplemented on top of the same resolution helpers, so the "column override, else file default, else constant" rule has one definition rather than one per accessor. # Are these changes tested? Yes. - The existing suite passes unchanged, with and without `encryption`: `cargo test -p parquet --features "arrow async encryption test_common experimental"`. - New `test_resolve_column_properties_matches_individual_accessors` asserts the one-pass resolution agrees with every individual accessor, for a column with overrides, a column that inherits the file defaults, and properties left entirely at their defaults. - To check the writer is byte-for-byte unchanged I wrote the same file from a build before and after this change, with a workload covering the settings this PR touches: per-column compression, encoding, dictionary on and off, page and dictionary page size limits, page-header statistics, a bloom filter, dictionary fallback on multi-KB values, and both writer versions. The two files are identical. Benchmark: cargo bench -p parquet --bench writer_overhead I did not have an idle machine, and criterion's wall-clock intervals were too wide there to be usable. I measured CPU time (user + sys) per iteration instead, which is far less sensitive to competing load: the minimum over 40 alternating runs of the two builds, with a separately measured ~13.3 ms of fixed benchmark setup subtracted. | benchmark case | before | after | | | --- | --- | --- | --- | | `writer_overhead/1000_cols` | 2.7 ms | 2.1 ms | see note | | `writer_overhead/5000_cols` | 20.2 ms | 18.5 ms | −8 % | | `writer_overhead/10000_cols` | 38.8 ms | 34.2 ms | −12 % | | `writer_overhead/1000_cols/repeated_batches` | 12.9 ms | 8.6 ms | −34 % | | `writer_overhead/5000_cols/repeated_batches` | 88.0 ms | 70.1 ms | −20 % | Note: at 1,000 columns with a single batch the remaining figure is close enough to the spread of the setup subtraction that I would not read a percentage into it. The other four imply about 40 ns per map search, consistently across all four shapes, which matches the search counts above. A run on an idle machine would be worth having, and the benchmark from apache#10878 makes that easy. `ColumnWriterImpl<Int32Type>` grows from 1312 to 1376 bytes to hold the resolved settings. Peak RSS on the 10,000 column benchmark was unchanged. # Are there any user-facing changes? No. No public API is added, removed or changed, and the bytes written are unchanged. # AI usage This PR was written with Claude Code and reviewed by a human. The byte-for-byte output comparison and the map-search counts above are the checks run to confirm the behaviour is unchanged. --------- Co-authored-by: Claude <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 25, 2026
apache#10878) # Which issue does this PR close? - Contributes to apache#9722. # Rationale for this change `parquet/benches/writer_overhead.rs` writes a single one-row batch per file. That measures column writer construction, allocation and metadata assembly, and it measures them well, but it never reaches the work a wide schema repeats on every batch: the per-column setup inside `ColumnWriter::write_batch`, and the per-mini-batch and per-page checks below it. With one `write` call per file, a change to that per-batch path is invisible here. # What changes are included in this PR? Adds `writer_overhead/{1000,5000}_cols/repeated_batches`. It holds the number of column writers fixed and writes 32 batches of 32 rows into a single row group, reusing the same wide schema and the same per-column `WriterProperties` as the existing cases, so the only difference from `writer_overhead/{n}_cols` is the number of `write` calls. The 10,000 column case is deliberately left out of the new benchmark so that one iteration stays well under a second. On the machine used here an iteration is roughly 13 ms at 1,000 columns and 90 ms at 5,000 columns. # Are these changes tested? No, this is a benchmark-only change. Run it with: cargo bench -p parquet --bench writer_overhead # Are there any user-facing changes? No. # AI usage This PR was written with Claude Code and reviewed by a human. --------- Co-authored-by: Claude Opus 5 <[email protected]>
Rich-T-kid
pushed a commit
to Rich-T-kid/arrow-rs
that referenced
this pull request
Sep 25, 2026
…pache#10880) # Which issue does this PR close? - Contributes to apache#9722. - Builds on apache#10878, which adds the `repeated_batches` benchmark cases used below. # Rationale for this change `WriterProperties` keeps per-column overrides in a `HashMap<ColumnPath, ColumnProperties>`. Every accessor that takes a `&ColumnPath` — `compression`, `encoding`, `dictionary_enabled`, `statistics_enabled`, `write_page_header_statistics`, `column_data_page_size_limit`, `column_dictionary_page_size_limit`, `column_data_page_v2_compression_ratio_threshold` and `bloom_filter_properties` — hashes that path and searches the map. `ColumnPath` is a `Vec<String>`, so each search hashes every part of the path and then compares strings on a hit. The column writers call those accessors repeatedly for the same leaf column: - 6 times while a column writer is constructed (`GenericColumnWriter::new` plus `ColumnValueEncoder::try_new`); - 2 more on every `write`, in `ByteBudgetChunker::new`; - 1 per mini-batch in `should_add_data_page`, and another in `should_dict_fallback` when a dictionary encoder is active; - 1 per page in `add_data_page`, plus one more for Data Page v2. `WriterProperties` is immutable once built, so all of that recomputes an answer that was already available when the column writer was created. Counting the searches directly (temporary instrumentation on the map access) over the `writer_overhead` shapes: | benchmark case | searches before | searches after | | --- | --- | --- | | `writer_overhead/1000_cols` | 10,000 | 1,000 | | `writer_overhead/5000_cols` | 50,000 | 5,000 | | `writer_overhead/10000_cols` | 100,000 | 10,000 | | `writer_overhead/1000_cols/repeated_batches` | 103,000 | 1,000 | | `writer_overhead/5000_cols/repeated_batches` | 515,000 | 5,000 | After the change it is exactly one search per leaf column per row group. # What changes are included in this PR? - Adds `WriterProperties::resolve_column_properties`, which searches the per-column map once and returns a `ResolvedColumnProperties` holding every per-column setting already resolved against the file-wide defaults. The struct is `pub(crate)`; no public API is added. - `GenericColumnWriter::new` calls it once and stores the result. The per-batch and per-page paths, `ByteBudgetChunker::new`, and both `ColumnValueEncoder` implementations read from it instead of searching the map again. `ColumnValueEncoder::try_new` and `create_bloom_filter` now take the resolved settings; that trait is not nameable outside the crate. - The existing per-column accessors keep their behaviour and are reimplemented on top of the same resolution helpers, so the "column override, else file default, else constant" rule has one definition rather than one per accessor. # Are these changes tested? Yes. - The existing suite passes unchanged, with and without `encryption`: `cargo test -p parquet --features "arrow async encryption test_common experimental"`. - New `test_resolve_column_properties_matches_individual_accessors` asserts the one-pass resolution agrees with every individual accessor, for a column with overrides, a column that inherits the file defaults, and properties left entirely at their defaults. - To check the writer is byte-for-byte unchanged I wrote the same file from a build before and after this change, with a workload covering the settings this PR touches: per-column compression, encoding, dictionary on and off, page and dictionary page size limits, page-header statistics, a bloom filter, dictionary fallback on multi-KB values, and both writer versions. The two files are identical. Benchmark: cargo bench -p parquet --bench writer_overhead I did not have an idle machine, and criterion's wall-clock intervals were too wide there to be usable. I measured CPU time (user + sys) per iteration instead, which is far less sensitive to competing load: the minimum over 40 alternating runs of the two builds, with a separately measured ~13.3 ms of fixed benchmark setup subtracted. | benchmark case | before | after | | | --- | --- | --- | --- | | `writer_overhead/1000_cols` | 2.7 ms | 2.1 ms | see note | | `writer_overhead/5000_cols` | 20.2 ms | 18.5 ms | −8 % | | `writer_overhead/10000_cols` | 38.8 ms | 34.2 ms | −12 % | | `writer_overhead/1000_cols/repeated_batches` | 12.9 ms | 8.6 ms | −34 % | | `writer_overhead/5000_cols/repeated_batches` | 88.0 ms | 70.1 ms | −20 % | Note: at 1,000 columns with a single batch the remaining figure is close enough to the spread of the setup subtraction that I would not read a percentage into it. The other four imply about 40 ns per map search, consistently across all four shapes, which matches the search counts above. A run on an idle machine would be worth having, and the benchmark from apache#10878 makes that easy. `ColumnWriterImpl<Int32Type>` grows from 1312 to 1376 bytes to hold the resolved settings. Peak RSS on the 10,000 column benchmark was unchanged. # Are there any user-facing changes? No. No public API is added, removed or changed, and the bytes written are unchanged. # AI usage This PR was written with Claude Code and reviewed by a human. The byte-for-byte output comparison and the map-search counts above are the checks run to confirm the behaviour is unchanged. --------- Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
parquet/benches/writer_overhead.rswrites a single one-row batch per file. Thatmeasures column writer construction, allocation and metadata assembly, and it
measures them well, but it never reaches the work a wide schema repeats on every
batch: the per-column setup inside
ColumnWriter::write_batch, and theper-mini-batch and per-page checks below it.
With one
writecall per file, a change to that per-batch path is invisible here.What changes are included in this PR?
Adds
writer_overhead/{1000,5000}_cols/repeated_batches. It holds the number ofcolumn writers fixed and writes 32 batches of 32 rows into a single row group,
reusing the same wide schema and the same per-column
WriterPropertiesas theexisting cases, so the only difference from
writer_overhead/{n}_colsis thenumber of
writecalls.The 10,000 column case is deliberately left out of the new benchmark so that one
iteration stays well under a second. On the machine used here an iteration is
roughly 13 ms at 1,000 columns and 90 ms at 5,000 columns.
Are these changes tested?
No, this is a benchmark-only change. Run it with:
Are there any user-facing changes?
No.
AI usage
This PR was written with Claude Code and reviewed by a human.