Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use bytes in arrow-flight #3359

Merged
merged 3 commits into from
Dec 20, 2022
Merged

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Dec 17, 2022

Which issue does this PR close?

Closes #.

Rationale for this change

Prost supports zero-copy reading of binary payloads, internally slicing the original Bytes comprising the HTTP frame read by hyper. This PR tweaks prost-build to generate structs with Bytes instead of Vec<u8> which should cut down on the amount of data copying during decode.

TBC there will still be copies resulting from:

  • prost_types::Any uses Vec not Bytes (we could work around this in a subsequent PR)
  • Conversion to Buffer involves a memcpy

What changes are included in this PR?

Are there any user-facing changes?

@tustvold tustvold added the api-change Changes to the arrow API label Dec 17, 2022
@tustvold tustvold requested a review from alamb December 17, 2022 20:01
@github-actions github-actions bot added the arrow-flight Changes to the arrow-flight crate label Dec 17, 2022
@@ -23,18 +23,14 @@ use arrow_flight::{
Location, SchemaAsIpc, Ticket,
};
use futures::{stream, Stream};
use prost::Message;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the changes in this file are actually clippy lints that weren't being picked up by CI (which I have also fixed)

@@ -94,3 +94,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// As the proto file is checked in, the build should not fail if the file is not found
Ok(())
}

fn prost_config() -> prost_build::Config {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately prost_build::Config is not Clone so this was my workaround

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Looks good to me -- thank you @tustvold

I recommend we wait for a few days for more feedback on this API prior to merging

We could also perhaps add some documentation changes / explanation in the PR or code to help migration.

cc @avantgardnerio I suspect this will require some changes downstream in Ballista


fn prost_config() -> prost_build::Config {
let mut config = prost_build::Config::new();
config.bytes([".arrow"]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should put a note / link that this uses the Bytes API to avoid copies

@tustvold tustvold force-pushed the use-bytes-in-arrow-flight branch from 407ddb6 to fddc134 Compare December 19, 2022 21:05
@tustvold
Copy link
Contributor Author

I plan to merge this this afternoon unless there are any objections

@tustvold tustvold merged commit 8b84d4d into apache:master Dec 20, 2022
@ursabot
Copy link

ursabot commented Dec 20, 2022

Benchmark runs are scheduled for baseline = f521e11 and contender = 8b84d4d. 8b84d4d is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Changes to the arrow API arrow-flight Changes to the arrow-flight crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants