Skip to content

perf(ipc): benchmark stream encoder - #10447

Merged
Jefffrey merged 3 commits into
apache:mainfrom
Phoenix500526:issue/10373
Jul 30, 2026
Merged

perf(ipc): benchmark stream encoder#10447
Jefffrey merged 3 commits into
apache:mainfrom
Phoenix500526:issue/10373

Conversation

@Phoenix500526

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Add a StreamEncoder benchmarks so that we can catch regressions without measuring sink IO.

What changes are included in this PR?

Are these changes tested?

Yes

Are there any user-facing changes?

No

StreamEncoder benchmarks catch regressions without measuring sink IO.

Closes apache#10373

Signed-off-by: Jiawei Zhao <Phoenix500526@163.com>
@Phoenix500526

Copy link
Copy Markdown
Contributor Author

cc @Rich-T-kid

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jul 28, 2026

@Rich-T-kid Rich-T-kid 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 @Phoenix500526, I left a comment but overall this looks good to me

Comment thread arrow-ipc/benches/ipc_writer.rs Outdated
Comment on lines +86 to +93
let mut encoder =
StreamEncoder::try_new_with_options(batch.schema().as_ref(), options).unwrap();
let mut encoded_len = 0;
for _ in 0..10 {
encoded_len += encoded_buffers_len(encoder.encode(&batch).unwrap());
}
encoded_len += encoded_buffers_len(encoder.finish().unwrap());
black_box(encoded_len);

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.

wouldn't we want to call black_box() on encoder.encode()? why are we calling it on the final computed length?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. The final length prevents the aggregate from being optimized away, but black-boxing the encoded buffers is a better benchmark boundary. I’ll update the StreamEncoder cases to black-box the encode / finish results before computing the length. Done in 868d643

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.

so do we still need to accumulate the lengths like this, or black boxing the encode methods is already sufficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that makes sense. Once the encoded buffers are passed through black_box, the length accumulation is redundant and adds extra work to the benchmark. I’ll simplify this to black-box the encode / finish results directly.

Black-box StreamEncoder benchmark outputs before measuring their lengths so the benchmark boundary is less fragile.

Signed-off-by: Jiawei Zhao <Phoenix500526@163.com>
Black-boxing the StreamEncoder outputs is enough to keep the work observable. Avoid traversing buffer lengths in the measured path.

Signed-off-by: Jiawei Zhao <Phoenix500526@163.com>
@Jefffrey Jefffrey added the development-process Related to development process of arrow-rs label Jul 30, 2026
@Jefffrey
Jefffrey merged commit e4df827 into apache:main Jul 30, 2026
30 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @Phoenix500526 & @Rich-T-kid

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 development-process Related to development process of arrow-rs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add benchmarks to measure Stream Encoder

3 participants