-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Optimize sequence algorithms to eliminate bounds-checking #40716
base: main
Are you sure you want to change the base?
Conversation
Using less-than and greater-than operators instead of checking equivalency allows the compiler to eliminate bounds-checking more thoroughly.
|
@swift-ci please benchmark |
Performance (x86_64): -O
Code size: -OPerformance (x86_64): -Osize
Code size: -OsizePerformance (x86_64): -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 |
|
Could someone give me some guidance on running the benchmark correctly on my own machine? I want to use For that matter, I notice that all but one of the changes (an improvement) are flagged with (?). Does that mean they should be ignored, and that the changes so far have no meaningful regression in practice? |
|
I've added @atrick as a reviewer who should be able to shed some light on this. There's also this document which I am not sure if you've seen yet (if so, please ignore!) https://github.com/apple/swift/tree/main/benchmark |
I read it from start to finish repeatedly before bothering anyone, in the hopes of figuring this out myself. It was very helpful in most regards, but it doesn’t explain what I’m seeing here. I even glanced at the Python scripts to see if there were any obvious causes, but nothing immediately jumps out and at that point it’s preferable for the solution to be discussed publicly so people can find it going forward. |
|
I don't think there is a real regression in these results. The Unfortunately the document is a bit outdated. The easiest way to compile+run the benchmarks locally is to use cmake (as described in the document) and copy the built swift libraries to the benchmark build dir, e.g: Compile two versions of the benchmarks: a baseline and the thing what you want to test. Then use https://github.com/apple/swift/blob/main/benchmark/scripts/run_smoke_bench to run the benchmarks, e.g. |
This pull request tweaks several algorithms in the standard library to improve performance optimization, mainly through eliminating extraneous bounds checks by replacing not-equal operators with less-than operators.
These improvements were brought to my attention by @karwa while discussing the performance roadmap, and have already been implemented in a limited form for WebURL.
However, I am having trouble running local benchmarks to confirm performance improvements. I asked for assistance on the Swift Forums over a week ago, but have yet to get a reply. I’m opening this pull request as a draft in the hopes that someone may help me with that.