Skip to content
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

[DNM] Disable jump threading through a potential loop header #76305

Closed

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Sep 6, 2024

PR to test performance impact of disabling jump threading through a loop header to avoid irreducible loops.

@meg-gupta
Copy link
Contributor Author

@swift-ci apple silicon benchmark

@meg-gupta
Copy link
Contributor Author

------- Performance (arm64): -O -------

REGRESSION                                                 OLD        NEW         DELTA        RATIO    
ExclusivityGlobal                                          0.0        5.706       +570600.0%   **0.00x**
ArrayValueProp3                                            0.0        2.854       +285400.0%   **0.00x**
ArrayValueProp4                                            0.0        2.854       +285400.0%   **0.00x**
ArrayValueProp2                                            0.0        2.854       +285400.0%   **0.00x**
ArrayValueProp                                             0.0        2.853       +285300.0%   **0.00x**
UTF16Decode                                                89.731     384.833     +328.9%      **0.23x**
SubstringFromLongStringGeneric2                            17.124     47.087      +175.0%      **0.36x**
CreateObjects                                              8.557      19.972      +133.4%      **0.43x**
BitCount                                                   63.053     140.471     +122.8%      **0.45x**
SubstringFromLongString2                                   17.118     35.661      +108.3%      **0.48x**
DropFirstArray                                             17.963     35.188      +95.9%       **0.51x**
DropWhileSequence                                          17.759     30.104      +69.5%       **0.59x**
DropWhileAnySeqCntRange                                    17.759     29.493      +66.1%       **0.60x**
DropWhileAnySeqCRangeIter                                  17.759     29.492      +66.1%       **0.60x**
DropWhileAnySequence                                       18.429     30.409      +65.0%       **0.61x**
NaiveRRC.append.smallContiguousRepeated                    40.471     57.622      +42.4%       **0.70x**
ProtocolDispatch2                                          57.103     71.333      +24.9%       **0.80x**
PointerArithmetics                                         14268.75   17121.429   +20.0%       **0.83x**
MapReduceLazyCollectionShort                               19.969     22.826      +14.3%       **0.87x**
DictionaryBridgeToObjC_Bridge                              6.055      6.787       +12.1%       **0.89x (?)**
StringFromLongWholeSubstringGeneric                        3.138      3.423       +9.1%        **0.92x**
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards   549.615    594.783     +8.2%        **0.92x**

IMPROVEMENT                                                OLD        NEW         DELTA        RATIO    
StringWithCString2                                         0.002      0.001       -33.3%       **1.50x**
UTF8Decode_InitDecoding                                    132.625    96.136      -27.5%       **1.38x**
UTF8Decode_InitFromCustom_contiguous                       131.706    96.13       -27.0%       **1.37x**
UTF8Decode_InitFromData                                    132.941    98.217      -26.1%       **1.35x**
UTF8Decode_InitFromBytes                                   137.625    102.19      -25.7%       **1.35x**
UTF8Decode_InitFromCustom_noncontiguous                    149.733    114.053     -23.8%       **1.31x**
DataCountSmall                                             14.265     11.413      -20.0%       **1.25x**
EqualSubstringSubstring                                    20.25      17.36       -14.3%       **1.17x**
LessSubstringSubstring                                     20.198     17.343      -14.1%       **1.16x**
EqualSubstringSubstringGenericEquatable                    20.198     17.352      -14.1%       **1.16x**
RawBuffer.copyContents                                     11.167     9.64        -13.7%       **1.16x (?)**
ArrayAppendGenericStructs                                  1088.889   948.125     -12.9%       **1.15x (?)**
ParseInt.UInt64.Hex                                        157.909    138.5       -12.3%       **1.14x (?)**
LessSubstringSubstringGenericComparable                    20.208     17.808      -11.9%       **1.13x**
EqualSubstringString                                       20.521     18.13       -11.7%       **1.13x**
SuffixArray                                                7.484      6.635       -11.3%       **1.13x (?)**
SuffixArrayLazy                                            7.484      6.635       -11.3%       **1.13x (?)**
EqualStringSubstring                                       20.282     18.232      -10.1%       **1.11x**
UTF16Decode.initFromCustom.cont                            250.714    229.75      -8.4%        **1.09x**
UTF16Decode.initFromCustom.noncont                         259.25     238.111     -8.2%        **1.09x**
ObserverUnappliedMethod                                    270.625    250.196     -7.5%        **1.08x (?)**

------- Code size: -O -------

