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

[Exclusivity] Access Enforcement Folding Optimization #16595

Merged
merged 7 commits into from May 15, 2018
Merged

[Exclusivity] Access Enforcement Folding Optimization #16595

merged 7 commits into from May 15, 2018

Conversation

atrick
Copy link
Member

@atrick atrick commented May 14, 2018

Use AccessedStorageAnalysis to find access markers with no nested conflicts.

This optimization analyzes the scope of each access to determine
whether it contains a potentially conflicting access. If not, then it
can be demoted to an instantaneous check, which still catches
conflicts on any enclosing outer scope.

This removes up to half of the runtime calls associated with
exclusivity checking.

There are about 100 significant benchmark regressions with -O
-enforce-exclusivity=checked.

This optimization roughly cuts the overhead in half. These are the top
30 improvements with the optimization enabled.

XorShift....................................................2.83x
ReversedArray...............................................2.76x
RangeIterationSigned........................................2.67x
ExclusivityGlobal...........................................2.57x
Random......................................................2.44x
ReversedDictionary..........................................2.41x
GeekbenchGEMM...............................................2.35x
ArrayInClass................................................2.31x
StringWalk..................................................2.29x
Ary.........................................................2.25x
Ary3........................................................2.25x
Ary2........................................................2.21x
MultiFileTogether...........................................2.17x
MultiFileSeparate...........................................2.17x
RecursiveOwnedParameter.....................................2.14x
LevenshteinDistance.........................................2.04x
HashTest....................................................1.97x
Voronoi.....................................................1.94x
NopDeinit...................................................1.92x
Life........................................................1.89x
Richards....................................................1.84x
Rectangles..................................................1.74x
MatMul......................................................1.71x
LinkedList..................................................1.51x
GeekbenchFFT................................................1.47x
Xcbuild_OutputByteStreamPerfTests...........................1.39x
ObjectAllocation............................................1.33x
MapReduceLazyCollection.....................................1.30x
Prims.......................................................1.28x
CharIndexing_tweet_unicodeScalars_Backwards.................1.28x

This is a special SIL case that MemAccessUtils and DiagnoseStaticExclusivity
diagnostics handle. Ensure that we have coverage.
@atrick atrick requested a review from shajrawi May 14, 2018 18:16
@atrick
Copy link
Member Author

atrick commented May 14, 2018

@swift-ci test.

@atrick
Copy link
Member Author

atrick commented May 14, 2018

@swift-ci test source compatibility.

@swift-ci
Copy link
Collaborator

Build failed
Swift Test OS X Platform
Git Sha - 11589027d342a530b17c9116690cb6d78fd2db7a

changed = true;
// Insertion in DenseMap invalidates the iterator (if `this` ==
// `other`. Break out of the loop and start over.
restart = true;

Choose a reason for hiding this comment

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

Did you test the impact of this change on compile time? I am concerned about the worst-case complexity of this change / data structure: we might have a lot of repeated / unnecessary work if we frequently restart this loop.

Copy link
Member Author

Choose a reason for hiding this comment

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

The set size should be tiny here. I just couldn't stand copying data to handle an exceedingly rare corner case. But, there's no sense having confusing code. Changed to...

  // Insertion in DenseMap invalidates the iterator in the rare case of
  // self-recursion (`this` == `other`) that passes accessed storage though an
  // argument. Rather than complicate the code, make a temporary copy of the
  // AccessedStorage.
  SmallVector<std::pair<AccessedStorage, StorageAccessInfo>, 8> otherAccesses;
  otherAccesses.reserve(other.storageAccessMap.size());
  otherAccesses.append(other.storageAccessMap.begin(),
                       other.storageAccessMap.end());

  bool changed = false;
  for (auto &accessEntry : otherAccesses) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding compile time. This pass should not make a measurable difference. I'm sanity checking with some real-world projects.

My general philosophy, which drove the decisions in this pass and the upcoming whole module pass:

  • Minimize the memory consumption and cost of the no-optimization case. Additional costs are proportional to the amount of optimization actually performed. Typically this means a single pass over the IR (possibly relying on DFS) doing an opcode check and a single hash table of optimizable things. This pass relies on interprocedural analysis before doing any optimization, so I was paranoid about its cost and size of the results.
  • Worst-case, pathological behavior, which we never see in testing, is more important to guard against than it is to reduce typical overhead of the optimization.

@atrick
Copy link
Member Author

atrick commented May 14, 2018

@swift-ci test.

1 similar comment
@atrick
Copy link
Member Author

atrick commented May 14, 2018

@swift-ci test.

///
/// AccessFolding is a forward data flow analysis that tracks open accesses. If
/// any path to an access' end of scope has a potentially conflicting access,
/// then that access is marker as a nested conflict.

Choose a reason for hiding this comment

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

typo: marker instead of marked.

@atrick
Copy link
Member Author

atrick commented May 14, 2018

@swift-ci test compiler performance.

@atrick
Copy link
Member Author

atrick commented May 14, 2018

@swift-ci smoke benchmark.

@swift-ci
Copy link
Collaborator

Build failed
Swift Test OS X Platform
Git Sha - ef40e5c587f3c8f04f4d15b9fa36538aa2b94480

@swift-ci
Copy link
Collaborator

Build comment file:

Optimized (O)

Improvement (53)
TEST OLD NEW DELTA SPEEDUP
CSVParsingAltIndices 424919 347637 -18.2% 1.22x
Calculator 1315 1098 -16.5% 1.20x
CharIteration_tweet_unicodeScalars 45299 38185 -15.7% 1.19x
COWTree 6674 5669 -15.1% 1.18x
BinaryFloatingPointPropertiesUlp 35 30 -14.3% 1.17x
CharIndexing_chinese_unicodeScalars 14131 12118 -14.2% 1.17x
CharIteration_russian_unicodeScalars_Backwards 13736 11807 -14.0% 1.16x
CharIndexing_korean_unicodeScalars_Backwards 17554 15099 -14.0% 1.16x
BinaryFloatingPointPropertiesNextUp 29 25 -13.8% 1.16x
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 3000 2589 -13.7% 1.16x
CharIndexing_ascii_unicodeScalars_Backwards 18033 15572 -13.6% 1.16x
CStringLongAscii 4684 4058 -13.4% 1.15x
CharIndexing_japanese_unicodeScalars 22104 19153 -13.4% 1.15x
CharIndexing_chinese_unicodeScalars_Backwards 13589 11789 -13.2% 1.15x
CharIndexing_punctuated_unicodeScalars 4068 3626 -10.9% 1.12x
BinaryFloatingPointPropertiesBinade 30 27 -10.0% 1.11x
CharIteration_punctuatedJapanese_unicodeScalars 3908 3525 -9.8% 1.11x
BitCount 165 149 -9.7% 1.11x (?)
CharIteration_punctuated_unicodeScalars_Backwards 3564 3233 -9.3% 1.10x
CharIndexing_punctuatedJapanese_unicodeScalars 3194 2898 -9.3% 1.10x
CharIndexing_korean_unicodeScalars 17065 15518 -9.1% 1.10x
CharIndexing_japanese_unicodeScalars_Backwards 20492 18651 -9.0% 1.10x
CharIndexing_russian_unicodeScalars 14567 13329 -8.5% 1.09x
CharIndexing_punctuated_unicodeScalars_Backwards 3796 3476 -8.4% 1.09x
CharIteration_punctuated_unicodeScalars 4781 4408 -7.8% 1.08x
CharIndexing_russian_unicodeScalars_Backwards 13999 12973 -7.3% 1.08x
ChainedFilterMap 1461 1355 -7.3% 1.08x
ArrayOfRef 4771 4428 -7.2% 1.08x
AnyHashableWithAClass 92911 86423 -7.0% 1.08x
PopFrontUnsafePointer 5630 5254 -6.7% 1.07x (?)
CharIteration_chinese_unicodeScalars_Backwards 11504 10736 -6.7% 1.07x
CharIndexing_tweet_unicodeScalars 33850 31598 -6.7% 1.07x (?)
ArrayAppendUTF16Substring 197321 184204 -6.6% 1.07x
CStringShortAscii 3634 3393 -6.6% 1.07x
ArrayOfGenericRef 4829 4510 -6.6% 1.07x
AngryPhonebook 3360 3141 -6.5% 1.07x (?)
ArrayAppendUTF16 41586 38890 -6.5% 1.07x
ArrayAppendLatin1 42879 40116 -6.4% 1.07x
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 2958 2771 -6.3% 1.07x
CharIteration_japanese_unicodeScalars_Backwards 18080 16955 -6.2% 1.07x
ArrayAppendAscii 4009 3770 -6.0% 1.06x
ArrayPlusEqualThreeElements 1818 1711 -5.9% 1.06x
ArrayAppendGenericStructs 1382 1301 -5.9% 1.06x
CharIteration_chinese_unicodeScalars 15554 14657 -5.8% 1.06x
ArrayAppendLatin1Substring 190669 179731 -5.7% 1.06x
ArrayInClass 70 66 -5.7% 1.06x (?)
ArrayAppendLazyMap 1171 1107 -5.5% 1.06x
CharIteration_korean_unicodeScalars_Backwards 14528 13744 -5.4% 1.06x
ArrayAppendAsciiSubstring 44676 42306 -5.3% 1.06x
PrefixCountableRangeLazy 19 18 -5.3% 1.06x
ArrayAppendSequence 877 831 -5.2% 1.06x
ArrayPlusEqualFiveElementCollection 5912 5610 -5.1% 1.05x
Array2D 2389 2274 -4.8% 1.05x (?)
No Changes (382)
TEST OLD NEW DELTA SPEEDUP
ArrayAppend 1074 1049 -2.3% 1.02x
ArrayAppendArrayOfInt 645 629 -2.5% 1.03x
ArrayAppendFromGeneric 656 631 -3.8% 1.04x
ArrayAppendOptionals 1330 1287 -3.2% 1.03x
ArrayAppendRepeatCol 1165 1118 -4.0% 1.04x
ArrayAppendReserved 809 798 -1.4% 1.01x
ArrayAppendStrings 6695 6438 -3.8% 1.04x
ArrayAppendToFromGeneric 645 629 -2.5% 1.03x
ArrayAppendToGeneric 648 632 -2.5% 1.03x
ArrayLiteral 0 0 +0.0% 1.00x
ArrayOfGenericPOD2 152 146 -3.9% 1.04x
ArrayOfPOD 174 170 -2.3% 1.02x
ArrayPlusEqualArrayOfInt 642 630 -1.9% 1.02x (?)
ArrayPlusEqualSingleElementCollection 1079 1058 -1.9% 1.02x
ArraySubscript 1563 1505 -3.7% 1.04x
ArrayValueProp 6 6 +0.0% 1.00x
ArrayValueProp2 6 6 +0.0% 1.00x
ArrayValueProp3 6 6 +0.0% 1.00x
ArrayValueProp4 6 6 +0.0% 1.00x
ByteSwap 119 115 -3.4% 1.03x
CSVParsing 719644 712524 -1.0% 1.01x
CSVParsingAlt 807602 797567 -1.2% 1.01x (?)
CStringLongNonAscii 2292 2259 -1.4% 1.01x
CaptureProp 4534 4440 -2.1% 1.02x
CharIndexing_ascii_unicodeScalars 16107 16006 -0.6% 1.01x
CharIndexing_tweet_unicodeScalars_Backwards 30779 30728 -0.2% 1.00x
CharIndexing_utf16_unicodeScalars 22773 22729 -0.2% 1.00x
CharIndexing_utf16_unicodeScalars_Backwards 23231 23189 -0.2% 1.00x
CharIteration_ascii_unicodeScalars 19406 19363 -0.2% 1.00x (?)
CharIteration_ascii_unicodeScalars_Backwards 14198 14169 -0.2% 1.00x
CharIteration_japanese_unicodeScalars 23760 23188 -2.4% 1.02x
CharIteration_korean_unicodeScalars 19388 18772 -3.2% 1.03x
CharIteration_russian_unicodeScalars 16319 16139 -1.1% 1.01x
CharIteration_tweet_unicodeScalars_Backwards 28044 28014 -0.1% 1.00x (?)
CharIteration_utf16_unicodeScalars 28075 28040 -0.1% 1.00x (?)
CharIteration_utf16_unicodeScalars_Backwards 17748 17747 -0.0% 1.00x (?)
CharacterLiteralsLarge 6108 6111 +0.0% 1.00x (?)
CharacterLiteralsSmall 232 232 +0.0% 1.00x
CharacterPropertiesFetch 4664 4657 -0.2% 1.00x (?)
CharacterPropertiesPrecomputed 1098 1099 +0.1% 1.00x (?)
CharacterPropertiesStashed 1443 1444 +0.1% 1.00x (?)
CharacterPropertiesStashedMemo 1505 1505 +0.0% 1.00x
Chars 896 896 +0.0% 1.00x
ClassArrayGetter 13 13 +0.0% 1.00x
Combos 509 510 +0.2% 1.00x (?)
DataAccessBytes 1288 1287 -0.1% 1.00x (?)
DataAppendArray 6016 6094 +1.3% 0.99x (?)
DataAppendBytes 5924 5785 -2.3% 1.02x (?)
DataAppendDataLargeToLarge 69017 69045 +0.0% 1.00x (?)
DataAppendDataLargeToMedium 37093 37221 +0.3% 1.00x (?)
DataAppendDataLargeToSmall 36640 38196 +4.2% 0.96x
DataAppendDataMediumToLarge 39496 39355 -0.4% 1.00x (?)
DataAppendDataMediumToMedium 7603 7636 +0.4% 1.00x (?)
DataAppendDataMediumToSmall 7069 7061 -0.1% 1.00x (?)
DataAppendDataSmallToLarge 39091 39080 -0.0% 1.00x (?)
DataAppendDataSmallToMedium 7236 7288 +0.7% 0.99x (?)
DataAppendDataSmallToSmall 7291 7043 -3.4% 1.04x (?)
DataAppendSequence 16572 16524 -0.3% 1.00x (?)
DataCopyBytes 2503 2502 -0.0% 1.00x (?)
DataCount 33 33 +0.0% 1.00x
DataMutateBytes 4337 4355 +0.4% 1.00x
DataReplaceLarge 41347 41159 -0.5% 1.00x (?)
DataReplaceLargeBuffer 61264 61044 -0.4% 1.00x (?)
DataReplaceMedium 11458 11496 +0.3% 1.00x (?)
DataReplaceMediumBuffer 13862 13897 +0.3% 1.00x (?)
DataReplaceSmall 8988 9151 +1.8% 0.98x
DataReplaceSmallBuffer 11030 11125 +0.9% 0.99x (?)
DataReset 3121 3123 +0.1% 1.00x (?)
DataSetCount 857 855 -0.2% 1.00x (?)
DataSubscript 251 251 +0.0% 1.00x
DictOfArraysToArrayOfDicts 811 801 -1.2% 1.01x (?)
Dictionary 671 672 +0.1% 1.00x (?)
Dictionary2 806 809 +0.4% 1.00x (?)
Dictionary2OfObjects 2288 2285 -0.1% 1.00x (?)
Dictionary3 244 243 -0.4% 1.00x
Dictionary3OfObjects 789 789 +0.0% 1.00x
Dictionary4 320 320 +0.0% 1.00x
Dictionary4Legacy 710 710 +0.0% 1.00x
Dictionary4OfObjects 441 440 -0.2% 1.00x (?)
Dictionary4OfObjectsLegacy 927 926 -0.1% 1.00x
DictionaryBridge 937 943 +0.6% 0.99x (?)
DictionaryCopy 106684 107110 +0.4% 1.00x (?)
DictionaryFilter 102385 102810 +0.4% 1.00x (?)
DictionaryGroup 211 212 +0.5% 1.00x (?)
DictionaryGroupOfObjects 2160 2170 +0.5% 1.00x
DictionaryKeysContainsCocoa 36 36 +0.0% 1.00x
DictionaryKeysContainsNative 28 28 +0.0% 1.00x
DictionaryLiteral 1935 1937 +0.1% 1.00x (?)
DictionaryOfObjects 2569 2553 -0.6% 1.01x
DictionaryRemove 4109 4097 -0.3% 1.00x (?)
DictionaryRemoveOfObjects 26523 26536 +0.0% 1.00x (?)
DictionarySubscriptDefaultMutation 271 272 +0.4% 1.00x
DictionarySubscriptDefaultMutationArray 633 650 +2.7% 0.97x (?)
DictionarySubscriptDefaultMutationArrayOfObjects 4085 4087 +0.0% 1.00x (?)
DictionarySubscriptDefaultMutationOfObjects 1764 1764 +0.0% 1.00x
DictionarySwap 1009 1009 +0.0% 1.00x
DictionarySwapAt 6969 6811 -2.3% 1.02x
DictionarySwapAtOfObjects 54692 54613 -0.1% 1.00x (?)
DictionarySwapOfObjects 9127 9116 -0.1% 1.00x (?)
DoubleWidthDivision 0 0 +0.0% 1.00x
DropFirstAnyCollection 51 51 +0.0% 1.00x
DropFirstAnyCollectionLazy 63382 63448 +0.1% 1.00x (?)
DropFirstAnySeqCRangeIter 21480 21485 +0.0% 1.00x (?)
DropFirstAnySeqCRangeIterLazy 21483 21495 +0.1% 1.00x (?)
DropFirstAnySeqCntRange 34 34 +0.0% 1.00x
DropFirstAnySeqCntRangeLazy 34 34 +0.0% 1.00x
DropFirstAnySequence 4876 4875 -0.0% 1.00x (?)
DropFirstAnySequenceLazy 4882 4880 -0.0% 1.00x (?)
DropFirstArray 30 30 +0.0% 1.00x
DropFirstArrayLazy 30 30 +0.0% 1.00x
DropFirstCountableRange 18 18 +0.0% 1.00x
DropFirstCountableRangeLazy 18 18 +0.0% 1.00x
DropFirstSequence 2671 2671 +0.0% 1.00x
DropFirstSequenceLazy 2853 2803 -1.8% 1.02x (?)
DropLastAnyCollection 26 26 +0.0% 1.00x
DropLastAnyCollectionLazy 21181 21201 +0.1% 1.00x (?)
DropLastAnySeqCRangeIter 3692 3707 +0.4% 1.00x
DropLastAnySeqCRangeIterLazy 3697 3701 +0.1% 1.00x (?)
DropLastAnySeqCntRange 12 12 +0.0% 1.00x
DropLastAnySeqCntRangeLazy 12 12 +0.0% 1.00x
DropLastAnySequence 5212 5212 +0.0% 1.00x
DropLastAnySequenceLazy 5404 5401 -0.1% 1.00x (?)
DropLastCountableRange 6 6 +0.0% 1.00x
DropLastCountableRangeLazy 6 6 +0.0% 1.00x
DropLastSequence 512 514 +0.4% 1.00x (?)
DropLastSequenceLazy 514 513 -0.2% 1.00x (?)
DropWhileAnyCollection 63 63 +0.0% 1.00x
DropWhileAnyCollectionLazy 82 82 +0.0% 1.00x
DropWhileAnySeqCRangeIter 16951 16964 +0.1% 1.00x
DropWhileAnySeqCRangeIterLazy 82 82 +0.0% 1.00x
DropWhileAnySeqCntRange 35 35 +0.0% 1.00x
DropWhileAnySeqCntRangeLazy 82 82 +0.0% 1.00x
DropWhileAnySequence 4810 4811 +0.0% 1.00x
DropWhileAnySequenceLazy 1966 1966 +0.0% 1.00x
DropWhileArrayLazy 57 57 +0.0% 1.00x
DropWhileCountableRange 19 19 +0.0% 1.00x
DropWhileCountableRangeLazy 59 59 +0.0% 1.00x
DropWhileSequence 2261 2261 +0.0% 1.00x
DropWhileSequenceLazy 46 46 +0.0% 1.00x
EqualStringSubstring 42 43 +2.4% 0.98x
EqualSubstringString 43 43 +0.0% 1.00x
EqualSubstringSubstring 43 43 +0.0% 1.00x
EqualSubstringSubstringGenericEquatable 43 43 +0.0% 1.00x
ErrorHandling 1547 1547 +0.0% 1.00x
ExclusivityGlobal 3 3 +0.0% 1.00x
ExclusivityIndependent 2 2 +0.0% 1.00x
FatCompactMap 216451 216305 -0.1% 1.00x (?)
FilterEvenUsingReduce 1345 1345 +0.0% 1.00x
FilterEvenUsingReduceInto 153 150 -2.0% 1.02x (?)
FloatingPointPrinting_Double_description_small 23193 23169 -0.1% 1.00x (?)
FloatingPointPrinting_Double_description_uniform 22715 22706 -0.0% 1.00x (?)
FloatingPointPrinting_Double_interpolated 68073 68990 +1.3% 0.99x (?)
FloatingPointPrinting_Float80_description_small 31169 31187 +0.1% 1.00x (?)
FloatingPointPrinting_Float80_description_uniform 30496 30467 -0.1% 1.00x (?)
FloatingPointPrinting_Float80_interpolated 72369 71877 -0.7% 1.01x (?)
FloatingPointPrinting_Float_description_small 4881 4883 +0.0% 1.00x (?)
FloatingPointPrinting_Float_description_uniform 4758 4758 +0.0% 1.00x
FloatingPointPrinting_Float_interpolated 41165 41173 +0.0% 1.00x (?)
FrequenciesUsingReduce 5036 5021 -0.3% 1.00x (?)
FrequenciesUsingReduceInto 1540 1539 -0.1% 1.00x (?)
Hanoi 2229 2226 -0.1% 1.00x (?)
HashTest 992 995 +0.3% 1.00x (?)
Histogram 672 672 +0.0% 1.00x
Integrate 312 312 +0.0% 1.00x
IterateData 1796 1795 -0.1% 1.00x (?)
Join 148 148 +0.0% 1.00x
LazilyFilteredArrayContains 32138 32136 -0.0% 1.00x (?)
LazilyFilteredArrays 67140 66902 -0.4% 1.00x (?)
LazilyFilteredRange 3853 3871 +0.5% 1.00x
LessSubstringSubstring 43 43 +0.0% 1.00x
LessSubstringSubstringGenericComparable 43 43 +0.0% 1.00x
LinkedList 8291 8292 +0.0% 1.00x (?)
LuhnAlgoEager 319 319 +0.0% 1.00x
LuhnAlgoLazy 317 317 +0.0% 1.00x
MapReduce 337 338 +0.3% 1.00x (?)
MapReduceAnyCollection 342 349 +2.0% 0.98x (?)
MapReduceAnyCollectionShort 2296 2288 -0.3% 1.00x (?)
MapReduceClass 3063 3062 -0.0% 1.00x (?)
MapReduceClassShort 4624 4622 -0.0% 1.00x (?)
MapReduceLazyCollection 13 13 +0.0% 1.00x
MapReduceLazyCollectionShort 36 36 +0.0% 1.00x
MapReduceLazySequence 90 90 +0.0% 1.00x
MapReduceSequence 444 443 -0.2% 1.00x (?)
MapReduceShort 2027 2027 +0.0% 1.00x
MapReduceShortString 23 23 +0.0% 1.00x
MapReduceString 69 69 +0.0% 1.00x
Memset 235 235 +0.0% 1.00x
MonteCarloE 10214 10216 +0.0% 1.00x (?)
MonteCarloPi 43945 43909 -0.1% 1.00x (?)
NSDictionaryCastToSwift 7394 7519 +1.7% 0.98x (?)
NSError 169 164 -3.0% 1.03x
NSStringConversion 679 680 +0.1% 1.00x (?)
NibbleSort 3518 3518 +0.0% 1.00x
NopDeinit 28960 28963 +0.0% 1.00x (?)
ObjectAllocation 133 133 +0.0% 1.00x
ObjectiveCBridgeFromNSArrayAnyObject 23653 23761 +0.5% 1.00x (?)
ObjectiveCBridgeFromNSArrayAnyObjectForced 4329 4326 -0.1% 1.00x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToString 42998 42972 -0.1% 1.00x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 40957 40864 -0.2% 1.00x
ObjectiveCBridgeFromNSDictionaryAnyObject 93005 92862 -0.2% 1.00x (?)
ObjectiveCBridgeFromNSSetAnyObject 42981 43184 +0.5% 1.00x
ObjectiveCBridgeFromNSSetAnyObjectForced 4632 4620 -0.3% 1.00x (?)
ObjectiveCBridgeFromNSSetAnyObjectToString 60476 60743 +0.4% 1.00x (?)
ObjectiveCBridgeFromNSString 1138 1138 +0.0% 1.00x
ObjectiveCBridgeFromNSStringForced 2357 2362 +0.2% 1.00x
ObjectiveCBridgeStubDataAppend 11454 11421 -0.3% 1.00x (?)
ObjectiveCBridgeStubDateMutation 424 424 +0.0% 1.00x
ObjectiveCBridgeStubFromArrayOfNSString 29174 28994 -0.6% 1.01x (?)
ObjectiveCBridgeStubFromNSDate 6124 6116 -0.1% 1.00x (?)
ObjectiveCBridgeStubFromNSString 916 923 +0.8% 0.99x (?)
ObjectiveCBridgeStubFromNSStringRef 149 149 +0.0% 1.00x
ObjectiveCBridgeStubNSDataAppend 2507 2442 -2.6% 1.03x (?)
ObjectiveCBridgeStubNSDateMutationRef 13237 13423 +1.4% 0.99x (?)
ObjectiveCBridgeStubToArrayOfNSString 39208 39395 +0.5% 1.00x (?)
ObjectiveCBridgeStubToNSDate 15911 15704 -1.3% 1.01x (?)
ObjectiveCBridgeStubToNSDateRef 3439 3479 +1.2% 0.99x (?)
ObjectiveCBridgeStubToNSString 2402 2404 +0.1% 1.00x (?)
ObjectiveCBridgeStubToNSStringRef 107 107 +0.0% 1.00x
ObjectiveCBridgeStubURLAppendPath 187394 188572 +0.6% 0.99x (?)
ObjectiveCBridgeStubURLAppendPathRef 188943 186986 -1.0% 1.01x (?)
ObjectiveCBridgeToNSArray 14131 14258 +0.9% 0.99x (?)
ObjectiveCBridgeToNSDictionary 23135 22930 -0.9% 1.01x (?)
ObjectiveCBridgeToNSSet 15992 15892 -0.6% 1.01x (?)
ObjectiveCBridgeToNSString 425 425 +0.0% 1.00x
ObserverClosure 2196 2200 +0.2% 1.00x
ObserverForwarderStruct 1226 1222 -0.3% 1.00x (?)
ObserverPartiallyAppliedMethod 3792 3789 -0.1% 1.00x (?)
ObserverUnappliedMethod 2667 2660 -0.3% 1.00x (?)
OpenClose 342 342 +0.0% 1.00x
PartialApplyDynamicType 0 0 +0.0% 1.00x
Phonebook 4647 4651 +0.1% 1.00x (?)
PointerArithmetics 34432 34535 +0.3% 1.00x (?)
PolymorphicCalls 17 17 +0.0% 1.00x
PopFrontArray 1261 1260 -0.1% 1.00x (?)
PopFrontArrayGeneric 1278 1278 +0.0% 1.00x
PrefixAnyCollection 51 51 +0.0% 1.00x
PrefixAnyCollectionLazy 63342 63414 +0.1% 1.00x (?)
PrefixAnySeqCRangeIter 16675 16675 +0.0% 1.00x
PrefixAnySeqCRangeIterLazy 16677 16683 +0.0% 1.00x (?)
PrefixAnySeqCntRange 26 26 +0.0% 1.00x
PrefixAnySeqCntRangeLazy 26 26 +0.0% 1.00x
PrefixAnySequence 4090 4093 +0.1% 1.00x (?)
PrefixAnySequenceLazy 4090 4089 -0.0% 1.00x
PrefixArray 30 30 +0.0% 1.00x
PrefixArrayLazy 30 30 +0.0% 1.00x
PrefixCountableRange 19 19 +0.0% 1.00x
PrefixSequence 2374 2374 +0.0% 1.00x
PrefixSequenceLazy 2447 2447 +0.0% 1.00x
PrefixWhileAnyCollection 89 89 +0.0% 1.00x
PrefixWhileAnyCollectionLazy 52 52 +0.0% 1.00x
PrefixWhileAnySeqCRangeIter 9362 9356 -0.1% 1.00x
PrefixWhileAnySeqCRangeIterLazy 58 58 +0.0% 1.00x
PrefixWhileAnySeqCntRange 44 44 +0.0% 1.00x
PrefixWhileAnySeqCntRangeLazy 52 52 +0.0% 1.00x
PrefixWhileAnySequence 10585 10597 +0.1% 1.00x (?)
PrefixWhileAnySequenceLazy 1494 1494 +0.0% 1.00x
PrefixWhileArray 68 68 +0.0% 1.00x
PrefixWhileArrayLazy 37 37 +0.0% 1.00x
PrefixWhileCountableRange 28 28 +0.0% 1.00x
PrefixWhileCountableRangeLazy 18 18 +0.0% 1.00x
PrefixWhileSequence 307 307 +0.0% 1.00x
PrefixWhileSequenceLazy 28 28 +0.0% 1.00x
Prims 914 916 +0.2% 1.00x (?)
PrimsSplit 923 919 -0.4% 1.00x (?)
QueueConcrete 1159 1158 -0.1% 1.00x (?)
QueueGeneric 1161 1161 +0.0% 1.00x
RC4 168 168 +0.0% 1.00x
RGBHistogram 3155 3116 -1.2% 1.01x (?)
RGBHistogramOfObjects 24127 24108 -0.1% 1.00x (?)
RandomDoubleDef 24260 24260 +0.0% 1.00x
RandomDoubleLCG 3827 3827 +0.0% 1.00x
RandomIntegersDef 22288 22286 -0.0% 1.00x (?)
RandomIntegersLCG 1909 1909 +0.0% 1.00x
RandomShuffleDef 856215 856639 +0.0% 1.00x (?)
RandomShuffleLCG 295915 295325 -0.2% 1.00x (?)
RangeAssignment 304 308 +1.3% 0.99x
RangeIterationSigned 156 153 -1.9% 1.02x (?)
RangeReplaceableCollectionPlusDefault 1042 1036 -0.6% 1.01x (?)
RecursiveOwnedParameter 81 81 +0.0% 1.00x
RemoveWhereFilterInts 40 40 +0.0% 1.00x
RemoveWhereFilterString 227 227 +0.0% 1.00x
RemoveWhereFilterStrings 440 440 +0.0% 1.00x
RemoveWhereMoveInts 15 15 +0.0% 1.00x
RemoveWhereMoveStrings 740 740 +0.0% 1.00x
RemoveWhereQuadraticInts 1216 1215 -0.1% 1.00x (?)
RemoveWhereQuadraticString 340 340 +0.0% 1.00x
RemoveWhereQuadraticStrings 2925 2926 +0.0% 1.00x (?)
RemoveWhereSwapInts 18 18 +0.0% 1.00x
RemoveWhereSwapStrings 881 880 -0.1% 1.00x (?)
ReversedArray 51 51 +0.0% 1.00x
ReversedBidirectional 16910 16949 +0.2% 1.00x (?)
ReversedDictionary 257 257 +0.0% 1.00x
RomanNumbers 80895 80924 +0.0% 1.00x (?)
SequenceAlgosAnySequence 11990 11988 -0.0% 1.00x (?)
SequenceAlgosArray 1660 1662 +0.1% 1.00x (?)
SequenceAlgosContiguousArray 1649 1648 -0.1% 1.00x (?)
SequenceAlgosList 1546 1547 +0.1% 1.00x (?)
SequenceAlgosRange 2273 2273 +0.0% 1.00x
SequenceAlgosUnfoldSequence 1116 1115 -0.1% 1.00x
SetExclusiveOr 5035 5022 -0.3% 1.00x (?)
SetExclusiveOr_OfObjects 11802 11849 +0.4% 1.00x (?)
SetIntersect 682 686 +0.6% 0.99x (?)
SetIntersect_OfObjects 1771 1764 -0.4% 1.00x (?)
SetIsSubsetOf 368 368 +0.0% 1.00x
SetIsSubsetOf_OfObjects 477 477 +0.0% 1.00x
SetUnion 4342 4351 +0.2% 1.00x (?)
SetUnion_OfObjects 10115 10112 -0.0% 1.00x (?)
SevenBoom 842 837 -0.6% 1.01x
Sim2DArray 447 447 +0.0% 1.00x
SortLargeExistentials 5953 5956 +0.1% 1.00x (?)
SortLettersInPlace 1119 1119 +0.0% 1.00x
SortSortedStrings 1000 1002 +0.2% 1.00x (?)
SortStrings 1990 1990 +0.0% 1.00x
SortStringsUnicode 2431 2435 +0.2% 1.00x (?)
StackPromo 26075 26811 +2.8% 0.97x (?)
StaticArray 8 8 +0.0% 1.00x
StrComplexWalk 1431 1431 +0.0% 1.00x
StrToInt 2879 2878 -0.0% 1.00x (?)
StringAdder 706 705 -0.1% 1.00x (?)
StringBuilder 625 624 -0.2% 1.00x (?)
StringBuilderLong 1295 1285 -0.8% 1.01x (?)
StringBuilderWithLongSubstring 1473 1474 +0.1% 1.00x (?)
StringComparison_abnormal 778 778 +0.0% 1.00x
StringComparison_ascii 1197 1197 +0.0% 1.00x
StringComparison_emoji 818 819 +0.1% 1.00x (?)
StringComparison_fastPrenormal 716 717 +0.1% 1.00x (?)
StringComparison_latin1 562 562 +0.0% 1.00x
StringComparison_longSharedPrefix 724 724 +0.0% 1.00x
StringComparison_nonBMPSlowestPrenormal 1588 1588 +0.0% 1.00x
StringComparison_slowerPrenormal 1689 1690 +0.1% 1.00x (?)
StringComparison_zalgo 102437 102350 -0.1% 1.00x (?)
StringEdits 165499 165759 +0.2% 1.00x (?)
StringEnumRawValueInitialization 913 913 +0.0% 1.00x
StringEqualPointerComparison 272 272 +0.0% 1.00x
StringFromLongWholeSubstring 22 22 +0.0% 1.00x
StringFromLongWholeSubstringGeneric 22 22 +0.0% 1.00x
StringHasPrefixAscii 1941 1942 +0.1% 1.00x (?)
StringHasPrefixUnicode 99625 99693 +0.1% 1.00x (?)
StringHasSuffixAscii 1938 1938 +0.0% 1.00x
StringHasSuffixUnicode 100353 100251 -0.1% 1.00x (?)
StringInterpolation 10299 10150 -1.4% 1.01x (?)
StringInterpolationManySmallSegments 20067 20069 +0.0% 1.00x (?)
StringInterpolationSmall 5663 5670 +0.1% 1.00x (?)
StringMatch 11666 11685 +0.2% 1.00x
StringRemoveDupes 499 501 +0.4% 1.00x
StringUTF16Builder 2765 2758 -0.3% 1.00x
StringUTF16SubstringBuilder 5640 5646 +0.1% 1.00x (?)
StringWalk 1487 1487 +0.0% 1.00x
StringWithCString 41754 41711 -0.1% 1.00x (?)
StringWordBuilder 2375 2370 -0.2% 1.00x
StringWordBuilderReservingCapacity 1628 1617 -0.7% 1.01x
SubstringComparable 27 27 +0.0% 1.00x
SubstringEqualString 631 630 -0.2% 1.00x (?)
SubstringEquatable 1414 1412 -0.1% 1.00x (?)
SubstringFromLongString 10 10 +0.0% 1.00x
SubstringFromLongStringGeneric 77 77 +0.0% 1.00x
SuffixAnyCollection 26 26 +0.0% 1.00x
SuffixAnyCollectionLazy 21164 21150 -0.1% 1.00x (?)
SuffixAnySeqCRangeIter 3951 3955 +0.1% 1.00x
SuffixAnySeqCRangeIterLazy 3950 3947 -0.1% 1.00x (?)
SuffixAnySeqCntRange 17 17 +0.0% 1.00x
SuffixAnySeqCntRangeLazy 17 17 +0.0% 1.00x
SuffixAnySequence 5306 5307 +0.0% 1.00x (?)
SuffixAnySequenceLazy 5504 5505 +0.0% 1.00x (?)
SuffixCountableRange 6 6 +0.0% 1.00x
SuffixCountableRangeLazy 6 6 +0.0% 1.00x
SuffixSequence 3790 3789 -0.0% 1.00x (?)
SuffixSequenceLazy 3790 3791 +0.0% 1.00x (?)
SumUsingReduce 96 96 +0.0% 1.00x
SumUsingReduceInto 97 97 +0.0% 1.00x
SuperChars 14919 14884 -0.2% 1.00x (?)
TwoSum 1442 1483 +2.8% 0.97x
TypeFlood 0 0 +0.0% 1.00x
UTF8Decode 259 259 +0.0% 1.00x
Walsh 365 366 +0.3% 1.00x
WordCountHistogramASCII 7535 7552 +0.2% 1.00x (?)
WordCountHistogramUTF16 13621 13615 -0.0% 1.00x (?)
WordCountUniqueASCII 2126 2141 +0.7% 0.99x (?)
WordCountUniqueUTF16 7388 7278 -1.5% 1.02x
WordSplitASCII 6078 6063 -0.2% 1.00x (?)
WordSplitUTF16 7144 7322 +2.5% 0.98x (?)
XorLoop 353 354 +0.3% 1.00x (?)
Hardware Overview
  Model Name: Mac mini
  Model Identifier: Macmini7,1
  Processor Name: Intel Core i5
  Processor Speed: 2.8 GHz
  Number of Processors: 1
  Total Number of Cores: 2
  L2 Cache (per Core): 256 KB
  L3 Cache: 3 MB
  Memory: 16 GB

@nadavrot
Copy link
Contributor

Nice!🎉🍾🚀🚢🌴

@atrick
Copy link
Member Author

atrick commented May 15, 2018

@swift-ci test OS X Platform.

@swift-ci
Copy link
Collaborator

Build failed
Swift Test OS X Platform
Git Sha - ef40e5c587f3c8f04f4d15b9fa36538aa2b94480

Copy link

@shajrawi shajrawi 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
Member Author

atrick commented May 15, 2018

@swift-ci smoke test.

1 similar comment
@atrick
Copy link
Member Author

atrick commented May 15, 2018

@swift-ci smoke test.

Use AccessedStorageAnalysis to find access markers with no nested conflicts.

This optimization analyzes the scope of each access to determine
whether it contains a potentially conflicting access. If not, then it
can be demoted to an instantaneous check, which still catches
conflicts on any enclosing outer scope.

This removes up to half of the runtime calls associated with
exclusivity checking.
There are ~100 significant benchmark regressions (of ~350) with -O
-enforce-exclusivity=checked.

This optimization roughly cuts the overhead in half for almost all of those
regressions. These are the top 30 improvements with the optimization enabled.

XorShift....................................................2.83x
ReversedArray...............................................2.76x
RangeIterationSigned........................................2.67x
ExclusivityGlobal...........................................2.57x
Random......................................................2.44x
ReversedDictionary..........................................2.41x
GeekbenchGEMM...............................................2.35x
ArrayInClass................................................2.31x
StringWalk..................................................2.29x
Ary.........................................................2.25x
Ary3........................................................2.25x
Ary2........................................................2.21x
MultiFileTogether...........................................2.17x
MultiFileSeparate...........................................2.17x
RecursiveOwnedParameter.....................................2.14x
LevenshteinDistance.........................................2.04x
HashTest....................................................1.97x
Voronoi.....................................................1.94x
NopDeinit...................................................1.92x
Life........................................................1.89x
Richards....................................................1.84x
Rectangles..................................................1.74x
MatMul......................................................1.71x
LinkedList..................................................1.51x
GeekbenchFFT................................................1.47x
Xcbuild_OutputByteStreamPerfTests...........................1.39x
ObjectAllocation............................................1.33x
MapReduceLazyCollection.....................................1.30x
Prims.......................................................1.28x
CharIndexing_tweet_unicodeScalars_Backwards.................1.28x
@atrick
Copy link
Member Author

atrick commented May 15, 2018

@swift-ci smoke test.

1 similar comment
@atrick
Copy link
Member Author

atrick commented May 15, 2018

@swift-ci smoke test.

@atrick
Copy link
Member Author

atrick commented May 15, 2018

I verified no measurable impact on building SwiftNIO with -enforce-exclusivity=checked -O.

@atrick atrick merged commit e1baf91 into apple:master May 15, 2018
@eeckstein
Copy link
Member

nice!

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.

None yet

5 participants