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

Add a specialization of read_exact for Cursor. #46485

Merged
merged 1 commit into from Dec 4, 2017

Conversation

Projects
None yet
4 participants
@khuey
Contributor

khuey commented Dec 4, 2017

The read_exact implementation for &[u8] is optimized and usually allows LLVM to reduce a read_exact call for small numbers of bytes to a bounds check and a register load instead of a generic memcpy. On a workload I have that decompresses, deserializes (via bincode), and processes some data, this leads to a 40% speedup by essentially eliminating the deserialization overhead entirely.

Add a specialization of read_exact for Cursor.
The read_exact implementation for &[u8] is optimized and usually allows LLVM to reduce a read_exact call for small numbers of bytes to a bounds check and a register load instead of a generic memcpy.  On a workload I have that decompresses, deserializes (via bincode), and processes some data, this leads to a 40% speedup by essentially eliminating the deserialization overhead entirely.
@khuey

This comment has been minimized.

Show comment
Hide comment
@khuey

khuey Dec 4, 2017

Contributor
Contributor

khuey commented Dec 4, 2017

@Manishearth

This comment has been minimized.

Show comment
Hide comment
@Manishearth

Manishearth Dec 4, 2017

Member

@bors r+

Seems innocuous; shouldn't change any behavior.

Member

Manishearth commented Dec 4, 2017

@bors r+

Seems innocuous; shouldn't change any behavior.

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 4, 2017

Contributor

📌 Commit 02c1862 has been approved by Manishearth

Contributor

bors commented Dec 4, 2017

📌 Commit 02c1862 has been approved by Manishearth

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 4, 2017

Contributor

⌛️ Testing commit 02c1862 with merge c16f480...

Contributor

bors commented Dec 4, 2017

⌛️ Testing commit 02c1862 with merge c16f480...

bors added a commit that referenced this pull request Dec 4, 2017

Auto merge of #46485 - khuey:cursor-read_exact, r=Manishearth
Add a specialization of read_exact for Cursor.

The read_exact implementation for &[u8] is optimized and usually allows LLVM to reduce a read_exact call for small numbers of bytes to a bounds check and a register load instead of a generic memcpy.  On a workload I have that decompresses, deserializes (via bincode), and processes some data, this leads to a 40% speedup by essentially eliminating the deserialization overhead entirely.
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Dec 4, 2017

Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: Manishearth
Pushing c16f480 to master...

Contributor

bors commented Dec 4, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: Manishearth
Pushing c16f480 to master...

@bors bors merged commit 02c1862 into rust-lang:master Dec 4, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@khuey khuey deleted the khuey:cursor-read_exact branch Dec 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment