-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[array] Remove unwrap checks from GenericByteArray::value_unchecked #7573
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
Conversation
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ctsk -- this also makes sense to me
I took the liberty of merging this PR up from main and running cargo fmt on it to get a clean CI run.
I also queued up some benchmark runs to see if we can see any improvements for this change
|
🤖 |
|
🤖: Benchmark completed Details
|
|
🤖 |
|
🤖: Benchmark completed Details
|
|
I don't see much one way or the other in the benchmarks but I would say this is a reasonable change regardless |
|
Thank you for driving this forward!
I don't know the details of the filter benchmarks, but this does seem like a significant difference doesn't it? |
Yes you are right! I am sorry I missed that. However, I double checked and the |
|
I see other runs of the benchmarks have the same pattern (with the same numbers for the fsb benchmark). Somehow the second run is always takes 66% longer... #7463. |
Yeah, it is really weird. It would be great if someone could look into that. I'll file a ticket |
|
Which issue does this PR close?
GenericByteArray::value_uncheckedpermitsunsafecode, but still introduces a check due tounwrapbeing called here:I believe it is sensible to use
unwrap_unsafehere instead. While the compiler may be able to prune the first unwrap as unreachable, I believe it can not prove at compile time thatend >= startand eliminate the second unwrap. This is an invariant of GenericByteArray.Are there any user-facing changes?
No.