REGRESSION                                     OLD     NEW     DELTA    RATIO  
DropWhile.o                                    10071   11675   +15.9%   **0.86x**
Exclusivity.o                                  2870    3282    +14.4%   **0.87x**
TypeFlood.o                                    543     611     +12.5%   **0.89x**
RomanNumbers.o                                 3267    3667    +12.2%   **0.89x**
DropFirst.o                                    9053    10039   +10.9%   **0.90x**
BitCount.o                                     1178    1290    +9.5%    **0.91x**
CreateObjects.o                                761     809     +6.3%    **0.94x**
DiffingMyers.o                                 5065    5357    +5.8%    **0.95x**
ProtocolDispatch2.o                            1170    1222    +4.4%    **0.96x**
ArrayLiteral.o                                 1248    1300    +4.2%    **0.96x**
ChainedFilterMap.o                             2443    2539    +3.9%    **0.96x**
DictionaryLiteralTest.o                        969     1005    +3.7%    **0.96x**
SevenBoom.o                                    1152    1192    +3.5%    **0.97x**
StringInterpolation.o                          5458    5626    +3.1%    **0.97x**
PrefixWhile.o                                  9753    10053   +3.1%    **0.97x**
ProtocolDispatch.o                             560     576     +2.9%    **0.97x**
CharacterLiteralsSmall.o                       894     918     +2.7%    **0.97x**
SubstringTest.o                                15511   15918   +2.6%    **0.97x**
CaptureProp.o                                  779     799     +2.6%    **0.97x**
RangeIteration.o                               1104    1132    +2.5%    **0.98x**
StringRepeating.o                              2846    2918    +2.5%    **0.98x**
MonteCarloPi.o                                 1142    1170    +2.5%    **0.98x**
NSDictionaryCastToSwift.o                      1158    1186    +2.4%    **0.98x**
BinaryFloatingPointProperties.o                3829    3921    +2.4%    **0.98x**
FloatingPointPrinting.o                        3368    3448    +2.4%    **0.98x**
Prefix.o                                       9486    9706    +2.3%    **0.98x**
DropLast.o                                     15576   15908   +2.1%    **0.98x**
ReduceInto.o                                   8669    8849    +2.1%    **0.98x**
DictionaryCopy.o                               7641    7797    +2.0%    **0.98x**
DictionaryBridgeToObjC.o                       3910    3986    +1.9%    **0.98x**
DictionaryRemove.o                             16204   16504   +1.9%    **0.98x**
AnyHashableWithAClass.o                        2431    2475    +1.8%    **0.98x**
XorLoop.o                                      1150    1170    +1.7%    **0.98x**
MapReduce.o                                    18881   19201   +1.7%    **0.98x**
StringComparison.o                             28352   28820   +1.7%    **0.98x**
LazyFilter.o                                   5401    5489    +1.6%    **0.98x**
DeadArray.o                                    1238    1258    +1.6%    **0.98x**
DictTest2.o                                    8443    8579    +1.6%    **0.98x**
LinkedList.o                                   1766    1794    +1.6%    **0.98x**
CString.o                                      5309    5393    +1.6%    **0.98x**
NaiveRangeReplaceableCollectionConformance.o   7182    7294    +1.6%    **0.98x**
NSErrorTest.o                                  1083    1099    +1.5%    **0.99x**
FlattenList.o                                  2730    2770    +1.5%    **0.99x**
IterateData.o                                  1395    1415    +1.4%    **0.99x**
StrToInt.o                                     5322    5398    +1.4%    **0.99x**
Histogram.o                                    2329    2361    +1.4%    **0.99x**
DictionarySwap.o                               14479   14675   +1.4%    **0.99x**
Ackermann.o                                    1198    1214    +1.3%    **0.99x**
CharacterProperties.o                          16764   16984   +1.3%    **0.99x**
ReversedCollections.o                          6584    6668    +1.3%    **0.99x**
Combos.o                                       3772    3820    +1.3%    **0.99x**
StrComplexWalk.o                               2202    2230    +1.3%    **0.99x**
StringWalk.o                                   27524   27872   +1.3%    **0.99x**
StringBuilder.o                                5727    5799    +1.3%    **0.99x**
DictTest3.o                                    12583   12735   +1.2%    **0.99x**
DataBenchmarks.o                               48897   49469   +1.2%    **0.99x**
NSStringConversion.o                           11350   11478   +1.1%    **0.99x**
UTF16Decode.o                                  14658   14822   +1.1%    **0.99x**
ArrayInClass.o                                 2615    2643    +1.1%    **0.99x**
DictionarySubscriptDefault.o                   15132   15292   +1.1%    **0.99x**

IMPROVEMENT                                    OLD     NEW     DELTA    RATIO  
NopDeinit.o                                    3517    2877    -18.2%   **1.22x**
ClassArrayGetter.o                             3130    3018    -3.6%    **1.04x**
CharacterLiteralsLarge.o                       630     614     -2.5%    **1.03x**
PopFrontGeneric.o                              1973    1929    -2.2%    **1.02x**
RangeReplaceableCollectionPlusDefault.o        7119    6963    -2.2%    **1.02x**
ByteSwap.o                                     1106    1082    -2.2%    **1.02x**
PopFront.o                                     2616    2560    -2.1%    **1.02x**
Integrate.o                                    1677    1649    -1.7%    **1.02x**
Hanoi.o                                        2144    2116    -1.3%    **1.01x**
Suffix.o                                       15542   15366   -1.1%    **1.01x**
Fibonacci.o                                    1126    1114    -1.1%    **1.01x**

####### Testing optimization level -Osize #######
------- Performance (arm64): -Osize -------

REGRESSION                                OLD        NEW        DELTA        RATIO    
ArrayValueProp3                           0.0        2.854      +285400.0%   **0.00x**
ArrayValueProp                            0.0        2.854      +285400.0%   **0.00x**
ArrayValueProp4                           0.0        2.854      +285400.0%   **0.00x**
ArrayValueProp2                           0.0        2.853      +285300.0%   **0.00x**
SubstringFromLongStringGeneric2           17.124     49.93      +191.6%      **0.34x**
CreateObjects                             8.557      22.825     +166.7%      **0.37x**
DropWhileSequence                         17.759     41.846     +135.6%      **0.42x**
SubstringFromLongString2                  18.543     38.519     +107.7%      **0.48x**
ExclusivityGlobal                         2.853      5.706      +100.0%      **0.50x**
BitCount                                  128.667    191.167    +48.6%       **0.67x**
NaiveRRC.append.smallContiguousRepeated   40.49      56.205     +38.8%       **0.72x**
ArrayAppendSequence                       324.444    440.556    +35.8%       **0.74x (?)**
ProtocolDispatch2                         57.103     71.406     +25.0%       **0.80x**
StringFromLongWholeSubstringGeneric       3.282      3.994      +21.7%       **0.82x**
DataCountSmall                            14.268     17.124     +20.0%       **0.83x**
DataCountMedium                           14.268     17.118     +20.0%       **0.83x**
StringFromLongWholeSubstring              1.854      2.14       +15.4%       **0.87x**
ProtocolDispatch                          199.727    228.3      +14.3%       **0.87x**
SuffixSequenceLazy                        84.074     96.043     +14.2%       **0.88x**
SuffixSequence                            84.192     96.083     +14.1%       **0.88x**
DataAppendDataSmallToLarge                5080.0     5717.808   +12.6%       **0.89x (?)**
DictionaryBridgeToObjC_Bridge             5.949      6.644      +11.7%       **0.90x**
Array.removeAll.keepingCapacity.Object    2.35       2.609      +11.0%       **0.90x (?)**
StrComplexWalk                            1936.667   2123.636   +9.7%        **0.91x**
NSStringConversion.Rebridge               41.528     45.14      +8.7%        **0.92x**
NSStringConversion                        160.786    174.462    +8.5%        **0.92x**
DataReplaceLarge                          5932.432   6397.143   +7.8%        **0.93x (?)**

IMPROVEMENT                               OLD        NEW        DELTA        RATIO    
SumUsingReduce                            860.0      294.25     -65.8%       **2.92x**
SumUsingReduceInto                        860.0      294.25     -65.8%       **2.92x**
UTF8Decode_InitDecoding                   131.813    96.304     -26.9%       **1.37x**
UTF8Decode_InitFromCustom_contiguous      131.765    96.625     -26.7%       **1.36x**
UTF8Decode_InitFromData                   132.294    97.304     -26.4%       **1.36x**
UTF8Decode_InitFromBytes                  137.75     101.952    -26.0%       **1.35x**
RawBuffer.copyContents                    12.29      9.538      -22.4%       **1.29x (?)**
CharacterLiteralsLarge                    48.511     39.942     -17.7%       **1.21x**
UTF8Decode_InitFromCustom_noncontiguous   228.2      190.167    -16.7%       **1.20x**
EqualSubstringString                      20.438     17.558     -14.1%       **1.16x**
EqualSubstringSubstringGenericEquatable   20.587     17.69      -14.1%       **1.16x**
EqualStringSubstring                      20.394     17.551     -13.9%       **1.16x**
SortIntPyramid                            515.0      443.696    -13.8%       **1.16x**
LessSubstringSubstringGenericComparable   20.531     17.69      -13.8%       **1.16x**
EqualSubstringSubstring                   20.5       17.688     -13.7%       **1.16x**
LessSubstringSubstring                    20.406     17.69      -13.3%       **1.15x**
SuffixArray                               7.484      6.635      -11.3%       **1.13x**
UTF16Decode.initFromCustom.noncont        285.286    258.375    -9.4%        **1.10x**
ParseInt.UInt64.Hex                       183.182    167.909    -8.3%        **1.09x (?)**
UTF16Decode.initFromCustom.cont           263.375    242.444    -7.9%        **1.09x**
SuffixArrayLazy                           7.195      6.635      -7.8%        **1.08x**
CharIteration_ascii_unicodeScalars        2520.0     2346.667   -6.9%        **1.07x**
CharIteration_tweet_unicodeScalars        4915.556   4580.0     -6.8%        **1.07x**

------- Code size: -Osize -------

REGRESSION                                     OLD     NEW     DELTA    RATIO  
StrToInt.o                                     5226    6638    +27.0%   **0.79x**
RomanNumbers.o                                 3211    3639    +13.3%   **0.88x**
TypeFlood.o                                    523     591     +13.0%   **0.88x**
DictionaryLiteralTest.o                        550     586     +6.5%    **0.94x**
CreateObjects.o                                737     785     +6.5%    **0.94x**
DropWhile.o                                    9635    10199   +5.9%    **0.94x**
ArrayLiteral.o                                 952     1004    +5.5%    **0.95x**
ProtocolDispatch2.o                            1134    1186    +4.6%    **0.96x**
CharacterLiteralsSmall.o                       806     842     +4.5%    **0.96x**
ReduceInto.o                                   5969    6189    +3.7%    **0.96x**
ChainedFilterMap.o                             2335    2415    +3.4%    **0.97x**
SevenBoom.o                                    1264    1304    +3.2%    **0.97x**
SubstringTest.o                                13087   13486   +3.0%    **0.97x**
ProtocolDispatch.o                             540     556     +3.0%    **0.97x**
MapReduce.o                                    14517   14929   +2.8%    **0.97x**
RangeIteration.o                               1076    1104    +2.6%    **0.97x**
DropLast.o                                     13070   13398   +2.5%    **0.98x**
NSDictionaryCastToSwift.o                      1122    1150    +2.5%    **0.98x**
PrefixWhile.o                                  9509    9737    +2.4%    **0.98x**
Histogram.o                                    1209    1237    +2.3%    **0.98x**
DropFirst.o                                    9671    9891    +2.3%    **0.98x**
BitCount.o                                     1070    1094    +2.2%    **0.98x**
Prefix.o                                       9964    10184   +2.2%    **0.98x**
StringInterpolation.o                          5146    5258    +2.2%    **0.98x**
DictionaryBridgeToObjC.o                       3150    3218    +2.2%    **0.98x**
StringRepeating.o                              2618    2674    +2.1%    **0.98x**
Exclusivity.o                                  2894    2954    +2.1%    **0.98x**
CaptureProp.o                                  791     807     +2.0%    **0.98x**
StringWalk.o                                   19576   19964   +2.0%    **0.98x**
XorLoop.o                                      1106    1126    +1.8%    **0.98x**
AnyHashableWithAClass.o                        2483    2527    +1.8%    **0.98x**
DictTest2.o                                    6218    6326    +1.7%    **0.98x**
FloatingPointPrinting.o                        2616    2660    +1.7%    **0.98x**
ArrayOfGenericRef.o                            6316    6420    +1.6%    **0.98x**
SortIntPyramids.o                              7048    7164    +1.6%    **0.98x**
LinkedList.o                                   1722    1750    +1.6%    **0.98x**
NaiveRangeReplaceableCollectionConformance.o   7110    7222    +1.6%    **0.98x**
IterateData.o                                  1295    1315    +1.5%    **0.98x**
StringComparison.o                             23192   23548   +1.5%    **0.98x**
DictionarySubscriptDefault.o                   9985    10137   +1.5%    **0.99x**
FlattenList.o                                  2638    2678    +1.5%    **0.99x**
MonteCarloPi.o                                 1074    1090    +1.5%    **0.99x**
Memset.o                                       1345    1365    +1.5%    **0.99x**
DictionaryCopy.o                               6457    6553    +1.5%    **0.99x**
CString.o                                      5137    5213    +1.5%    **0.99x**
DictionaryRemove.o                             13360   13556   +1.5%    **0.99x**
ArrayOfRef.o                                   5645    5725    +1.4%    **0.99x**
LazyFilter.o                                   5401    5477    +1.4%    **0.99x**
Ackermann.o                                    1158    1174    +1.4%    **0.99x**
CharacterProperties.o                          14564   14764   +1.4%    **0.99x**
CharacterLiteralsLarge.o                       586     594     +1.4%    **0.99x**
DiffingMyers.o                                 5275    5347    +1.4%    **0.99x**
DeadArray.o                                    1194    1210    +1.3%    **0.99x**
StringRemoveDupes.o                            2726    2762    +1.3%    **0.99x**
StrComplexWalk.o                               2134    2162    +1.3%    **0.99x**
BinaryFloatingPointProperties.o                3441    3485    +1.3%    **0.99x**
ReversedCollections.o                          5745    5817    +1.3%    **0.99x**
KeyPathPerformanceTests.o                      71433   72285   +1.2%    **0.99x**
DictionarySwap.o                               12495   12639   +1.2%    **0.99x**
Combos.o                                       3820    3864    +1.2%    **0.99x**
NSStringConversion.o                           9442    9546    +1.1%    **0.99x**
DictionaryOfAnyHashableStrings.o               4371    4419    +1.1%    **0.99x**
StringBuilder.o                                5166    5222    +1.1%    **0.99x**
DictionaryBridge.o                             2230    2254    +1.1%    **0.99x**
DataBenchmarks.o                               37889   38285   +1.0%    **0.99x**
ArrayInClass.o                                 2724    2752    +1.0%    **0.99x**

IMPROVEMENT                                    OLD     NEW     DELTA    RATIO  
NopDeinit.o                                    3265    2817    -13.7%   **1.16x**
PopFront.o                                     2420    2340    -3.3%    **1.03x**
ClassArrayGetter.o                             3006    2930    -2.5%    **1.03x**
RangeReplaceableCollectionPlusDefault.o        6771    6611    -2.4%    **1.02x**
PopFrontGeneric.o                              1917    1873    -2.3%    **1.02x**
ByteSwap.o                                     1070    1046    -2.2%    **1.02x**
Suffix.o                                       13056   12796   -2.0%    **1.02x**
Fibonacci.o                                    1086    1074    -1.1%    **1.01x**

####### Testing optimization level -Onone #######
  

------- Performance (arm64): -Onone -------

REGRESSION                                OLD        NEW        DELTA    RATIO    
DictionarySwapAt                          918.5      1038.857   +13.1%   **0.88x**
ChaCha                                    9407.0     10319.0    +9.7%    **0.91x**
Set.isStrictSuperset.Seq.Int100           1070.5     1167.0     +9.0%    **0.92x (?)**
DataReplaceLarge                          6020.0     6550.0     +8.8%    **0.92x (?)**
CharacterRecognizer.mixed                 12.192     13.193     +8.2%    **0.92x**

IMPROVEMENT                               OLD        NEW        DELTA    RATIO    
ArrayAppendGenericStructs                 1149.091   728.571    -36.6%   **1.58x (?)**
UTF8Decode_InitFromData                   133.071    97.263     -26.9%   **1.37x**
UTF8Decode_InitFromCustom_contiguous      135.588    100.5      -25.9%   **1.35x**
UTF8Decode_InitDecoding                   134.429    99.75      -25.8%   **1.35x**
UTF8Decode_InitFromBytes                  138.0      102.455    -25.8%   **1.35x**
EqualSubstringSubstringGenericEquatable   22.93      19.542     -14.8%   **1.17x**
EqualSubstringString                      24.413     20.888     -14.4%   **1.17x**
LessSubstringSubstringGenericComparable   22.756     19.542     -14.1%   **1.16x**
EqualStringSubstring                      24.055     20.726     -13.8%   **1.16x**
LessSubstringSubstring                    23.613     20.413     -13.6%   **1.16x**
EqualSubstringSubstring                   22.988     20.267     -11.8%   **1.13x**
RawBufferCopyBytes                        11.0       10.277     -6.6%    **1.07x (?)**

@meg-gupta
Copy link
Contributor Author

This was an experiment to record performance regressions by disabling this optimization which can create irreducible loops.

@meg-gupta meg-gupta closed this Sep 11, 2024
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.

1 participant