Skip to content

Handle begin_apply in TempRVO #31063

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 4 commits into from
Apr 23, 2020

Conversation

meg-gupta
Copy link
Contributor

A tempobj passed to begin_apply instruction and cannot be modified by it
(is guaranteed and doesn't alias with other inout args) has potential to be optimized
away.

A tempobj passed to begin_apply instruction and cannot be modified by it
(is guaranteed and doesn't alias with other inout args) can be optimzed
away.
@meg-gupta
Copy link
Contributor Author

@swift-ci please test

@meg-gupta
Copy link
Contributor Author

@swift-ci benchmark

@swift-ci
Copy link
Contributor

Build failed before running benchmark.

@meg-gupta meg-gupta requested a review from atrick April 16, 2020 17:32
@meg-gupta
Copy link
Contributor Author

@swift-ci please benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
DictionaryBridgeToObjC_Access 881 1016 +15.3% 0.87x (?)
FloatingPointPrinting_Float_description_uniform 5300 5700 +7.5% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
RandomShuffleLCG2 816 208 -74.5% 3.92x
SortIntPyramid 1300 640 -50.8% 2.03x
SortAdjacentIntPyramids 1565 1175 -24.9% 1.33x
Breadcrumbs.MutatedUTF16ToIdx.ASCII 5 4 -20.0% 1.25x
Breadcrumbs.MutatedIdxToUTF16.ASCII 5 4 -20.0% 1.25x
FindString.Loop1.Substring 826 668 -19.1% 1.24x
FindString.Rec3.Substring 255 217 -14.9% 1.18x
FindString.Rec3.String 215 183 -14.9% 1.17x
ArrayAppendLazyMap 7100 6090 -14.2% 1.17x (?)
ReversedBidirectional 9918 8655 -12.7% 1.15x
LazilyFilteredArrayContains 41400 36600 -11.6% 1.13x (?)
String.replaceSubrange.RepChar 3325 2976 -10.5% 1.12x (?)
RemoveWhereSwapInts 69 62 -10.1% 1.11x
RemoveWhereFilterInts 51 46 -9.8% 1.11x (?)
Data.hash.Empty 80 74 -7.5% 1.08x (?)
Array2D 8112 7520 -7.3% 1.08x (?)
MapReduce 400 371 -7.2% 1.08x (?)
FlattenListLoop 4812 4466 -7.2% 1.08x (?)
ArrayPlusEqualFiveElementCollection 9065 8436 -6.9% 1.07x (?)
MapReduceAnyCollection 426 397 -6.8% 1.07x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
RemoveWhere.o 17157 17845 +4.0% 0.96x
 
Improvement OLD NEW DELTA RATIO
RandomShuffle.o 3632 3368 -7.3% 1.08x
StringMatch.o 5304 5208 -1.8% 1.02x
ReversedCollections.o 9286 9126 -1.7% 1.02x

Performance: -Osize

Regression OLD NEW DELTA RATIO
CharIteration_ascii_unicodeScalars_Backwards 5080 5640 +11.0% 0.90x (?)
CharIteration_tweet_unicodeScalars_Backwards 10080 11160 +10.7% 0.90x (?)
DropLastAnySequenceLazy 4096 4492 +9.7% 0.91x (?)
 
Improvement OLD NEW DELTA RATIO
RandomShuffleLCG2 816 192 -76.5% 4.25x
FlattenListLoop 5203 4005 -23.0% 1.30x
FindString.Loop1.Substring 846 681 -19.5% 1.24x
FlattenListFlatMap 7350 6011 -18.2% 1.22x (?)
ReversedBidirectional 13296 10958 -17.6% 1.21x
FindString.Rec3.String 216 185 -14.4% 1.17x
FindString.Rec3.Substring 257 221 -14.0% 1.16x
RemoveWhereFilterInts 50 44 -12.0% 1.14x (?)
ArrayAppendLazyMap 8130 7210 -11.3% 1.13x (?)
RemoveWhereSwapInts 67 60 -10.4% 1.12x (?)
CharIteration_russian_unicodeScalars 4040 3680 -8.9% 1.10x (?)
NSStringConversion.MutableCopy.Rebridge 955 878 -8.1% 1.09x (?)
Data.hash.Empty 77 71 -7.8% 1.08x
ArrayPlusEqualFiveElementCollection 8325 7696 -7.6% 1.08x (?)
String.replaceSubrange.RepChar 3243 2998 -7.6% 1.08x (?)
Array2D 7520 6960 -7.4% 1.08x (?)
MapReduce 435 406 -6.7% 1.07x (?)

Code size: -Osize

Improvement OLD NEW DELTA RATIO
RandomShuffle.o 3878 3614 -6.8% 1.07x
StringMatch.o 5138 5026 -2.2% 1.02x
RemoveWhere.o 16299 16091 -1.3% 1.01x

Performance: -Onone

Regression OLD NEW DELTA RATIO
Set.isDisjoint.Box25 2491 2835 +13.8% 0.88x (?)
 
Improvement OLD NEW DELTA RATIO
PrefixArrayLazy 88155 65766 -25.4% 1.34x
SuffixArrayLazy 28810 21874 -24.1% 1.32x
DropFirstArrayLazy 87077 66828 -23.3% 1.30x
DropLastArrayLazy 29019 22416 -22.8% 1.29x
SuffixCountableRangeLazy 38397 31162 -18.8% 1.23x (?)
DropLastCountableRangeLazy 38589 31578 -18.2% 1.22x
PrefixCountableRangeLazy 115551 94802 -18.0% 1.22x (?)
DropFirstCountableRangeLazy 115657 95543 -17.4% 1.21x
DropLastAnyCollectionLazy 69525 59474 -14.5% 1.17x (?)
PrefixAnyCollectionLazy 204819 178303 -12.9% 1.15x (?)
DropFirstAnyCollectionLazy 198077 176842 -10.7% 1.12x (?)
String.replaceSubrange.RepChar 3438 3074 -10.6% 1.12x (?)
SuffixAnyCollectionLazy 65850 58902 -10.6% 1.12x (?)
CharacterPropertiesStashed 2370 2150 -9.3% 1.10x (?)
RandomShuffleLCG2 56880 51920 -8.7% 1.10x (?)
CharacterPropertiesStashedMemo 3690 3390 -8.1% 1.09x (?)
DataSetCountSmall 154 142 -7.8% 1.08x
CharacterPropertiesPrecomputed 3240 3000 -7.4% 1.08x (?)
WordCountUniqueUTF16 13000 12050 -7.3% 1.08x (?)
WordCountUniqueASCII 12610 11720 -7.1% 1.08x (?)
CharacterPropertiesFetch 5420 5050 -6.8% 1.07x (?)
StringWordBuilderReservingCapacity 2730 2550 -6.6% 1.07x (?)

Code size: -swiftlibs

Improvement OLD NEW DELTA RATIO
libswiftCompression.dylib 45056 40960 -9.1% 1.10x
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

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this. But remember that a begin_apply operand is used at the point of the end_apply. So the end_apply needs to be considered the use-point for things like checkNoSourceModification.

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7a6ed1a

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7a6ed1a

@meg-gupta
Copy link
Contributor Author

@swift-ci test linux

@meg-gupta
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c5c1330

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c5c1330

@meg-gupta meg-gupta requested a review from atrick April 22, 2020 17:58
@meg-gupta meg-gupta merged commit 4613d94 into swiftlang:master Apr 23, 2020
Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

LGTM

meg-gupta added a commit to meg-gupta/swift that referenced this pull request Apr 24, 2020
* Handle begin_apply in TempRVO

A tempobj passed to begin_apply instruction and cannot be modified by it
(is guaranteed and doesn't alias with other inout args) can be optimzed
away.
meg-gupta added a commit that referenced this pull request Apr 24, 2020
* Handle begin_apply in TempRVO

A tempobj passed to begin_apply instruction and cannot be modified by it
(is guaranteed and doesn't alias with other inout args) can be optimzed
away.
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