-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[benchmark] Add new benchmark for floating-point conversion #33801
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
@swift-ci Please benchmark |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -Onone
Code size: -swiftlibs
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
|
@swift-ci smoke test |
@swift-ci smoke test macOS platform |
Thanks for picking this up. Just as a matter of naming: I think it would also make sense for this same benchmark to eventually test generic conversions between integer types, so something like |
@troughton That's a good thought. For a thorough set of tests, though, we'll need to define mock types here, so I expect it'll be a very long file even just with floating-point types. I think I'd rather leave integer benchmarks to a separate file. |
@swift-ci smoke test linux platform |
This benchmark (or at least, parts of it) should not be built for armv7. https://ci.swift.org/job/swift-PR-osx/23595/consoleText
|
@xwu for optimizations where we expect the generated code to be trivial it is better to add a lit test than a micro benchmark. So, I looked at #33803 (nice work, BTW!) and found that the compiler still produces unnecessary code. |
@eeckstein That's fantastic; thanks for your follow-up PR in #33839! I have another optimization and refactoring in #33826 that I hope and expect will pass this new lit test as well. It emits code that's 3x faster, comparable to your results in #33839, despite not having the benefit of your changes in that PR. I expected the improvement to be possible given the disparity between concrete performance and generic performance after landing #33803--but now I'm curious as to how the improvement was possible without tweaking the compiler! This particular PR here was just a start to the benchmarks; I created mock wrapper types in #33821 to test further optimizations with custom floating-point types, which I did not expect would result in code that could be optimized to the point of being trivial. It's looking like all of it might optimize pretty well, though, so I do wonder as to the future of these benchmarks. |
@xwu Sounds good. Feel free to add more tests in floating_point_conversion.swift. I still recommend to remove the ConvertFloatingPoint.GenericDoubleToDouble/ConcreteDoubleToDouble benchmarks. They don't add much value, because the lit test already checks that the optimization is optimal. |
This PR adds a new benchmark for floating-point conversion.
Eventually, it will test more combinations, but for now, it looks to quantify the difference between concrete conversions from
Double
toDouble
and generic conversions fromDouble
toDouble
in anticipation of upcoming PRs.