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

Avoid useless memory copies in IPC reader. #2510

Merged
merged 1 commit into from Aug 19, 2022

Conversation

HaoYang670
Copy link
Contributor

Signed-off-by: remzi 13716567376yh@gmail.com

Which issue does this PR close?

Closes #2437.

Rationale for this change

What changes are included in this PR?

Are there any user-facing changes?

Yes.

Signed-off-by: remzi <13716567376yh@gmail.com>
@github-actions github-actions bot added the arrow Changes to the arrow crate label Aug 19, 2022
@@ -53,14 +53,11 @@ fn read_buffer(
) -> Result<Buffer> {
let start_offset = buf.offset() as usize;
let end_offset = start_offset + buf.length() as usize;
let buf_data = &a_data[start_offset..end_offset];
let buf_data = Buffer::from(&a_data[start_offset..end_offset]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we cannot slice on Buffer with length, we cannot implement a_data as a Buffer

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 the calculation above, I think we don't need to truncate the length, as end_offset is the end of the buffer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The end_offset is the end of buf, but not sure whether it is the end of a_data

Copy link
Contributor

Choose a reason for hiding this comment

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

Aah yes, brain fart on my part. R.e. making a_data a Buffer, we could always pass the length separately...

Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

There is definitely more that could be done here, but this is a solid start 👍

@tustvold tustvold merged commit ebe3d43 into apache:master Aug 19, 2022
@ursabot
Copy link

ursabot commented Aug 19, 2022

Benchmark runs are scheduled for baseline = 601968b and contender = ebe3d43. ebe3d43 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

@HaoYang670 HaoYang670 deleted the avoid_useless_copies_in_ipc branch August 19, 2022 12:26
@HaoYang670
Copy link
Contributor Author

Thank you, @tustvold
I just have a question (maybe it is an old question). Why don't we support truncate by length for Buffer.

@tustvold
Copy link
Contributor

I don't believe there is a particular reason, I think lifting length out of Bytes into Buffer would be a sensible change imo

@alamb
Copy link
Contributor

alamb commented Aug 19, 2022

Wow that was fast 🚀

} else if decompressed_length == LENGTH_NO_COMPRESSED_DATA {
// no compression
let data = &input[(LENGTH_OF_PREFIX_DATA as usize)..];
Buffer::from(data)
input.slice(LENGTH_OF_PREFIX_DATA as usize)
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

amrltqt pushed a commit to amrltqt/arrow-rs that referenced this pull request Aug 20, 2022
Signed-off-by: remzi <13716567376yh@gmail.com>

Signed-off-by: remzi <13716567376yh@gmail.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid unecessary copies in Arrow IPC reader
4 participants