Skip to content

perf(parquet): resolve per-column writer properties once per column - #10880

Merged
Jefffrey merged 3 commits into
apache:mainfrom
pydantic:claude/parquet-resolve-column-props
Aug 31, 2026
Merged

Jefffrey merged 3 commits into
apache:mainfrom
pydantic:claude/parquet-resolve-column-props

Conversation

@adriangb

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

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.

…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.
`WriterProperties` keeps per-column overrides in a
`HashMap<ColumnPath, ColumnProperties>`, and every accessor that takes a
`&ColumnPath` hashes that path and searches the map. `ColumnPath` is a
`Vec<String>`, so each of those lookups hashes every part of the path.

The column writers called those accessors repeatedly for the same leaf
column: about six times when a column writer is created, twice more on
every `write` (in `ByteBudgetChunker::new`), once per mini-batch (in
`should_add_data_page` and `should_dict_fallback`), and once per page (in
`add_data_page`). The settings cannot change over a column writer's
lifetime, since `WriterProperties` is immutable once built, so all of that
repeats the same answer.

Add `WriterProperties::resolve_column_properties`, which searches the
override map once and returns every per-column setting already resolved
against the file-wide defaults. `GenericColumnWriter::new` calls it once
and stores the result; the per-batch and per-page paths, the byte budget
chunker, and the value encoders read from it instead of searching the map
again.

The existing per-column accessors keep their behaviour and are now
implemented in terms of the same resolution helpers, so there is one
definition of how a column setting falls back to its default.
@github-actions github-actions Bot added the parquet parquet crate label Aug 27, 2026
@alamb alamb added the performance Speed or memory optimizations label Aug 27, 2026
@alamb

alamb commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

It makes sense to me

Claude mentioned this still happens once per row group

So one potential follow on would be

  • Hoist across row groups. Column writers are recreated per row group, so a wide schema × many row groups still does one search per column per row group. Caching Vec per leaf in SerializedFileWriter/ArrowWriter would make it once per file.

@alamb

alamb commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

(this PR has a merge conflict)

…conflicts-9hymy6

# Conflicts:
#	parquet/benches/writer_overhead.rs
@adriangb

Copy link
Copy Markdown
Contributor Author

Thanks Andrew. Addressed your comments and resolved the merge conflict. I opened #10896 to track hoisting this up further.

@etseidl etseidl left a comment

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.

Clever!

@Jefffrey
Jefffrey merged commit 5fa7c8c into apache:main Aug 31, 2026
18 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @adriangb, @alamb & @etseidl

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
…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
…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
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet parquet crate performance Speed or memory optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants