Skip to content

SIL optimizer: propagate count and capacity from empty Array/Set/Dictionary singletons. #29428

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
Jan 27, 2020

Conversation

eeckstein
Copy link
Contributor

Constant-propagate the 0 value when loading "count" or "capacity" from the empty Array, Set or Dictionary storage.
On high-level SIL this optimization is also done by the ArrayCountPropagation pass, but only for Array.
And even for Array it's sometimes needed to propagate the empty-array count when high-level semantics function are already inlined.

Fixes an optimization deficiency for empty OptionSet literals.

https://bugs.swift.org/browse/SR-12046
rdar://problem/58861171

…ionary singletons.

Constant-propagate the 0 value when loading "count" or "capacity" from the empty Array, Set or Dictionary storage.
On high-level SIL this optimization is also done by the ArrayCountPropagation pass, but only for Array.
And even for Array it's sometimes needed to propagate the empty-array count when high-level semantics function are already inlined.

Fixes an optimization deficiency for empty OptionSet literals.

https://bugs.swift.org/browse/SR-12046
rdar://problem/58861171
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
Set.isSuperset.Seq.Empty.Int 46 52 +13.0% 0.88x (?)
SortIntPyramid 425 465 +9.4% 0.91x (?)
ParseInt.Small.Decimal 177 193 +9.0% 0.92x (?)
IterateData 874 948 +8.5% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
SuffixArrayLazy 9 4 -55.5% 2.25x
Set.isSubset.Int.Empty 52 46 -11.5% 1.13x (?)
Set.isDisjoint.Seq.Box.Empty 87 80 -8.0% 1.09x (?)

Code size: -O

Improvement OLD NEW DELTA RATIO
DictTest.o 16124 14716 -8.7% 1.10x
DictTest3.o 18461 17117 -7.3% 1.08x
DictTest2.o 11757 11309 -3.8% 1.04x

Performance: -Osize

Regression OLD NEW DELTA RATIO
Set.isDisjoint.Seq.Int.Empty 45 50 +11.1% 0.90x (?)
 
Improvement OLD NEW DELTA RATIO
SuffixArrayLazy 9 4 -55.5% 2.25x
ArrayAppendSequence 870 680 -21.8% 1.28x (?)
Set.isSubset.Int.Empty 49 45 -8.2% 1.09x (?)

Code size: -Osize

Performance: -Onone

Regression OLD NEW DELTA RATIO
ArrayOfGenericPOD2 713 836 +17.3% 0.85x (?)

Code size: -swiftlibs

Improvement OLD NEW DELTA RATIO
libswiftFoundation.dylib 1445888 1421312 -1.7% 1.02x
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: 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

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 966d617

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test macOS

1 similar comment
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test macOS

@eeckstein eeckstein merged commit 21905ea into swiftlang:master Jan 27, 2020
@eeckstein eeckstein deleted the opt-empty-collection branch January 27, 2020 08:51
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