Skip to content

[TASK-429] Pre-size Arrow builders and recommend jemalloc for write path#430

Merged
luoyuxia merged 4 commits intoapache:mainfrom
fresh-borzoni:jemalloc-pre-size
Mar 8, 2026
Merged

[TASK-429] Pre-size Arrow builders and recommend jemalloc for write path#430
luoyuxia merged 4 commits intoapache:mainfrom
fresh-borzoni:jemalloc-pre-size

Conversation

@fresh-borzoni
Copy link
Contributor

@fresh-borzoni fresh-borzoni commented Mar 7, 2026

Summary

close #429

  • Pre-size Arrow builders to DEFAULT_MAX_RECORD (256) capacity to eliminate reallocations
  • Document jemalloc as recommended allocator for Linux deployments
  • Add jemalloc setup to examples

Benchmark results (Linux, glibc, 8 threads, 100K cycles, 13-column schema)

Variant Throughput RSS delta
Default capacity raw Arrow baseline baseline
Pre-sized raw Arrow +30% -15%
Pre-sized fluss builder +4% -12%
jemalloc + pre-sized +45% vs default -25%

I will address these findings during benchmarking in

Follow-ups

@fresh-borzoni
Copy link
Contributor Author

@luoyuxia @leekeiabstraction PTAL 🙏

Copy link
Contributor

@leekeiabstraction leekeiabstraction left a comment

Choose a reason for hiding this comment

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

TY for the PR, left some comments

@fresh-borzoni
Copy link
Contributor Author

@leekeiabstraction Addressed magic number, PTAL 🙏

Copy link
Contributor

@leekeiabstraction leekeiabstraction left a comment

Choose a reason for hiding this comment

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

Approved, TY for the PR

Copy link

Copilot AI left a comment

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 implements two performance optimizations for the write path: pre-sizing Arrow column builders to DEFAULT_MAX_RECORD (256) capacity to eliminate growth reallocations, and documenting jemalloc (tikv-jemallocator) as the recommended allocator for production Linux deployments with an accompanying example setup.

Changes:

  • Pre-size all Arrow column builders (with_capacity instead of new) in RowAppendRecordBatchBuilder::create_builder, using a fixed capacity of 256 and a 64-byte average data buffer for variable-width types.
  • Add jemalloc documentation to the crate-level doc comment in lib.rs and configure it in the examples crate (Cargo.toml + example_table.rs).
  • Remove a stray blank line in crates/fluss/Cargo.toml.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/fluss/src/record/arrow.rs All Arrow builders now use with_capacity(256) instead of new(); variable-width types also pre-allocate data buffers; create_builder updated with a capacity parameter.
crates/fluss/src/lib.rs Crate-level doc comment expanded with a # Performance section recommending jemalloc for Linux production use.
crates/examples/Cargo.toml Adds tikv-jemallocator = "0.6" as a conditional dependency for non-MSVC targets.
crates/examples/src/example_table.rs Activates jemalloc as #[global_allocator] for the example binary.
crates/fluss/Cargo.toml Removes trailing blank line in dev-dependencies section.

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

@fresh-borzoni
Copy link
Contributor Author

Addressed comments

@fresh-borzoni
Copy link
Contributor Author

fixed ci/cd, example_table.rs includes the other two files as mod, so we don't need to add global allocator separately

Copy link
Contributor

@luoyuxia luoyuxia left a comment

Choose a reason for hiding this comment

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

@fresh-borzoni Thanks for the improvement. LGTM

@luoyuxia luoyuxia merged commit 251c1a9 into apache:main Mar 8, 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.

Reduce Arrow builder allocation overhead in write path(pre-size and jemalloc)

4 participants