Skip to content

Allow for reading raw bytes from rustc_serialize::Decoder without unsafe code #83465

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

Merged
merged 1 commit into from
Mar 26, 2021

Conversation

michaelwoerister
Copy link
Member

The current read_raw_bytes method requires using MaybeUninit and unsafe. I don't think this is necessary. Let's see if a safe interface has any performance drawbacks.

This is a followup to #83273 and will make it easier to rebase #82183.

r? @cjgillot

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 25, 2021
@michaelwoerister
Copy link
Member Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 25, 2021
@bors
Copy link
Collaborator

bors commented Mar 25, 2021

⌛ Trying commit 517d5ac with merge 8454a31114a0ff65016cc30a4c74570cdabc03b2...

@bors
Copy link
Collaborator

bors commented Mar 25, 2021

☀️ Try build successful - checks-actions
Build commit: 8454a31114a0ff65016cc30a4c74570cdabc03b2 (8454a31114a0ff65016cc30a4c74570cdabc03b2)

@rust-timer
Copy link
Collaborator

Queued 8454a31114a0ff65016cc30a4c74570cdabc03b2 with parent 372afcf, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (8454a31114a0ff65016cc30a4c74570cdabc03b2): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 25, 2021
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 25, 2021

📌 Commit 517d5ac has been approved by cjgillot

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 25, 2021
@michaelwoerister
Copy link
Member Author

There seems to be a slight regression in terms of instruction counts. Interestingly, using &mut [u8] instead of &mut [MaybeUninit<u8>] does not seem to be the cause of that. Instead it is the copy_from_slice() call instead ot the copy_non_overlapping() that introduces an additional check (making sure that the start index is less than or equal to the end index).

I've tested a few different versions at https://play.rust-lang.org/?version=nightly&mode=release&edition=2018&gist=4933fb0cfc1884086c846c98260bd4c7. The assembly code of all versions that avoid that additional check look the same (or almost the same) and should perform the same. I'm not sure yet if we really should skip that additional check. In theory the self.position += s.len() addition could overflow, causing undefined behavior.

@cjgillot
Copy link
Contributor

The regression in instruction count is within noise, with no actual effect on wall-time. max-rss is green-ish.
I am not really concerned by this additional check, as it could fire in the unlikely case of overflow.

@bors
Copy link
Collaborator

bors commented Mar 26, 2021

⌛ Testing commit 517d5ac with merge 0ced530...

@bors
Copy link
Collaborator

bors commented Mar 26, 2021

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 0ced530 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 26, 2021
@bors bors merged commit 0ced530 into rust-lang:master Mar 26, 2021
@rustbot rustbot added this to the 1.53.0 milestone Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants