You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Phoenix500526 (via GitHub)" <gi...@apache.org> on 2026/07/28 02:22:02 UTC
[PR] perf(ipc): benchmark stream encoder [arrow-rs]
Phoenix500526 opened a new pull request, #10447:
URL: https://github.com/apache/arrow-rs/pull/10447
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
-->
- Closes #10373.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
Add a `StreamEncoder` benchmarks so that we can catch regressions without measuring sink IO.
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
# Are these changes tested?
Yes
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
If this PR claims a performance improvement, please include evidence such as benchmark results.
-->
# Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ipc): benchmark stream encoder [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #10447:
URL: https://github.com/apache/arrow-rs/pull/10447#issuecomment-5132323101
thanks @Phoenix500526 & @Rich-T-kid
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ipc): benchmark stream encoder [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10447:
URL: https://github.com/apache/arrow-rs/pull/10447#discussion_r3674102436
##########
arrow-ipc/benches/ipc_writer.rs:
##########
@@ -60,6 +64,36 @@ fn criterion_benchmark(c: &mut Criterion) {
})
});
+ group.bench_function("StreamEncoder/encode_10", |b| {
+ let batch = create_batch(8192, true);
+ b.iter(move || {
+ let mut encoder = StreamEncoder::try_new(batch.schema().as_ref()).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);
+ })
+ });
+
+ group.bench_function("StreamEncoder/encode_10/zstd", |b| {
+ let batch = create_batch(8192, true);
+ b.iter(move || {
+ let options = IpcWriteOptions::default()
+ .try_with_compression(Some(CompressionType::ZSTD))
+ .unwrap();
+ 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);
Review Comment:
so do we still need to accumulate the lengths like this, or black boxing the encode methods is already sufficient?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ipc): benchmark stream encoder [arrow-rs]
Posted by "Phoenix500526 (via GitHub)" <gi...@apache.org>.
Phoenix500526 commented on code in PR #10447:
URL: https://github.com/apache/arrow-rs/pull/10447#discussion_r3682829819
##########
arrow-ipc/benches/ipc_writer.rs:
##########
@@ -60,6 +64,36 @@ fn criterion_benchmark(c: &mut Criterion) {
})
});
+ group.bench_function("StreamEncoder/encode_10", |b| {
+ let batch = create_batch(8192, true);
+ b.iter(move || {
+ let mut encoder = StreamEncoder::try_new(batch.schema().as_ref()).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);
+ })
+ });
+
+ group.bench_function("StreamEncoder/encode_10/zstd", |b| {
+ let batch = create_batch(8192, true);
+ b.iter(move || {
+ let options = IpcWriteOptions::default()
+ .try_with_compression(Some(CompressionType::ZSTD))
+ .unwrap();
+ 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);
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ipc): benchmark stream encoder [arrow-rs]
Posted by "Phoenix500526 (via GitHub)" <gi...@apache.org>.
Phoenix500526 commented on PR #10447:
URL: https://github.com/apache/arrow-rs/pull/10447#issuecomment-5099207615
cc @Rich-T-kid
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ipc): benchmark stream encoder [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #10447:
URL: https://github.com/apache/arrow-rs/pull/10447
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ipc): benchmark stream encoder [arrow-rs]
Posted by "Phoenix500526 (via GitHub)" <gi...@apache.org>.
Phoenix500526 commented on code in PR #10447:
URL: https://github.com/apache/arrow-rs/pull/10447#discussion_r3670705498
##########
arrow-ipc/benches/ipc_writer.rs:
##########
@@ -60,6 +64,36 @@ fn criterion_benchmark(c: &mut Criterion) {
})
});
+ group.bench_function("StreamEncoder/encode_10", |b| {
+ let batch = create_batch(8192, true);
+ b.iter(move || {
+ let mut encoder = StreamEncoder::try_new(batch.schema().as_ref()).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);
+ })
+ });
+
+ group.bench_function("StreamEncoder/encode_10/zstd", |b| {
+ let batch = create_batch(8192, true);
+ b.iter(move || {
+ let options = IpcWriteOptions::default()
+ .try_with_compression(Some(CompressionType::ZSTD))
+ .unwrap();
+ 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);
Review Comment:
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ipc): benchmark stream encoder [arrow-rs]
Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on code in PR #10447:
URL: https://github.com/apache/arrow-rs/pull/10447#discussion_r3666330792
##########
arrow-ipc/benches/ipc_writer.rs:
##########
@@ -60,6 +64,36 @@ fn criterion_benchmark(c: &mut Criterion) {
})
});
+ group.bench_function("StreamEncoder/encode_10", |b| {
+ let batch = create_batch(8192, true);
+ b.iter(move || {
+ let mut encoder = StreamEncoder::try_new(batch.schema().as_ref()).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);
+ })
+ });
+
+ group.bench_function("StreamEncoder/encode_10/zstd", |b| {
+ let batch = create_batch(8192, true);
+ b.iter(move || {
+ let options = IpcWriteOptions::default()
+ .try_with_compression(Some(CompressionType::ZSTD))
+ .unwrap();
+ 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);
Review Comment:
wouldn't we want to call `black_box()` on `encoder.encode()`? why are we calling it on the final computed length?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org