Skip to content

Improvements for parquet writing performance #7824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jhorstmann
Copy link
Contributor

Which issue does this PR close?

We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.

Rationale for this change

The changes in this PR improve parquet writing performance for primitives without bloom filters by between 15% and 30%.

What changes are included in this PR?

There was not a single bottleneck to fix, instead several small improvements contributed to the performance increase:

  • Optimize counting of values and nulls by replacing a loop with code that can be vectorized by the compiler. The number of nulls can also be calculated from the lengths of the array and the number of values to write, instead of being counted separately.
  • Change asserts in BitWriter::put_value to debug_assert since these should never be triggered by users of the code and are not required for soundness.
  • Use slice iteration instead of indexing in flush_bit_packed_run to avoid a bounds check.
  • Separate iteration for def_levels and non_null_indices using specialized iterators. Range iteration is TrustedLen and so avoids multiple capacity checks and BitIndexIterator is more optimized for collecting non-null indices.
  • Cache logical nulls of the array to avoid clones or repeated recomputation. This should avoid a pathological case when writing lists of arrays that need logical nulls.

Are these changes tested?

Logic should be covered by existing tests.

Are there any user-facing changes?

No, all changes are to implementation details and do not affect public apis.

@github-actions github-actions bot added parquet Changes to the parquet crate arrow Changes to the arrow crate labels Jun 29, 2025
@jhorstmann jhorstmann force-pushed the parquet-writing-performance branch from 3a807a5 to 11e76a3 Compare June 29, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate parquet Changes to the parquet crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Perf: Investigate and improve parquet writing performance
1 participant