Skip to content

[stdlib] Add consuming/owned annotations to Collection implementations #19360

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
Sep 21, 2018

Conversation

airspeedswift
Copy link
Member

@airspeedswift airspeedswift commented Sep 18, 2018

Mostly following the protocols, various ownership annotations on collection types:

  • make all (non-trivial) iterators __consuming
  • all appended/inserted elements __owned
  • make casting-like operations __consuming

Most changes are in now. I'm leaving Set and Dictionary for later as they're in-flux elsewhere.

@airspeedswift
Copy link
Member Author

@swift-ci please smoke benchmark

@swift-ci
Copy link
Contributor

Build comment file:

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
ObserverForwarderStruct 711 917 +29.0% 0.78x (?)
QueueGeneric 1129 1299 +15.1% 0.87x
QueueConcrete 1131 1299 +14.9% 0.87x (?)
ObserverUnappliedMethod 1996 2230 +11.7% 0.90x (?)

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
main.o 35238 45946 +30.4% 0.77x
ArrayAppend.o 40942 42243 +3.2% 0.97x
COWTree.o 15491 15843 +2.3% 0.98x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
ObserverForwarderStruct 731 919 +25.7% 0.80x
QueueConcrete 1127 1307 +16.0% 0.86x (?)
QueueGeneric 1128 1308 +16.0% 0.86x
ObserverUnappliedMethod 1996 2289 +14.7% 0.87x
Improvement
Hanoi 3383 2364 -30.1% 1.43x
ObserverClosure 2072 1898 -8.4% 1.09x (?)
ArrayAppendAsciiSubstring 27126 24936 -8.1% 1.09x

Code size: -Osize

TEST OLD NEW DELTA RATIO
Regression
main.o 16513 41857 +153.5% 0.39x
ObserverForwarderStruct.o 3631 3719 +2.4% 0.98x
ObserverUnappliedMethod.o 5347 5435 +1.6% 0.98x
SortIntPyramids.o 9895 10047 +1.5% 0.98x
RangeAssignment.o 5125 5181 +1.1% 0.99x
Improvement
ObserverClosure.o 3580 3476 -2.9% 1.03x
Hanoi.o 3737 3633 -2.8% 1.03x
ObserverPartiallyAppliedMethod.o 3901 3797 -2.7% 1.03x
ArrayAppend.o 39470 38478 -2.5% 1.03x
ArrayOfRef.o 14054 13870 -1.3% 1.01x
ArrayOfGenericRef.o 15291 15091 -1.3% 1.01x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Regression
RangeAssignment 2827 4338 +53.4% 0.65x
Phonebook 21136 28917 +36.8% 0.73x
CharIndexing_korean_unicodeScalars 308382 334983 +8.6% 0.92x

Code size: Swift libraries

TEST OLD NEW DELTA RATIO
Regression
libswiftCloudKit.dylib 102400 106496 +4.0% 0.96x
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

@airspeedswift
Copy link
Member Author

@swift-ci please smoke test compiler performance

@swift-ci
Copy link
Contributor

Build comment file:

Summary for master smoketest

Unexpected test results, excluded stats for Kingfisher, ReactiveCocoa

No regressions above thresholds

Debug

debug brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 238,742,482,798 238,802,573,884 60,091,086 0.03%
LLVM.NumLLVMBytesOutput 9,500,884 9,499,924 -960 -0.01%
time.swift-driver.wall 26.1s 26.1s 70.3ms 0.27%

debug detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 5,966 5,966 0 0.0%
AST.NumLoadedModules 1,510 1,510 0 0.0%
AST.NumTotalClangImportedEntities 18,342 18,342 0 0.0%
AST.NumUsedConformances 1,344 1,344 0 0.0%
IRModule.NumIRBasicBlocks 31,468 31,464 -4 -0.01%
IRModule.NumIRFunctions 16,820 16,816 -4 -0.02%
IRModule.NumIRGlobals 14,519 14,519 0 0.0%
IRModule.NumIRInsts 443,207 443,242 35 0.01%
IRModule.NumIRValueSymbols 30,059 30,055 -4 -0.01%
LLVM.NumLLVMBytesOutput 9,500,884 9,499,924 -960 -0.01%
SILModule.NumSILGenFunctions 7,845 7,845 0 0.0%
SILModule.NumSILOptFunctions 10,611 10,611 0 0.0%
Sema.NumConformancesDeserialized 34,041 34,041 0 0.0%
Sema.NumConstraintScopes 72,576 72,576 0 0.0%
Sema.NumDeclsDeserialized 273,382 273,382 0 0.0%
Sema.NumDeclsValidated 16,641 16,641 0 0.0%
Sema.NumFunctionsTypechecked 7,085 7,085 0 0.0%
Sema.NumGenericSignatureBuilders 11,512 11,512 0 0.0%
Sema.NumLazyGenericEnvironments 54,592 54,592 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 6,239 6,239 0 0.0%
Sema.NumLazyIterableDeclContexts 45,803 45,803 0 0.0%
Sema.NumTypesDeserialized 126,342 126,312 -30 -0.02%
Sema.NumTypesValidated 14,185 14,185 0 0.0%

Release

release brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 232,545,569,087 232,294,663,451 -250,905,636 -0.11%
LLVM.NumLLVMBytesOutput 10,612,116 10,607,872 -4,244 -0.04%
time.swift-driver.wall 43.1s 43.2s 78.5ms 0.18%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 1,385 1,385 0 0.0%
AST.NumLoadedModules 100 100 0 0.0%
AST.NumTotalClangImportedEntities 4,901 4,901 0 0.0%
AST.NumUsedConformances 1,346 1,346 0 0.0%
IRModule.NumIRBasicBlocks 34,351 34,296 -55 -0.16%
IRModule.NumIRFunctions 15,068 15,093 25 0.17%
IRModule.NumIRGlobals 13,903 13,903 0 0.0%
IRModule.NumIRInsts 335,841 335,527 -314 -0.09%
IRModule.NumIRValueSymbols 27,907 27,932 25 0.09%
LLVM.NumLLVMBytesOutput 10,612,116 10,607,872 -4,244 -0.04%
SILModule.NumSILGenFunctions 6,074 6,074 0 0.0%
SILModule.NumSILOptFunctions 9,036 9,046 10 0.11%
Sema.NumConformancesDeserialized 16,856 16,856 0 0.0%
Sema.NumConstraintScopes 71,136 71,136 0 0.0%
Sema.NumDeclsDeserialized 52,248 52,248 0 0.0%
Sema.NumDeclsValidated 10,362 10,362 0 0.0%
Sema.NumFunctionsTypechecked 4,362 4,362 0 0.0%
Sema.NumGenericSignatureBuilders 2,593 2,593 0 0.0%
Sema.NumLazyGenericEnvironments 9,471 9,471 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 1,346 1,346 0 0.0%
Sema.NumLazyIterableDeclContexts 5,992 5,992 0 0.0%
Sema.NumTypesDeserialized 30,974 30,966 -8 -0.03%
Sema.NumTypesValidated 7,103 7,103 0 0.0%

@airspeedswift
Copy link
Member Author

@swift-ci please smoke test

@airspeedswift
Copy link
Member Author

@swift-ci please smoke benchmark

@airspeedswift
Copy link
Member Author

@swift-ci please smoke test

@swift-ci
Copy link
Contributor

Build comment file:

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
ObserverForwarderStruct 712 912 +28.1% 0.78x (?)
QueueConcrete 1129 1303 +15.4% 0.87x (?)
QueueGeneric 1130 1300 +15.0% 0.87x
ObserverUnappliedMethod 1989 2229 +12.1% 0.89x (?)
StringWordBuilder 1769 1941 +9.7% 0.91x (?)
Improvement
IterateData 1690 1566 -7.3% 1.08x (?)
CStringLongAscii 3529 3277 -7.1% 1.08x

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
main.o 35238 45946 +30.4% 0.77x
ArrayAppend.o 40942 42275 +3.3% 0.97x
COWTree.o 15539 15891 +2.3% 0.98x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
QueueGeneric 1126 1305 +15.9% 0.86x
QueueConcrete 1126 1305 +15.9% 0.86x (?)
ObserverForwarderStruct 801 915 +14.2% 0.88x (?)
ObserverUnappliedMethod 2132 2298 +7.8% 0.93x
Improvement
Hanoi 3375 2247 -33.4% 1.50x
IterateData 1807 1639 -9.3% 1.10x (?)
ArrayAppendAsciiSubstring 27117 24794 -8.6% 1.09x
ObserverClosure 2063 1899 -7.9% 1.09x (?)
CStringLongAscii 3545 3306 -6.7% 1.07x

Code size: -Osize

TEST OLD NEW DELTA RATIO
Regression
main.o 16513 41857 +153.5% 0.39x
ObserverForwarderStruct.o 3631 3719 +2.4% 0.98x
ObserverUnappliedMethod.o 5347 5435 +1.6% 0.98x
SortIntPyramids.o 9895 10047 +1.5% 0.98x
RangeAssignment.o 5125 5181 +1.1% 0.99x
Improvement
ObserverClosure.o 3580 3476 -2.9% 1.03x
Hanoi.o 3737 3633 -2.8% 1.03x
ObserverPartiallyAppliedMethod.o 3901 3797 -2.7% 1.03x
ArrayAppend.o 39470 38478 -2.5% 1.03x
ArrayOfRef.o 14054 13870 -1.3% 1.01x
ArrayOfGenericRef.o 15291 15091 -1.3% 1.01x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Regression
RangeAssignment 2748 4081 +48.5% 0.67x
CharIndexing_punctuated_unicodeScalars 72278 83046 +14.9% 0.87x
DropFirstCountableRangeLazy 37289 42740 +14.6% 0.87x
PrefixCountableRangeLazy 37309 42491 +13.9% 0.88x
PrefixWhileSequence 24955 27991 +12.2% 0.89x
PrefixWhileAnySequence 25377 28347 +11.7% 0.90x
PrefixWhileAnySeqCRangeIter 34176 36921 +8.0% 0.93x

Code size: Swift libraries

TEST OLD NEW DELTA RATIO
Regression
libswiftStdlibUnittest.dylib 405504 413696 +2.0% 0.98x
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

@airspeedswift
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 0459317f835f48af15f4dc53149336b21b0415cc

@@ -64,22 +64,22 @@ class Myclass2 {

arr1.append(1)
// FIXME: missing append()
// CHECK: dref: FAILURE for 'append' usr=s:Sa6appendyyxF
// CHECK: type: (inout Array<Int>) -> (Int) -> ()
Copy link
Member Author

Choose a reason for hiding this comment

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

@nkcsgexi @benlangmuir not entirely sure what this was testing so the fix here was just to make it match the new output... Array.append(_:) now takes its argument owned so the mangled name changed but not sure about the following line.

Copy link
Contributor

Choose a reason for hiding this comment

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

The type change from (inout Array<Int>) -> (Int) -> () to (inout Array<Int>) -> () -> () is bogus. I assume that means we aren't handling owned et. al. correctly in type reconstruction. @slavapestov what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

So would it be better to XFAIL this one for now?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can go ahead and XFAIL it, please do file a radar though.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0459317f835f48af15f4dc53149336b21b0415cc

// CHECK-NEXT: strong_retain %1 : $Hello
// CHECK-NEXT: [[STACK:%.*]] = alloc_stack $Hello
// CHECK-NEXT: store %1 to [[STACK]]
// CHECK-NEXT: apply [[AEFUN]]<Hello>([[STACK]], %0)
// CHECK-NEXT: dealloc_stack [[STACK]]
// CHECK-NEXT: strong_release %1
Copy link
Member Author

Choose a reason for hiding this comment

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

@eeckstein this was the only non-mangled-name change that was needed

@airspeedswift
Copy link
Member Author

Oops missed an assert-build-only optimizer test...

@airspeedswift
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c753163e4cb95ee08b3e8e487f15889a6fe66599

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c753163e4cb95ee08b3e8e487f15889a6fe66599

@airspeedswift
Copy link
Member Author

@swift-ci please smoke test

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@airspeedswift airspeedswift merged commit ae6f5dd into swiftlang:master Sep 21, 2018
milseman pushed a commit to milseman/swift that referenced this pull request Oct 15, 2018
swiftlang#19360)

* Add consuming/owned annotations to Collection implementations

* Update SILOptimizer tests

* Fix access_marker_verify test

* XFAIL reconstruct_type_from_mangled_name
milseman pushed a commit to milseman/swift that referenced this pull request Oct 22, 2018
swiftlang#19360)

* Add consuming/owned annotations to Collection implementations

* Update SILOptimizer tests

* Fix access_marker_verify test

* XFAIL reconstruct_type_from_mangled_name
milseman pushed a commit to milseman/swift that referenced this pull request Oct 28, 2018
swiftlang#19360)

* Add consuming/owned annotations to Collection implementations

* Update SILOptimizer tests

* Fix access_marker_verify test

* XFAIL reconstruct_type_from_mangled_name
milseman pushed a commit to milseman/swift that referenced this pull request Nov 1, 2018
swiftlang#19360)

* Add consuming/owned annotations to Collection implementations

* Update SILOptimizer tests

* Fix access_marker_verify test

* XFAIL reconstruct_type_from_mangled_name
milseman pushed a commit to milseman/swift that referenced this pull request Nov 4, 2018
swiftlang#19360)

* Add consuming/owned annotations to Collection implementations

* Update SILOptimizer tests

* Fix access_marker_verify test

* XFAIL reconstruct_type_from_mangled_name
milseman pushed a commit to milseman/swift that referenced this pull request Nov 4, 2018
swiftlang#19360)

* Add consuming/owned annotations to Collection implementations

* Update SILOptimizer tests

* Fix access_marker_verify test

* XFAIL reconstruct_type_from_mangled_name
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.

5 participants