-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[benchmark] Fix: Set.*.Box use identity everywhere #24570
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
Consistently apply the `identity` in `Box` variants of benchmarks for `subtracting` and `intersection` to guard against future sufficiently smart compiler that could hoist the constant expression out of the loop. (This pattern is used in all other variants.)
@swift-ci please benchmark |
This issue was discovered during tuning of benchmark workloads in #24156. |
Performance: -O
Performance: -Osize
Performance: -Onone
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
|
OK, this matches my local results, because the negligible performance changes in The I'm pretty sure there will be legitimate performance changes in |
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.
This fix increases the runtime and because I've triggered the CI benchmark in #21300 to be sure, but without fixing this, the runtime dips too low in these two cases ( |
Erm, I misspoke, those two cases regress according to benchmark report (0.15x & 0.60x), but these are marginal cases with 1000x workload multipliers — so this means subtracting the empty set takes 158 ns and 15 ns depending on which side is empty. |
With this fix, these will be even a bit higher (by ratio 0.30x and 0.51x), because the loop will have to deal with |
@swift-ci please smoke test |
@eeckstein @lorentey Assuming #21300 is ready to be merged, I propose we coordinate the landing of these 3 PRs in following order:
Edit: Karoy informed me that branch is not yet ready to merge, so I'll let this PR wait until it will be... |
Consistently apply the
identity
inBox
variants of benchmarks forsubtracting
andintersection
to guard against future sufficiently smart compiler that could hoist the constant expression out of the loop. This pattern is used in all other variants and was explained by @lorentey in #18928 (comment).