-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Adds KeyPath test to benchmark suite #36451
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 smoke test |
@swift-ci 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
|
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.
The key path accesses are all optimized away. You can use identity
to prevent that, e.g.
let kp0 = identity(FixedSizeArray10<Double>.getKeypathToElement(index: 0))
Also, it would be nice to benchmark other key path operations, like: subscripts, getters, setters.
Adds identity function to avoid keypath being optimized away
@swift-ci benchmark |
1 similar comment
@swift-ci benchmark |
Build failed before running benchmark. |
@eeckstein Overall I'd like this benchmark to highlight the performance difference between the KeyPath and Direct Access implementations in working with struct properties. Any further suggestions? |
The difference between both benchmarks is not reported in a benchmark run, e.g. on CI. So the only way to see the difference is to compile the benchmarks locally and manually compare both results. You can keep |
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.
lgtm, thanks!
@swift-ci benchmark |
@swift-ci smoke test |
@swift-ci 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
|
@taylorGeisler I just saw that you moved the keypath variables out of the function and made them global. That is not good, because accesses to (non-trivial) globals is slow. |
My coworker (from the same company that originated this PR) has been working on a more extensive set of keypath benchmarks in #60383, so I believe it is safe to close out this PR in favor of that newer one. |
This pull request adds a test of KeyPaths performance to the benchmark suite. It creates a fixed size array struct and KeyPaths to its properties. It does work inside of a loop by accessing the properties with KeyPaths.