-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Simplify {Float,Double,Float80}.init(_: String) #28992
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
The original version scanned the entire input string for whitespace and non-ASCII characters. Both are unnecessary: the C routines we're building on already stop at non-ASCII characters or non-leading whitespace. So we need only check the first character for whitespace and verify that all characters are consumed. This demonstrates significant improvements for -Onone benchmarks: about 4k smaller RSS and 3x speedups. I'm not seeing any local changes to the -O benchmarks, however. We could further improve this by pushing these checks down into the runtime stubs and simplifying the ABI so it just returned a success/failure boolean. In particular, that could avoid inlining these checks into every client. But an ABI migration is more work than I have time for right now.
@swift-ci Please smoke test Linux |
@swift-ci Please smoke test macOS |
@swift-ci please benchmark |
Performance: -O
Code size: -O
Performance: -Osize
Code size: -Osize
Performance: -Onone
Code size: -swiftlibsHow 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
|
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.
Room to make this cleaner still, but good enough start to take now.
The original version scanned the entire input string for whitespace and
non-ASCII characters. Both are unnecessary: the C routines we're building on
already stop at non-ASCII characters or non-leading whitespace. So we need only
check the first character for whitespace and verify that all characters are
consumed.
This demonstrates significant improvements for -Onone benchmarks:
about 4k smaller RSS and 3x speedups. I'm not seeing any local
changes to the -O benchmarks, however.
Resolves rdar://33045403
Future: We could further improve this by pushing these checks down into the runtime
stubs and simplifying the ABI so those stubs just returne a success/failure boolean.
In particular, that would avoid inlining these checks into every client.