-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Remove useless optional unwrap from Unsafe[Raw]BufferPointer subscript. #22338
Conversation
|
@swift-ci test. |
|
@swift-ci benchmark. |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview |
|
Build failed |
It is unfortunate that `Unsafe[Raw]BufferPointer._pointer` and `baseAddress` are declared Optional. This leaves extra runtime checks in the code in the most performance critical paths. Contrast this with Array, which uses an sentinal pointer for the empty representation. This forces us to use _unsafelyUnwrappedUnchecked whenever we just want to dereference a non-empty buffer pointer. Fixes SR-9809: swiftc appears to make some sub-optimal optimization choices
|
@swift-ci smoke test. |
|
(For the record, they're optional so that they round-trip with C pointer/length pairs, which usually accept |
|
If you want to keep it as a |
|
@swift-ci please benchmark |
|
(I've seen issues where removing force unwraps slows down benchmarks due to unpredictability of the optimizer, so double checking here) |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview |
|
I have a number of patches that fix inlining and pass manager problems but haven't had time to look into the benchmark numbers for those either. So for now I'd say this is blocked on other fixes. |
|
E.g. #21132, which just removes branches, slowing down benchmarks. |
|
Merging this unambiguously good bug fix and recording the regressions here so we can fix the inliner... https://bugs.swift.org/browse/SR-9875 |
It is unfortunate that
Unsafe[Raw]BufferPointer._pointerandbaseAddressare declared Optional. This leaves extra runtime checksin the code in the most performance critical paths. Contrast this with
Array, which uses an sentinal pointer for the empty representation.
This forces us to use _unsafelyUnwrappedUnchecked whenever we just
want to dereference a non-empty buffer pointer.
Fixes SR-9809: swiftc appears to make some sub-optimal optimization choices