Skip to content

Disable fix_lifetime DCE. #36183

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
Feb 26, 2021
Merged

Disable fix_lifetime DCE. #36183

merged 1 commit into from
Feb 26, 2021

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Feb 26, 2021

Unless the type is a trivial scalar. As a follow-up we could try to
prove that the referenced object is unique, but that seems more
natural for DeadObjectElimination.

This optimization was never correct because references may alias. See
rdar://36038096 ([SR-6608] DeadCodeElimination removes fix_lifetime
instructions.)

Fixes rdar://74759728 (The compiler/optimizer seems to be shortening
the lifetime too early)

@atrick atrick requested a review from eeckstein February 26, 2021 17:36
@atrick
Copy link
Contributor Author

atrick commented Feb 26, 2021

@swift-ci smoke test

@atrick
Copy link
Contributor Author

atrick commented Feb 26, 2021

@swift-ci benchmark

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@atrick
Copy link
Contributor Author

atrick commented Feb 26, 2021

@swift-ci smoke test

@atrick
Copy link
Contributor Author

atrick commented Feb 26, 2021

@swift-ci benchmark

Unless the type is a trivial scalar. As a follow-up we could try to
prove that the referenced object is unique, but that seems more
natural for DeadObjectElimination.

This optimization was never correct because references may alias. See
rdar://36038096 ([SR-6608] DeadCodeElimination removes fix_lifetime
instructions.)

Fixes rdar://74759728 (The compiler/optimizer seems to be shortening
the lifetime too early)
@atrick atrick force-pushed the fix-dce-fixlifetime branch from 9329465 to f470b29 Compare February 26, 2021 19:06
@atrick
Copy link
Contributor Author

atrick commented Feb 26, 2021

@swift-ci smoke test

@atrick
Copy link
Contributor Author

atrick commented Feb 26, 2021

@swift-ci benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
HashTest 840 1140 +35.7% 0.74x
CSVParsingAlt2 1089 1287 +18.2% 0.85x (?)
UTF8Decode_InitFromCustom_noncontiguous_ascii 632 739 +16.9% 0.86x (?)
UTF8Decode_InitFromCustom_noncontiguous_ascii_as_ascii 713 813 +14.0% 0.88x (?)
UnicodeStringFromCodable 309 333 +7.8% 0.93x (?)
StringHasPrefixAscii 1320 1420 +7.6% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
EqualSubstringString 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
LessSubstringSubstringGenericComparable 29 22 -24.1% 1.32x
EqualSubstringSubstring 30 23 -23.3% 1.30x
FlattenListLoop 1340 1032 -23.0% 1.30x (?)
UTF8Decode_InitFromCustom_contiguous 165 130 -21.2% 1.27x
UTF8Decode_InitDecoding 158 129 -18.4% 1.22x
SortAdjacentIntPyramids 800 660 -17.5% 1.21x
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 800 720 -10.0% 1.11x (?)
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 800 720 -10.0% 1.11x (?)
BucketSort 86 78 -9.3% 1.10x (?)
CharIteration_punctuatedJapanese_unicodeScalars 480 440 -8.3% 1.09x (?)
CharIteration_japanese_unicodeScalars_Backwards 5640 5200 -7.8% 1.08x (?)
CharIndexing_japanese_unicodeScalars_Backwards 5640 5200 -7.8% 1.08x (?)
CharIteration_punctuated_unicodeScalars 520 480 -7.7% 1.08x (?)
CharIteration_korean_unicodeScalars 2640 2440 -7.6% 1.08x (?)
CharIteration_chinese_unicodeScalars_Backwards 3320 3080 -7.2% 1.08x (?)
CharIndexing_chinese_unicodeScalars_Backwards 3320 3080 -7.2% 1.08x (?)
CharIteration_ascii_unicodeScalars 2320 2160 -6.9% 1.07x (?)
CharIteration_japanese_unicodeScalars 3560 3320 -6.7% 1.07x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
RangeOverlaps.o 6090 6626 +8.8% 0.92x
MonteCarloE.o 2801 2865 +2.3% 0.98x
BucketSort.o 8591 8751 +1.9% 0.98x
RangeAssignment.o 3313 3369 +1.7% 0.98x
RomanNumbers.o 6774 6870 +1.4% 0.99x
FlattenList.o 3898 3946 +1.2% 0.99x

Performance: -Osize

