Skip to content

fix(parquet): add memory control for parquet write#123

Merged
zjw1111 merged 5 commits into
alibaba:mainfrom
zjw1111:fix-parquet-oom
Feb 10, 2026
Merged

fix(parquet): add memory control for parquet write#123
zjw1111 merged 5 commits into
alibaba:mainfrom
zjw1111:fix-parquet-oom

Conversation

@zjw1111

@zjw1111 zjw1111 commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

Purpose

Linked issue: close #xxx

In parquet writer, the memory occupied by all batches of data is only released after the entire row group has been flushed. This can lead to excessive memory usage during the writing process, posing a risk of out-of-memory (OOM) errors. This PR adds memory control, which forces flush the row group when the pool's memory usage reaches a specified threshold.

Tests

ParquetFormatWriterTest.TestMemoryControl

API and Format

Documentation

@zjw1111 zjw1111 changed the title add memory control for parquet write fix(parquet): add memory control for parquet write Feb 6, 2026
@lucasfang
lucasfang requested a review from Copilot February 6, 2026 09:25

Copilot AI 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.

Pull request overview

This PR adds memory control to the Parquet writer to prevent out-of-memory errors during write operations. Previously, all data batches in a row group were held in memory until the entire row group was flushed, which could lead to excessive memory usage. The new implementation monitors memory usage and forces a row group flush when memory exceeds a configurable threshold (default 512MB).

Changes:

  • Added memory control logic that checks pool memory usage before writing each batch and forces row group flush when threshold is exceeded
  • Added new configuration option parquet.writer.max.memory.use with a default value of 512MB
  • Updated all ParquetFormatWriter::Create calls to include the new max_memory_use parameter

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/paimon/format/parquet/parquet_format_defs.h Added PARQUET_WRITER_MAX_MEMORY_USE constant and DEFAULT_PARQUET_WRITER_MAX_MEMORY_USE (512MB)
src/paimon/format/parquet/parquet_format_writer.h Added max_memory_use parameter to Create method and constructor, added max_memory_use_ member variable
src/paimon/format/parquet/parquet_format_writer.cpp Implemented memory check in AddBatch that triggers NewBufferedRowGroup when threshold exceeded
src/paimon/format/parquet/parquet_writer_builder.h Removed unused includes (arrow/util/compression.h, paimon/fs/file_system_factory.h)
src/paimon/format/parquet/parquet_writer_builder.cpp Added logic to extract max_memory_use from options and pass to ParquetFormatWriter::Create
src/paimon/format/parquet/parquet_format_writer_test.cpp Added TestMemoryControl test case, updated all Create calls with new parameter, added test infrastructure for null values
src/paimon/format/parquet/predicate_pushdown_test.cpp Updated ParquetFormatWriter::Create call with DEFAULT_PARQUET_WRITER_MAX_MEMORY_USE parameter
src/paimon/format/parquet/parquet_stats_extractor_test.cpp Added include for parquet_format_defs.h, updated Create calls with new parameter
src/paimon/format/parquet/parquet_file_batch_reader_test.cpp Removed unused include (arrow/util/thread_pool.h), updated Create call with new parameter
src/paimon/format/parquet/file_reader_wrapper_test.cpp Added include for parquet_format_defs.h, updated Create call with new parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/paimon/format/parquet/parquet_format_writer_test.cpp Outdated
Comment thread src/paimon/format/parquet/parquet_format_writer.cpp
Comment thread src/paimon/format/parquet/parquet_format_writer.cpp

@lucasfang lucasfang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1

@zjw1111
zjw1111 merged commit 623db38 into alibaba:main Feb 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants