Skip to content

Comments

iceberg: reduce per-batch overhead in write_data_files#35179

Merged
DAlperin merged 1 commit intoMaterializeInc:mainfrom
DAlperin:dov/reduce-batch-overhead
Feb 24, 2026
Merged

iceberg: reduce per-batch overhead in write_data_files#35179
DAlperin merged 1 commit intoMaterializeInc:mainfrom
DAlperin:dov/reduce-batch-overhead

Conversation

@DAlperin
Copy link
Member

Box the DeltaWriter values stored in the in_flight_batches HashMap. DeltaWriter is a large struct (containing multiple sub-writers, a 100k-entry seen_rows HashMap, VecDeque, Arrow schemas, etc.), and storing it inline means every HashMap insert, resize, and extract_if memcpy's the entire struct. Boxing reduces this to moving an pointer.

Also hoist invariant work out of the per-batch create_delta_writer closure:

  • Position delete and equality delete Iceberg schemas (arrow_schema_to_schema) are now computed once upfront rather than on every batch.
  • EqualityDeleteWriterConfig (which internally calls schema_to_arrow_schema and builds a RecordBatchProjector) is now constructed once and cloned, avoiding redundant schema conversions per batch.

(The update to iceberg-rs just includes a commit that makes EqualityDeleteWriterConfig Clone)

@DAlperin DAlperin requested a review from a team February 23, 2026 17:00
@DAlperin DAlperin requested a review from a team as a code owner February 23, 2026 17:00
@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Thanks for opening this PR! Here are a few tips to help make the review process smooth for everyone.

PR title guidelines

  • Use imperative mood: "Fix X" not "Fixed X" or "Fixes X"
  • Be specific: "Fix panic in catalog sync when controller restarts" not "Fix bug" or "Update catalog code"
  • Prefix with area if helpful: compute: , storage: , adapter: , sql:

Pre-merge checklist

  • The PR title is descriptive and will make sense in the git log.
  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).

@DAlperin DAlperin force-pushed the dov/reduce-batch-overhead branch from f4ac92a to 9f86c0c Compare February 23, 2026 17:05
@DAlperin
Copy link
Member Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Contributor

@ublubu ublubu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@martykulma martykulma left a comment

Choose a reason for hiding this comment

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

nice!

Comment on lines 1104 to 1108
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this again, I don't think you need any of these clones.

Box the DeltaWriter values stored in the in_flight_batches HashMap.
DeltaWriter is a large struct (containing multiple sub-writers, a 100k-entry
seen_rows HashMap, VecDeque, Arrow schemas, etc.), and storing it inline
means every HashMap insert, resize, and extract_if memcpy's the entire
struct. Boxing reduces this to moving an pointer.

Also hoist invariant work out of the per-batch create_delta_writer closure:
- Position delete and equality delete Iceberg schemas (arrow_schema_to_schema)
  are now computed once upfront rather than on every batch.
- EqualityDeleteWriterConfig (which internally calls schema_to_arrow_schema
  and builds a RecordBatchProjector) is now constructed once and cloned,
  avoiding redundant schema conversions per batch.
@DAlperin DAlperin force-pushed the dov/reduce-batch-overhead branch from 9f86c0c to 8afd475 Compare February 24, 2026 21:32
@DAlperin DAlperin enabled auto-merge (squash) February 24, 2026 21:32
@DAlperin DAlperin merged commit c194606 into MaterializeInc:main Feb 24, 2026
135 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