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
Add SortArrayInClass benchmark. #26663
Conversation
@swift-ci test |
@swift-ci benchmark |
@swift-ci test. |
@swift-ci benchmark |
Build failed |
Build failed |
Performance: -O
Code size: -O
Performance: -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.
Thanks for the help in getting this added.
Isn't this correct behavior, since there could be a subclass that overrides |
This currently copies the array each time it swaps elements. This makes it 1500x slower than it should be to sort the array. The benchmark now runs in 15ms but should be around 10us when fully optimized. This algorithm is an interesting optimization problem involving array optimization, uniqueness, bounds checks, and exclusivity. But the general first order problem is how to modify a CoW data structure that's stored in a class property. As it stands, the property getter retains the class property around the modify accesses that checks uniqueness.
@swift-ci smoke test. |
@swift-ci benchmark |
@jrose-apple It's true that if the class were From any normal programmers's point of view this code:
Should be equivalent to:
The fact that we force an array copy here seems like an unintended artifact of SILGen to me rather than fundamental lanuage semantics. For some reason the scope of the assignment's RHS extends beyond the modification rather than ending after the RHS is fully evaluated. @rjmccall will remember why and know if there's a good reason we can't fix it. |
Oh, yeah, sure, the problem is a real problem. My question was whether the benchmark made any sense, and you're right, it does. |
Performance: -O
Code size: -O
Performance: -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
|
Add SortArrayInClass benchmark.