Skip to content

SILOptimizer: Peephole to eliminate closures which just apply a witness_method #30689

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
Mar 31, 2020

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Mar 27, 2020

Attempting to fix a performance regression from #28698.

@slavapestov
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Improvement OLD NEW DELTA RATIO
Diffing.Same 5 4 -20.0% 1.25x
UTF8Decode_InitDecoding 166 142 -14.5% 1.17x (?)
UTF8Decode_InitDecoding_ascii 206 192 -6.8% 1.07x (?)

Code size: -O

Improvement OLD NEW DELTA RATIO
PrimsNonStrongRef.o 121032 117304 -3.1% 1.03x

Performance: -Osize

Improvement OLD NEW DELTA RATIO
Diffing.Same 5 4 -20.0% 1.25x
UTF8Decode_InitDecoding 167 144 -13.8% 1.16x
Dictionary3 187 165 -11.8% 1.13x
SortIntPyramid 845 775 -8.3% 1.09x (?)
UTF8Decode_InitDecoding_ascii 210 194 -7.6% 1.08x (?)
FlattenListFlatMap 4858 4502 -7.3% 1.08x (?)

Code size: -Osize

Improvement OLD NEW DELTA RATIO
PrimsNonStrongRef.o 102516 99204 -3.2% 1.03x
Phonebook.o 9254 9014 -2.6% 1.03x

Performance: -Onone

Improvement OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 186 163 -12.4% 1.14x (?)
WordCountHistogramUTF16 94100 86500 -8.1% 1.09x (?)
WordCountHistogramASCII 95800 88900 -7.2% 1.08x (?)
Walsh 4496 4196 -6.7% 1.07x (?)

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

@slavapestov slavapestov force-pushed the curry-thunk-peephole branch from 7ad7568 to fefa32c Compare March 31, 2020 02:56
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov marked this pull request as ready for review March 31, 2020 03:00
@slavapestov slavapestov force-pushed the curry-thunk-peephole branch from fefa32c to 3fde52a Compare March 31, 2020 03:35
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov force-pushed the curry-thunk-peephole branch from 3fde52a to e8b7a3b Compare March 31, 2020 04:29
…ss_method

A partial_apply of a function_ref whose body consists of just an
apply of a witness_method can be simplified down to a simple
partial_apply of the witness_method:

sil @foo:
  %fn = witness_method ...
  %result = apply %fn(...)
  return %result

sil @bar:
  %fn = function_ref @foo
  %closure = partial_apply %fn(...)

  ===>

sil @bar:
  %fn = witness_method ...
  %closure = partial_apply %fn(...)
@slavapestov slavapestov force-pushed the curry-thunk-peephole branch from e8b7a3b to dcd6c6d Compare March 31, 2020 04:48
@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
ObjectiveCBridgeStubFromNSDateRef 4750 5780 +21.7% 0.82x (?)
 
Improvement OLD NEW DELTA RATIO
Diffing.Same 8 7 -12.5% 1.14x (?)

Code size: -O

Improvement OLD NEW DELTA RATIO
PrimsNonStrongRef.o 121032 117304 -3.1% 1.03x

Performance: -Osize

Regression OLD NEW DELTA RATIO
FlattenListFlatMap 6831 7488 +9.6% 0.91x (?)
FlattenListLoop 4758 5196 +9.2% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
String.data.LargeUnicode 110 91 -17.3% 1.21x (?)
Diffing.Same 8 7 -12.5% 1.14x (?)
String.data.Medium 103 95 -7.8% 1.08x (?)
ObjectiveCBridgeToNSDictionary 16800 15550 -7.4% 1.08x (?)

Code size: -Osize

Improvement OLD NEW DELTA RATIO
PrimsNonStrongRef.o 102516 99204 -3.2% 1.03x
Phonebook.o 9254 9014 -2.6% 1.03x

Performance: -Onone

Regression OLD NEW DELTA RATIO
ArrayOfPOD 1033 1114 +7.8% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
Diffing.Same 8 7 -12.5% 1.14x (?)
Data.hash.Small 358 326 -8.9% 1.10x (?)

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 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

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.

2 participants