-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Improve set isDisjoint by iterating on smaller set #39263
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
[stdlib] Improve set isDisjoint by iterating on smaller set #39263
Conversation
@swift-ci Please smoke 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
|
@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
|
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 is good change, thank you! We should keep the sequence-based code paths intact (see note).
3a75f4d
to
a65fd67
Compare
@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
|
a65fd67
to
9a7bb1a
Compare
9a7bb1a
to
00cb1c5
Compare
@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
|
Now the new benchmarks can show the improvements =] |
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.
Good work!
(I know this has been a long process; but if you have a bit of extra time, it might be worth taking a very quick look at the code generated for, say, Set<Int>.isDisjoint(with:)
-- just enough to make sure it looks sensible. Sometimes there can be unpleasant surprises. 🙈
FWIW, it feels like this version of isDisjoint
expects less of the compiler than the version in #21300, but you never know...)
@swift-ci test |
Build failed |
@swift-ci Please test Linux Platform |
@swift-ci Please test Windows Platform |
Yeah, by looking into this compiler explorer(link here) is interesting to see that the version in the previous # previous
output.f1(s1: Swift.Set<Swift.Int>, s2: Swift.Set<Swift.Int>) -> Swift.Bool:
mov rax, rdi
mov rcx, qword ptr [rdi + 16]
cmp rcx, qword ptr [rsi + 16]
jae .LBB6_2
mov rdi, rax
jmp (generic specialization <Swift.Int, Swift.Set<Swift.Int>> of (extension in output):Swift.Set._isDisjoint1<A where A == A1.Element, A1: Swift.Sequence>(with: A1) -> Swift.Bool)
.LBB6_2:
mov rdi, rsi
mov rsi, rax
jmp (generic specialization <Swift.Int, Swift.Set<Swift.Int>> of (extension in output):Swift.Set._isDisjoint1<A where A == A1.Element, A1: Swift.Sequence>(with: A1) -> Swift.Bool)
# this
output.f2(s1: Swift.Set<Swift.Int>, s2: Swift.Set<Swift.Int>) -> Swift.Bool:
mov rax, rdi
mov rdi, rsi
mov rsi, rax
jmp (generic specialization <Swift.Int> of (extension in output):Swift.Set.isDisjoint2(with: Swift.Set<A>) -> Swift.Bool)
the difference is basically that for the previous version two branches calling the So I think it would be fine to just go with this version :) |
Just a small improvement in
Set.isDisjoint
by iterating on smaller set.