Skip to content

feat(ipc): Remove per-message flush in IPC writer hot path - #9763

Merged
alamb merged 1 commit into
apache:mainfrom
pchintar:remove-ipc-flush-hotpath
Apr 21, 2026
Merged

feat(ipc): Remove per-message flush in IPC writer hot path#9763
alamb merged 1 commit into
apache:mainfrom
pchintar:remove-ipc-flush-hotpath

Conversation

@pchintar

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Currently, flush() is called unconditionally in write_body_buffers and write_continuation - both executed per batch. This forces per-batch syscalls, breaks write coalescing, and adds unnecessary overhead. These flushes are not required for correctness (IPC boundaries are length-prefixed, no durability guarantees).

What changes are included in this PR?

  • Remove flush() from write_body_buffers and write_continuation
  • Add self.writer.flush()? to StreamWriter::finish() (missing; FileWriter::finish() already has it)

Are these changes tested?

Yes the changes were tested successfully by running:

cargo test -p arrow-ipc
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings

Are there any user-facing changes?

No, There are no changes made to any Public APIs

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Apr 18, 2026

@alamb alamb 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.

Thank you @pchintar -- this makes sense to me

I also verified that there are flush methods on FileWriter and StreamWriter, if anyone downstream really needs to flush more frequently

Comment thread arrow-ipc/src/writer.rs
}

write_continuation(&mut self.writer, &self.write_options, 0)?;
self.writer.flush()?;

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.

It makes sense to me to flush the stream on completion

@pchintar
pchintar force-pushed the remove-ipc-flush-hotpath branch from be1d690 to ac159b3 Compare April 21, 2026 01:26
@alamb
alamb merged commit d03571b into apache:main Apr 21, 2026
26 checks passed
@alamb

alamb commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Thanks again @pchintar

Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Jun 2, 2026
# Which issue does this PR close?

- Closes apache#9762 .

# Rationale for this change

Currently, `flush()` is called unconditionally in `write_body_buffers`
and `write_continuation` - both executed per batch. This forces
per-batch syscalls, breaks write coalescing, and adds unnecessary
overhead. These flushes are not required for correctness (IPC boundaries
are length-prefixed, no durability guarantees).

# What changes are included in this PR?

- Remove `flush()` from `write_body_buffers` and `write_continuation`
- Add `self.writer.flush()?` to `StreamWriter::finish()` (missing;
`FileWriter::finish()` already has it)

# Are these changes tested?

Yes the changes were tested successfully by running:
```bash
cargo test -p arrow-ipc
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
```

# Are there any user-facing changes?

No, There are no changes made to any Public APIs
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 performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove per-message flush overhead in Arrow IPC writer

2 participants