Skip to content

Start using the best resilience expansion in SIL #23170

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

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Mar 7, 2019

Follow-up to #23263.

Finally start using the best resilience expansion in SIL type lowering.

Completes rdar://problem/24057844, https://bugs.swift.org/browse/SR-261.

@slavapestov slavapestov force-pushed the enable-sil-resilience-expansion branch 3 times, most recently from 4152571 to 13f76bd Compare March 13, 2019 06:39
@slavapestov slavapestov changed the title Start using the correct resilience expansion in SIL Start using the best resilience expansion in SIL Mar 13, 2019
@slavapestov
Copy link
Contributor Author

@swift-ci Please benchmark

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
IterateData 1462 4088 +179.6% 0.36x
Improvement
ObjectiveCBridgeStubDateMutation 394 255 -35.3% 1.55x
ObjectiveCBridgeStubFromNSDate 6560 5230 -20.3% 1.25x (?)
FlattenListLoop 4337 3974 -8.4% 1.09x (?)
MapReduce 397 368 -7.3% 1.08x (?)
FlattenListFlatMap 6541 6072 -7.2% 1.08x (?)
MapReduceAnyCollection 397 369 -7.1% 1.08x (?)

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
IterateData 1462 4042 +176.5% 0.36x
CharacterPropertiesStashed 1870 2050 +9.6% 0.91x (?)
CharacterPropertiesStashedMemo 1840 2010 +9.2% 0.92x (?)
ObjectiveCBridgeToNSArray 14000 15100 +7.9% 0.93x (?)
Improvement
ObjectiveCBridgeStubDateMutation 400 257 -35.7% 1.56x
ObjectiveCBridgeStubFromNSDate 6600 5150 -22.0% 1.28x (?)
DictionaryLiteral 7710 6940 -10.0% 1.11x (?)
FlattenListLoop 4432 4069 -8.2% 1.09x (?)
Array2D 7520 6912 -8.1% 1.09x (?)
MapReduce 433 404 -6.7% 1.07x (?)

Performance: -Onone

TEST OLD NEW DELTA RATIO
Regression
IterateData 5782 7974 +37.9% 0.73x
FatCompactMap 456050 532290 +16.7% 0.86x (?)
RemoveWhereFilterInts 3296 3798 +15.2% 0.87x (?)
RemoveWhereFilterStrings 4117 4706 +14.3% 0.87x (?)
ArrayAppendLazyMap 289930 325270 +12.2% 0.89x (?)
FloatingPointPrinting_Float_interpolated 54600 60600 +11.0% 0.90x (?)
FloatingPointPrinting_Float80_interpolated 95600 105600 +10.5% 0.91x (?)
Breadcrumbs.IdxToUTF16Range.longASCII 364 402 +10.4% 0.91x (?)
Breadcrumbs.UTF16ToIdxRange.longASCII 356 393 +10.4% 0.91x (?)
DataCreateEmptyArray 148700 164150 +10.4% 0.91x (?)
Breadcrumbs.CopyUTF16CodeUnits.ASCII 190 209 +10.0% 0.91x (?)
FloatingPointPrinting_Double_interpolated 72200 79200 +9.7% 0.91x (?)
Breadcrumbs.CopyUTF16CodeUnits.Mixed 222 243 +9.5% 0.91x (?)
LazilyFilteredArrays2 127100 138800 +9.2% 0.92x (?)
NormalizedIterator_ascii 491 536 +9.2% 0.92x (?)
Breadcrumbs.UTF16ToIdxRange.longMixed 443 483 +9.0% 0.92x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 46600 50400 +8.2% 0.92x (?)
WordCountUniqueASCII 12220 13200 +8.0% 0.93x (?)
NormalizedIterator_latin1 790 852 +7.8% 0.93x (?)
CharIteration_tweet_unicodeScalars_Backwards 732800 789080 +7.7% 0.93x (?)
Improvement
ObjectiveCBridgeStubFromNSDate 6230 4910 -21.2% 1.27x (?)
ObjectiveCBridgeStubDateMutation 771 628 -18.5% 1.23x
DictionaryCompactMapValuesOfCastValue 73764 63990 -13.3% 1.15x (?)
LuhnAlgoEager 5002 4460 -10.8% 1.12x (?)
UTF8Decode_InitDecoding_ascii 452 405 -10.4% 1.12x (?)
DictionaryGroup 8646 7782 -10.0% 1.11x (?)
DropWhileAnySeqCntRange 55216 50097 -9.3% 1.10x (?)
DropWhileAnySeqCRangeIter 55112 50070 -9.1% 1.10x (?)
DictionaryLiteral 8030 7360 -8.3% 1.09x (?)
RangeReplaceableCollectionPlusDefault 9732 9024 -7.3% 1.08x (?)
DataReplaceMediumBuffer 11800 11000 -6.8% 1.07x (?)

Code size: -swiftlibs

TEST OLD NEW DELTA RATIO
Regression
libswiftNetwork.dylib 155648 172032 +10.5% 0.90x
libswiftFoundation.dylib 1581056 1642496 +3.9% 0.96x
libswiftCore.dylib 3612672 3690496 +2.2% 0.98x
Improvement
libswiftDispatch.dylib 90112 81920 -9.1% 1.10x
libswiftCloudKit.dylib 77824 73728 -5.3% 1.06x
libswiftStdlibUnittest.dylib 352256 348160 -1.2% 1.01x
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

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 13f76bd14406c6058b802426d2116b240598be1c

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 13f76bd14406c6058b802426d2116b240598be1c

// CHECK: return [[RESULT]] : $()

// CHECK-LABEL: sil @$s4test26cannotConvertToValueUseAltyyF : $@convention(thin) () -> ()
// CHECK: [[TMP:%.*]] = alloc_stack $ResilientStruct
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like at least a FIXME here.

FIXME: The optimizer should easily eliminate this copy. The problem is that copy forwarding assumes that address-only types are always explicitly destroyed.

@slavapestov slavapestov force-pushed the enable-sil-resilience-expansion branch from d7c7ead to f168c00 Compare April 26, 2019 22:12
@slavapestov slavapestov marked this pull request as ready for review April 26, 2019 22:13
@slavapestov slavapestov force-pushed the enable-sil-resilience-expansion branch from f168c00 to eef3b22 Compare April 27, 2019 01:45
This is a large patch; I couldn't split it up further while still
keeping things working. There are four things being changed at
once here:

- Places that call SILType::isAddressOnly()/isLoadable() now call
  the SILFunction overload and not the SILModule one.

- SILFunction's overloads of getTypeLowering() and getLoweredType()
  now pass the function's resilience expansion down, instead of
  hardcoding ResilienceExpansion::Minimal.

- Various other places with '// FIXME: Expansion' now use a better
  resilience expansion.

- A few tests were updated to reflect SILGen's improved code
  generation, and some new tests are added to cover more code paths
  that previously were uncovered and only manifested themselves as
  standard library build failures while I was working on this change.
… a SILModule

Finally we can remove the old overloads.
@slavapestov slavapestov force-pushed the enable-sil-resilience-expansion branch from eef3b22 to d069cc4 Compare April 27, 2019 02:48
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

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