Regression OLD NEW DELTA RATIO
StringWalk 1360 3080 +126.5% 0.44x
ArrayAppendReserved 250 350 +40.0% 0.71x (?)
HashTest 890 1170 +31.5% 0.76x
Dictionary4 158 207 +31.0% 0.76x
CharIndexing_punctuatedJapanese_unicodeScalars 680 880 +29.4% 0.77x
CharIndexing_tweet_unicodeScalars 6280 7960 +26.8% 0.79x
CharIndexing_japanese_unicodeScalars 4960 6200 +25.0% 0.80x
ArrayAppendLazyMap 680 850 +25.0% 0.80x (?)
CharIndexing_chinese_unicodeScalars 3000 3720 +24.0% 0.81x
CharIndexing_punctuated_unicodeScalars 720 880 +22.2% 0.82x
CharIndexing_korean_unicodeScalars 3920 4760 +21.4% 0.82x
CharIndexing_ascii_unicodeScalars 3200 3880 +21.2% 0.82x
ArrayAppendLatin1Substring 19476 23580 +21.1% 0.83x (?)
ArrayAppendUTF16Substring 19080 23004 +20.6% 0.83x
ArrayAppendAsciiSubstring 19044 22896 +20.2% 0.83x
CharIndexing_utf16_unicodeScalars 4560 5440 +19.3% 0.84x
CSVParsingAlt2 1122 1331 +18.6% 0.84x
CharIteration_japanese_unicodeScalars 3600 4240 +17.8% 0.85x
CharIteration_punctuated_unicodeScalars 480 560 +16.7% 0.86x
CharIndexing_russian_unicodeScalars 3680 4160 +13.0% 0.88x (?)
SortIntPyramid 730 825 +13.0% 0.88x (?)
CharIteration_chinese_unicodeScalars 2120 2360 +11.3% 0.90x (?)
StringHasPrefixAscii 1170 1300 +11.1% 0.90x (?)
Dictionary4OfObjects 275 304 +10.5% 0.90x (?)
Breadcrumbs.UTF16ToIdxRange.longMixed 112 121 +8.0% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ArrayPlusEqualSingleElementCollection 658 423 -35.7% 1.56x (?)
UTF8Decode_InitFromCustom_noncontiguous 368 256 -30.4% 1.44x
UTF8Decode_InitFromCustom_noncontiguous_ascii 879 632 -28.1% 1.39x
LessSubstringSubstring 30 22 -26.7% 1.36x
EqualStringSubstring 30 22 -26.7% 1.36x
EqualSubstringString 30 22 -26.7% 1.36x
ArrayAppendRepeatCol 680 500 -26.5% 1.36x
UTF8Decode_InitFromCustom_noncontiguous_ascii_as_ascii 961 711 -26.0% 1.35x
EqualSubstringSubstringGenericEquatable 29 22 -24.1% 1.32x
EqualSubstringSubstring 30 23 -23.3% 1.30x (?)
LessSubstringSubstringGenericComparable 30 23 -23.3% 1.30x
UTF8Decode_InitFromCustom_contiguous 165 131 -20.6% 1.26x
UTF8Decode_InitDecoding 163 130 -20.2% 1.25x
Data.init.Sequence.2049B.Count0.I 398 333 -16.3% 1.20x
Data.init.Sequence.2047B.Count0.I 381 320 -16.0% 1.19x (?)
CharIteration_korean_unicodeScalars_Backwards 4600 4160 -9.6% 1.11x (?)
CharacterLiteralsLarge 64 58 -9.4% 1.10x (?)
CharIteration_japanese_unicodeScalars_Backwards 6160 5600 -9.1% 1.10x (?)
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 880 800 -9.1% 1.10x
DataSetCountMedium 220 200 -9.1% 1.10x (?)
Data.init.Sequence.64kB.Count0 181 165 -8.8% 1.10x (?)
Data.init.Sequence.64kB.Count0.I 182 167 -8.2% 1.09x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
ArraySetElement.o 1148 1260 +9.8% 0.91x
Sim2DArray.o 1200 1312 +9.3% 0.91x
COWArrayGuaranteedParameterOverhead.o 1219 1331 +9.2% 0.92x
Join.o 1441 1567 +8.7% 0.92x
MonteCarloE.o 2657 2826 +6.4% 0.94x
StackPromo.o 1952 2076 +6.4% 0.94x
Memset.o 1787 1899 +6.3% 0.94x
BinaryFloatingPointProperties.o 4796 5091 +6.2% 0.94x
Array2D.o 2494 2643 +6.0% 0.94x
RangeAssignment.o 3065 3225 +5.2% 0.95x
ArraySubscript.o 2297 2409 +4.9% 0.95x
Prims.o 10477 10963 +4.6% 0.96x
PrimsSplit.o 10529 11015 +4.6% 0.96x
ObserverClosure.o 2499 2613 +4.6% 0.96x
ObserverPartiallyAppliedMethod.o 2548 2662 +4.5% 0.96x
FlattenList.o 3633 3793 +4.4% 0.96x
PopFrontGeneric.o 2599 2711 +4.3% 0.96x
Hanoi.o 2926 3052 +4.3% 0.96x
ObserverForwarderStruct.o 2924 3048 +4.2% 0.96x
SortArrayInClass.o 2666 2778 +4.2% 0.96x
RC4.o 2933 3054 +4.1% 0.96x
BucketSort.o 8019 8336 +4.0% 0.96x
ReversedCollections.o 7164 7441 +3.9% 0.96x
RemoveWhere.o 12943 13419 +3.7% 0.96x
ProtocolConformance.o 3590 3714 +3.5% 0.97x
PopFront.o 3317 3429 +3.4% 0.97x
RandomShuffle.o 3330 3442 +3.4% 0.97x
DiffingMyers.o 6286 6477 +3.0% 0.97x
RangeOverlaps.o 5437 5602 +3.0% 0.97x
Walsh.o 4035 4147 +2.8% 0.97x
Combos.o 5817 5976 +2.7% 0.97x
ArrayInClass.o 4232 4344 +2.6% 0.97x
ArrayAppend.o 21573 22137 +2.6% 0.97x
ObserverUnappliedMethod.o 5032 5156 +2.5% 0.98x
RangeReplaceableCollectionPlusDefault.o 4589 4701 +2.4% 0.98x
DictionaryOfAnyHashableStrings.o 5260 5386 +2.4% 0.98x
StringEdits.o 9638 9834 +2.0% 0.98x
RomanNumbers.o 5128 5216 +1.7% 0.98x
IndexPathTest.o 7206 7318 +1.6% 0.98x
FindStringNaive.o 7868 7989 +1.5% 0.98x
PrimsNonStrongRef.o 82845 84101 +1.5% 0.99x
Hash.o 18185 18449 +1.5% 0.99x
DictionaryGroup.o 10154 10299 +1.4% 0.99x
ArrayOfGenericRef.o 8056 8170 +1.4% 0.99x
Queue.o 11827 11993 +1.4% 0.99x
ArrayOfRef.o 8306 8422 +1.4% 0.99x
Breadcrumbs.o 35707 36204 +1.4% 0.99x
ReduceInto.o 8075 8187 +1.4% 0.99x
Mirror.o 9756 9882 +1.3% 0.99x
Phonebook.o 9004 9114 +1.2% 0.99x
ObjectiveCBridgingStubs.o 13630 13796 +1.2% 0.99x
CSVParsing.o 51646 52214 +1.1% 0.99x
SortIntPyramids.o 8826 8922 +1.1% 0.99x
StringRemoveDupes.o 3706 3746 +1.1% 0.99x

Performance: -Onone

Regression OLD NEW DELTA RATIO
UTF8Decode_InitDecoding_ascii_as_ascii 209 233 +11.5% 0.90x (?)
 
Improvement OLD NEW DELTA RATIO
UTF8Decode_InitFromCustom_contiguous 180 142 -21.1% 1.27x
UTF8Decode_InitDecoding 177 140 -20.9% 1.26x
LessSubstringSubstringGenericComparable 59 50 -15.3% 1.18x (?)
EqualSubstringSubstringGenericEquatable 58 50 -13.8% 1.16x (?)
LessSubstringSubstring 60 52 -13.3% 1.15x (?)
EqualSubstringString 60 52 -13.3% 1.15x (?)
EqualStringSubstring 61 53 -13.1% 1.15x (?)
EqualSubstringSubstring 59 53 -10.2% 1.11x (?)

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

@atrick atrick merged commit ecc7127 into swiftlang:main Feb 26, 2021
@atrick atrick deleted the fix-dce-fixlifetime branch February 26, 2021 22:37
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