Skip to content

[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

Merged
merged 1 commit into from
Sep 15, 2021

Conversation

LucianoPAlmeida
Copy link
Contributor

Just a small improvement in Set.isDisjoint by iterating on smaller set.

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please smoke benchmark

@swift-ci
Copy link
Contributor

Performance (x86_64): -O

Regression OLD NEW DELTA RATIO
DictionaryOfAnyHashableStrings_insert 3402 5614 +65.0% 0.61x (?)
Set.isDisjoint.Int25 268 360 +34.3% 0.74x (?)
Set.isDisjoint.Int100 262 348 +32.8% 0.75x
Set.isDisjoint.Int50 268 351 +31.0% 0.76x (?)
Set.isDisjoint.Box25 355 448 +26.2% 0.79x (?)
StringFromLongWholeSubstring 4 5 +25.0% 0.80x
UTF8Decode_InitDecoding_ascii 240 283 +17.9% 0.85x (?)
UTF8Decode_InitFromCustom_contiguous_ascii 243 283 +16.5% 0.86x (?)
DictionaryRemove 3180 3510 +10.4% 0.91x (?)
CStringLongAscii 222 242 +9.0% 0.92x (?)
NSStringConversion.MutableCopy.Rebridge.Medium 618 668 +8.1% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Box.Empty 158 90 -43.0% 1.76x
Set.isDisjoint.Int.Empty 142 81 -43.0% 1.75x
FlattenListFlatMap 6655 4327 -35.0% 1.54x (?)
RemoveWhereFilterString 327 296 -9.5% 1.10x
EqualSubstringSubstring 43 39 -9.3% 1.10x (?)
ArrayInClass 2025 1855 -8.4% 1.09x (?)
DistinctClassFieldAccesses 417 382 -8.4% 1.09x
DictionaryOfAnyHashableStrings_lookup 4512 4152 -8.0% 1.09x (?)
Array2D 7808 7216 -7.6% 1.08x (?)
LessSubstringSubstring 42 39 -7.1% 1.08x (?)
EqualStringSubstring 42 39 -7.1% 1.08x (?)
EqualSubstringSubstringGenericEquatable 42 39 -7.1% 1.08x (?)
EqualSubstringString 42 39 -7.1% 1.08x
LessSubstringSubstringGenericComparable 42 39 -7.1% 1.08x (?)

Code size: -O

Performance (x86_64): -Osize

Regression OLD NEW DELTA RATIO
Set.isDisjoint.Int100 268 345 +28.7% 0.78x
StringFromLongWholeSubstring 4 5 +25.0% 0.80x
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Int.Empty 144 81 -43.7% 1.78x
Set.isDisjoint.Box.Empty 155 90 -41.9% 1.72x
Set.isDisjoint.Box25 509 451 -11.4% 1.13x (?)
LessSubstringSubstring 43 39 -9.3% 1.10x (?)
DictionaryOfAnyHashableStrings_lookup 4536 4128 -9.0% 1.10x (?)
DistinctClassFieldAccesses 402 368 -8.5% 1.09x
ArrayInClass 2005 1840 -8.2% 1.09x (?)
RandomShuffleLCG2 448 416 -7.1% 1.08x (?)
EqualSubstringSubstring 42 39 -7.1% 1.08x (?)
EqualStringSubstring 42 39 -7.1% 1.08x (?)
EqualSubstringString 42 39 -7.1% 1.08x (?)
LessSubstringSubstringGenericComparable 42 39 -7.1% 1.08x (?)
Array2D 7520 6992 -7.0% 1.08x (?)
EqualSubstringSubstringGenericEquatable 43 40 -7.0% 1.07x (?)

Code size: -Osize

Performance (x86_64): -Onone

Regression OLD NEW DELTA RATIO
StringBuilderWithLongSubstring 3830 4440 +15.9% 0.86x (?)
Data.append.Sequence.809B.Count.RE 36919 42389 +14.8% 0.87x (?)
DataAppendSequence 3672800 4216300 +14.8% 0.87x (?)
Data.init.Sequence.809B.Count.RE 36932 42328 +14.6% 0.87x (?)
Data.init.Sequence.64kB.Count.RE.I 29795 34067 +14.3% 0.87x (?)
Data.append.Sequence.809B.Count.RE.I 36906 42167 +14.3% 0.88x (?)
Data.init.Sequence.809B.Count.RE.I 36981 42116 +13.9% 0.88x (?)
Data.append.Sequence.64kB.Count.RE.I 29688 33798 +13.8% 0.88x (?)
Data.append.Sequence.64kB.Count.RE 29745 33836 +13.8% 0.88x (?)
ArrayAppendRepeatCol 365960 415540 +13.5% 0.88x (?)
Data.init.Sequence.64kB.Count.RE 29794 33748 +13.3% 0.88x (?)
Breadcrumbs.MutatedIdxToUTF16.ASCII 11 12 +9.1% 0.92x (?)
Set.isDisjoint.Seq.Empty.Int 415 449 +8.2% 0.92x (?)
ErrorHandling 3880 4190 +8.0% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Box25 2452 1239 -49.5% 1.98x
Set.isDisjoint.Int.Empty 734 392 -46.6% 1.87x
Set.isDisjoint.Box.Empty 778 426 -45.2% 1.83x
Set.isDisjoint.Int25 1121 699 -37.6% 1.60x
Set.isDisjoint.Int50 1079 699 -35.2% 1.54x
Set.isDisjoint.Empty.Int 576 381 -33.9% 1.51x
Set.isDisjoint.Empty.Box 615 428 -30.4% 1.44x
Set.isDisjoint.Int100 895 699 -21.9% 1.28x
Set.isDisjoint.Int0 817 737 -9.8% 1.11x (?)
DictionaryOfAnyHashableStrings_lookup 5376 4872 -9.4% 1.10x (?)
NSError 666 616 -7.5% 1.08x (?)
String.replaceSubrange.String 27 25 -7.4% 1.08x (?)
Dictionary2 1670 1555 -6.9% 1.07x (?)

Code size: -swiftlibs

How to read the data The 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
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Performance (x86_64): -O

Regression OLD NEW DELTA RATIO
DictionaryOfAnyHashableStrings_insert 2142 3738 +74.5% 0.57x
Set.isDisjoint.Int50 199 278 +39.7% 0.72x (?)
Set.isDisjoint.Int25 201 278 +38.3% 0.72x (?)
Set.isDisjoint.Int100 199 274 +37.7% 0.73x
UTF8Decode_InitDecoding 125 157 +25.6% 0.80x
Set.isDisjoint.Box25 284 356 +25.4% 0.80x (?)
UTF8Decode_InitFromCustom_contiguous 124 155 +25.0% 0.80x
UTF8Decode_InitFromCustom_noncontiguous 318 352 +10.7% 0.90x
SequenceAlgosUnfoldSequence 790 850 +7.6% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Box.Empty 96 51 -46.9% 1.88x
Set.isDisjoint.Int.Empty 86 46 -46.5% 1.87x
FlattenListFlatMap 3962 2389 -39.7% 1.66x (?)
EqualSubstringSubstring 30 22 -26.7% 1.36x
LessSubstringSubstring 29 22 -24.1% 1.32x
EqualStringSubstring 29 22 -24.1% 1.32x
EqualSubstringSubstringGenericEquatable 29 22 -24.1% 1.32x
EqualSubstringString 29 22 -24.1% 1.32x
LessSubstringSubstringGenericComparable 29 22 -24.1% 1.32x
ArrayLiteral2 78 70 -10.3% 1.11x
StringComparison_longSharedPrefix 357 321 -10.1% 1.11x (?)
Set.isSubset.Seq.Empty.Int 83 76 -8.4% 1.09x (?)
SortStringsUnicode 2180 2000 -8.3% 1.09x (?)
Set.isSubset.Int.Empty 49 45 -8.2% 1.09x (?)

Code size: -O

Performance (x86_64): -Osize

Regression OLD NEW DELTA RATIO
Set.isDisjoint.Int100 207 280 +35.3% 0.74x
UTF8Decode_InitDecoding 123 159 +29.3% 0.77x
UTF8Decode_InitFromCustom_contiguous 125 156 +24.8% 0.80x
Set.isDisjoint.Int50 243 280 +15.2% 0.87x
Set.isDisjoint.Int25 245 280 +14.3% 0.88x
UTF8Decode_InitFromCustom_noncontiguous 246 275 +11.8% 0.89x
SortSortedStrings 45 49 +8.9% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Int.Empty 91 51 -44.0% 1.78x
Set.isDisjoint.Box.Empty 96 55 -42.7% 1.75x
EqualSubstringSubstring 30 22 -26.7% 1.36x
LessSubstringSubstringGenericComparable 30 22 -26.7% 1.36x
LessSubstringSubstring 29 22 -24.1% 1.32x
EqualStringSubstring 29 22 -24.1% 1.32x (?)
EqualSubstringSubstringGenericEquatable 29 22 -24.1% 1.32x
EqualSubstringString 29 22 -24.1% 1.32x (?)
StringComparison_longSharedPrefix 357 321 -10.1% 1.11x (?)
Set.isDisjoint.Box25 395 361 -8.6% 1.09x (?)
SortStringsUnicode 2215 2025 -8.6% 1.09x (?)
Set.isDisjoint.Empty.Int 87 81 -6.9% 1.07x (?)

Code size: -Osize

Performance (x86_64): -Onone

Regression OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 132 165 +25.0% 0.80x (?)
UTF8Decode_InitFromCustom_contiguous 134 167 +24.6% 0.80x
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Int.Empty 459 228 -50.3% 2.01x
Set.isDisjoint.Box.Empty 481 241 -49.9% 2.00x
Set.isDisjoint.Box25 1687 868 -48.5% 1.94x
Set.isDisjoint.Int25 731 473 -35.3% 1.55x
Set.isDisjoint.Empty.Int 359 238 -33.7% 1.51x
Set.isDisjoint.Int50 707 473 -33.1% 1.49x
Set.isDisjoint.Empty.Box 375 252 -32.8% 1.49x
Set.isDisjoint.Int100 594 473 -20.4% 1.26x
EqualSubstringSubstring 59 51 -13.6% 1.16x (?)
EqualSubstringSubstringGenericEquatable 57 50 -12.3% 1.14x (?)
LessSubstringSubstring 58 51 -12.1% 1.14x (?)
EqualSubstringString 58 51 -12.1% 1.14x (?)
LessSubstringSubstringGenericComparable 56 50 -10.7% 1.12x (?)
EqualStringSubstring 57 51 -10.5% 1.12x (?)
Set.isDisjoint.Int0 564 524 -7.1% 1.08x (?)

Code size: -swiftlibs

How to read the data The 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
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac mini
  Model Identifier: Macmini8,1
  Processor Name: 6-Core Intel Core i7
  Processor Speed: 3.2 GHz
  Number of Processors: 1
  Total Number of Cores: 6
  L2 Cache (per Core): 256 KB
  L3 Cache: 12 MB
  Memory: 64 GB

Copy link
Member

@lorentey lorentey left a 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).

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Performance (x86_64): -O

Regression OLD NEW DELTA RATIO
DictionaryOfAnyHashableStrings_insert 2100 3752 +78.7% 0.56x
Set.isDisjoint.Int50 197 277 +40.6% 0.71x (?)
Set.isDisjoint.Int100 197 277 +40.6% 0.71x
Set.isDisjoint.Int25 201 274 +36.3% 0.73x (?)
Set.isDisjoint.Box25 285 359 +26.0% 0.79x (?)
StringRemoveDupes 180 199 +10.6% 0.90x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Box.Empty 96 54 -43.7% 1.78x
Set.isDisjoint.Int.Empty 84 49 -41.7% 1.71x
FlattenListFlatMap 3204 2684 -16.2% 1.19x (?)

Code size: -O

Performance (x86_64): -Osize

Regression OLD NEW DELTA RATIO
Set.isDisjoint.Int100 208 280 +34.6% 0.74x
FlattenListFlatMap 3328 3893 +17.0% 0.85x (?)
Set.isDisjoint.Int50 243 279 +14.8% 0.87x
Set.isDisjoint.Int25 245 280 +14.3% 0.88x
FlattenListLoop 1387 1567 +13.0% 0.89x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Int.Empty 91 51 -44.0% 1.78x
Set.isDisjoint.Box.Empty 97 56 -42.3% 1.73x
Set.isDisjoint.Box25 400 361 -9.7% 1.11x
Data.hash.Empty 52 47 -9.6% 1.11x (?)

Code size: -Osize

Performance (x86_64): -Onone

Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Int.Empty 459 233 -49.2% 1.97x
Set.isDisjoint.Box25 1689 864 -48.8% 1.95x
Set.isDisjoint.Box.Empty 481 251 -47.8% 1.92x
Set.isDisjoint.Int25 732 476 -35.0% 1.54x
Set.isDisjoint.Empty.Int 360 241 -33.1% 1.49x
Set.isDisjoint.Empty.Box 378 254 -32.8% 1.49x
Set.isDisjoint.Int50 707 476 -32.7% 1.49x
Set.isDisjoint.Int100 594 476 -19.9% 1.25x
Set.isDisjoint.Int0 563 524 -6.9% 1.07x (?)

Code size: -swiftlibs

How to read the data The 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
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac mini
  Model Identifier: Macmini8,1
  Processor Name: 6-Core Intel Core i7
  Processor Speed: 3.2 GHz
  Number of Processors: 1
  Total Number of Cores: 6
  L2 Cache (per Core): 256 KB
  L3 Cache: 12 MB
  Memory: 64 GB

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Performance (x86_64): -O

Regression OLD NEW DELTA RATIO
DictionaryOfAnyHashableStrings_insert 2898 5012 +72.9% 0.58x
Set.isDisjoint.Int25 241 315 +30.7% 0.77x (?)
Set.isDisjoint.Int100 237 305 +28.7% 0.78x
Set.isDisjoint.Box25 325 401 +23.4% 0.81x (?)
FlattenListLoop 1454 1790 +23.1% 0.81x (?)
DictionaryKeysContainsNative 19 23 +21.1% 0.83x (?)
String.data.Medium 91 109 +19.8% 0.83x (?)
String.data.Small 37 42 +13.5% 0.88x (?)
String.data.LargeUnicode 93 102 +9.7% 0.91x (?)
DropLastAnyCollectionLazy 25071 27068 +8.0% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Smaller.Box0 758 284 -62.5% 2.67x
Set.isDisjoint.Smaller.Int0 362 149 -58.8% 2.43x
Set.isDisjoint.Box.Empty 147 80 -45.6% 1.84x
Set.isDisjoint.Int.Empty 126 74 -41.3% 1.70x
DictionaryOfAnyHashableStrings_lookup 4032 3720 -7.7% 1.08x (?)

Code size: -O

Performance (x86_64): -Osize

Regression OLD NEW DELTA RATIO
Set.isDisjoint.Int100 236 306 +29.7% 0.77x
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Smaller.Box0 744 298 -59.9% 2.50x
Set.isDisjoint.Smaller.Int0 369 149 -59.6% 2.48x
Set.isDisjoint.Box.Empty 152 82 -46.1% 1.85x
Set.isDisjoint.Int.Empty 129 71 -45.0% 1.82x
Set.isDisjoint.Box25 458 414 -9.6% 1.11x (?)
DictionaryOfAnyHashableStrings_lookup 4056 3720 -8.3% 1.09x (?)

Code size: -Osize

Performance (x86_64): -Onone

Regression OLD NEW DELTA RATIO
ArrayAppendRepeatCol 324090 373940 +15.4% 0.87x (?)
Data.append.Sequence.809B.Count.RE 32971 37621 +14.1% 0.88x (?)
Data.append.Sequence.64kB.Count.RE 26531 30263 +14.1% 0.88x (?)
Data.init.Sequence.64kB.Count.RE.I 26659 30359 +13.9% 0.88x (?)
Data.append.Sequence.64kB.Count.RE.I 26647 30298 +13.7% 0.88x (?)
Data.append.Sequence.809B.Count.RE.I 33310 37682 +13.1% 0.88x (?)
DataAppendSequence 3330200 3766800 +13.1% 0.88x (?)
Data.init.Sequence.809B.Count.RE 33143 37390 +12.8% 0.89x (?)
Data.init.Sequence.64kB.Count.RE 26753 30122 +12.6% 0.89x (?)
Data.init.Sequence.809B.Count.RE.I 33172 37266 +12.3% 0.89x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isDisjoint.Smaller.Int0 936 322 -65.6% 2.91x
Set.isDisjoint.Smaller.Box0 3059 1305 -57.3% 2.34x
Set.isDisjoint.Box25 2228 1111 -50.1% 2.01x
Set.isDisjoint.Int.Empty 661 347 -47.5% 1.90x
Set.isDisjoint.Box.Empty 692 376 -45.7% 1.84x
Set.isDisjoint.Int25 1009 618 -38.8% 1.63x
Set.isDisjoint.Int50 973 618 -36.5% 1.57x
Set.isDisjoint.Empty.Int 528 356 -32.6% 1.48x
Set.isDisjoint.Empty.Box 548 377 -31.2% 1.45x
Set.isDisjoint.Int100 809 618 -23.6% 1.31x
Set.isDisjoint.Int0 732 652 -10.9% 1.12x (?)
SIMDReduce.Int8x16.Initializer 609589 555485 -8.9% 1.10x (?)
Dictionary2 1495 1380 -7.7% 1.08x (?)
String.data.Empty 73 68 -6.8% 1.07x (?)

Code size: -swiftlibs

How to read the data The 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
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 8-Core Intel Xeon E5
  Processor Speed: 3 GHz
  Number of Processors: 1
  Total Number of Cores: 8
  L2 Cache (per Core): 256 KB
  L3 Cache: 25 MB
  Memory: 64 GB

@LucianoPAlmeida
Copy link
Contributor Author

Improvement | OLD | NEW | DELTA | RATIO
Set.isDisjoint.Smaller.Box0 | 758 | 284 | -62.5% | 2.67x
Set.isDisjoint.Smaller.Int0 | 362 | 149 | -58.8% | 2.43x
Set.isDisjoint.Box.Empty | 147 | 80 | -45.6% | 1.84x
Set.isDisjoint.Int.Empty | 126 | 74 | -41.3% | 1.70x
DictionaryOfAnyHashableStrings_lookup | 4032 | 3720 | -7.7% | 1.08x (?)

Now the new benchmarks can show the improvements =]

Copy link
Member

@lorentey lorentey left a 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...)

@lorentey
Copy link
Member

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 00cb1c5

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please test Linux Platform

@LucianoPAlmeida
Copy link
Contributor Author

@swift-ci Please test Windows Platform

@LucianoPAlmeida
Copy link
Contributor Author

LucianoPAlmeida commented Sep 15, 2021

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 _isDisjoint function, which is fine but the problem would be if the optimizer decides to inline them, then this would increase code size. I experimented with that by making _isDisjoint a @inline(__always) to see if the optimizer would make it (link here) and we can see indeed how the _isDisjoint call is inlined on the two branches.

So I think it would be fine to just go with this version :)

@LucianoPAlmeida LucianoPAlmeida merged commit 50a1817 into swiftlang:main Sep 15, 2021
@LucianoPAlmeida LucianoPAlmeida deleted the set-improvements branch September 15, 2021 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants