Skip to content

[metadata prespecialization] Add canonical records to cache. #34490

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

Conversation

nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented Oct 29, 2020

Previously, every call to swift_getGenericMetadata involved looking into the passed-in nominal type descriptor to look for canonical prespecialized metadata records and searching through those records looking for one whose arguments matched those passed to the function. That behavior was an evolution from the previous behavior where the search through canonical metadata records was performed in the metadata accessor itself.

Here, that behavior is removed from swift_getGenericMetadata entirely. This is made possible by calling a different variant of that function from the metadata accessors of generic types for which canonical prespecialized metadata records have been formed. The metadata accessors now call the new runtime function swift_getCanonicalPrespecializedGenericMetadata, either directly or by way of a newly added thunk __swift_instantiateCanonicalPrespecializedGenericMetadata which is analogous to __swift_instantiateGenericMetadata but calls through to swift_getCanonicalPrespecializedGenericMetadata rather than swift_getGenericMetadata.

The new runtime function swift_getCanonicalPrespecializedGenericMetadata takes an additional argument beyond those passed to swift_getGenericMetadata, namely, a swift_once_t * token. That token is used to guard that only one attempt is made to add the canonical prespecialized metadata records attached to the nominal type descriptor to the metadata cache.

Additionally, swift_getCanonicalSpecializedMetadata--the entry point for canonicalizing non-canonical prespecialized metadata records--is able to make use of that same token to also avoid attempting to add more than once to the metadata cache those same canonical prespecialized records. Reusing the once token like this (by both swift_getCanonicalPrespecializedGenericMetadata and swift_getCanonicalSpecializedMetadata) ensures that, regardless of which entry point is used, exactly one attempt will be made to add canonical prespecialized records to the metadata cache.

Reusing the once token is made possible by adding its address to the struct enum and class descriptors after the canonical prespecialized records already in those descriptors. swift_getCanonicalPrespecializedGenericMetadata attempts to find the once token in the type descriptor. If it is there, then that means that there were prespecializations and it attempts to add those prespecializations to the cache (guarded, again, by that once token).

rdar://problem/69855938

@nate-chandler nate-chandler force-pushed the generic-metadata-prespecialization-components/special-entry branch from b323cd5 to 7fed11d Compare October 29, 2020 19:27
@swiftlang swiftlang deleted a comment from swift-ci Oct 29, 2020
Emit a once token when adding canonical prespecialized metadata records
to a nominal type descriptor and add the token itself as a trailing
object to the type descriptor.  The new token will, in subsequent
commits, enable the canonical prespecialized metadata records attached
to the type descriptor to be added to the metadata cache exactly once.
Add a new entry point for getting generic metadata which adds the
canonical metadata records attached to the nominal type descriptor to
the metadata cache.

Change the implementation of the primary entry-point
swift_getGenericMetadata to stop looking through canonical
prespecialized records.

Change the implementation of swift_getCanonicalSpecializedMetadata to
use the caching token attached to the nominal type descriptor to add
canonical prespecialized metadata records to the metadata cache only
once rather than using the cache variables to limit the number of times
the attempt was made.
When emitting the metadata accessor for a generic type for which
canonical prespecialized metadata records have been formed, rather than
calling getGenericMetadata, instead call
getCanonicalPrespecializedGenericMetadata and pass to it the once token
which will guard that the canonical prespecialized metadata records
attached to the nominal type descriptor are only added to the metadata
cache once.
@nate-chandler nate-chandler force-pushed the generic-metadata-prespecialization-components/special-entry branch from 7fed11d to 1bbd0f4 Compare November 1, 2020 21:35
@nate-chandler nate-chandler changed the title [DNM] [Prespecialized Metadata] Add entry point to look through prespecialized records. [Prespecialized Metadata] Add entry point to cache prespecialized records once. Nov 1, 2020
@nate-chandler nate-chandler changed the title [Prespecialized Metadata] Add entry point to cache prespecialized records once. [Prespecialized Metadata] Add prespecialized metadata records to metadata cache once. Nov 1, 2020
@swiftlang swiftlang deleted a comment from swift-ci Nov 1, 2020
@swiftlang swiftlang deleted a comment from swift-ci Nov 1, 2020
@swiftlang swiftlang deleted a comment from swift-ci Nov 1, 2020
@swiftlang swiftlang deleted a comment from swift-ci Nov 1, 2020
@swiftlang swiftlang deleted a comment from swift-ci Nov 1, 2020
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please benchmark

@nate-chandler
Copy link
Contributor Author

@swift-ci please test compiler performance

@nate-chandler
Copy link
Contributor Author

@swift-ci please asan test

@nate-chandler nate-chandler marked this pull request as ready for review November 1, 2020 22:06
@nate-chandler nate-chandler changed the title [Prespecialized Metadata] Add prespecialized metadata records to metadata cache once. [Prespecialized Metadata] Add prespecialized records to cache. Nov 1, 2020
@nate-chandler nate-chandler changed the title [Prespecialized Metadata] Add prespecialized records to cache. [metadata prespecialization] Add prespecialized records to cache. Nov 1, 2020
@nate-chandler nate-chandler changed the title [metadata prespecialization] Add prespecialized records to cache. [metadata prespecialization] Add canonical records to cache. Nov 1, 2020
@swift-ci
Copy link
Contributor

swift-ci commented Nov 1, 2020

Build failed
Swift Test Linux Platform
Git Sha - 1bbd0f4

@nate-chandler
Copy link
Contributor Author

@swift-ci please clean test linux platform

@nate-chandler
Copy link
Contributor Author

@swift-ci please clean test windows platform

@swift-ci
Copy link
Contributor

swift-ci commented Nov 1, 2020

Performance: -O

Improvement OLD NEW DELTA RATIO
CSVParsing.Scalar 332 185 -44.3% 1.79x
ArrayInitFromSlice 810 472 -41.7% 1.72x
ReversedBidirectional 17557 10531 -40.0% 1.67x
NSDictionaryCastToSwift 2400 1460 -39.2% 1.64x
DictionaryOfAnyHashableStrings_insert 7924 5194 -34.5% 1.53x
String.replaceSubrange.RepChar 3638 2393 -34.2% 1.52x
SuffixAnySequenceLazy 6311 4231 -33.0% 1.49x
DropLastAnySequenceLazy 6123 4111 -32.9% 1.49x
ObjectiveCBridgeFromNSArrayAnyObjectForced 6860 4840 -29.4% 1.42x (?)
DictionaryOfAnyHashableStrings_lookup 5808 4152 -28.5% 1.40x
UTF8Decode_InitFromData_ascii_as_ascii 770 612 -20.5% 1.26x (?)
PrefixAnyCollectionLazy 104905 83874 -20.0% 1.25x
DropFirstAnyCollectionLazy 105693 85086 -19.5% 1.24x
DropLastAnyCollectionLazy 35059 28541 -18.6% 1.23x
SuffixAnyCollectionLazy 34754 28680 -17.5% 1.21x
ObjectiveCBridgeStubFromArrayOfNSString2 3250 2730 -16.0% 1.19x (?)
DictionaryCompactMapValuesOfNilValue 5750 4850 -15.7% 1.19x (?)
ObjectiveCBridgeFromNSArrayAnyObject 28400 24200 -14.8% 1.17x (?)
ObjectiveCBridgeToNSArray 15050 13050 -13.3% 1.15x (?)
Diffing.Same 9 8 -11.1% 1.12x (?)
TwoSum 1278 1140 -10.8% 1.12x (?)
DictionaryCompactMapValuesOfCastValue 7560 6750 -10.7% 1.12x (?)
AnyHashableWithAClass 89000 80000 -10.1% 1.11x (?)
ObjectiveCBridgeFromNSDictionaryAnyObject 53700 48300 -10.1% 1.11x (?)
ObjectiveCBridgeFromNSSetAnyObjectForced 6440 5820 -9.6% 1.11x (?)
PlistPerfDecode 464 424 -8.6% 1.09x (?)
StringInterpolation 12500 11500 -8.0% 1.09x (?)
String.replaceSubrange.RepChar.Small 442 409 -7.5% 1.08x (?)
DictionaryBridgeToObjC_Access 903 839 -7.1% 1.08x (?)
ObjectiveCBridgeFromNSSetAnyObject 41000 38200 -6.8% 1.07x (?)

Code size: -O

Performance: -Osize

Regression OLD NEW DELTA RATIO
NSStringConversion.MutableCopy.UTF8 1009 1111 +10.1% 0.91x (?)
 
Improvement OLD NEW DELTA RATIO
CSVParsing.Scalar 335 185 -44.8% 1.81x
ArrayInitFromSlice 810 472 -41.7% 1.72x
NSDictionaryCastToSwift 2390 1450 -39.3% 1.65x
ReversedBidirectional 17441 10991 -37.0% 1.59x
String.replaceSubrange.RepChar 3680 2458 -33.2% 1.50x
DictionaryOfAnyHashableStrings_insert 8022 5362 -33.2% 1.50x
SuffixAnySequenceLazy 6739 4513 -33.0% 1.49x
DropLastAnySequenceLazy 6491 4392 -32.3% 1.48x
DictionaryOfAnyHashableStrings_lookup 5832 4128 -29.2% 1.41x
DropFirstAnySequence 7387 5400 -26.9% 1.37x
PrefixAnySequence 6955 5113 -26.5% 1.36x
ObjectiveCBridgeFromNSArrayAnyObjectForced 7240 5440 -24.9% 1.33x (?)
DictionaryLiteral 4370 3360 -23.1% 1.30x
PrefixAnyCollectionLazy 104557 84138 -19.5% 1.24x
DropFirstAnyCollectionLazy 105542 84998 -19.5% 1.24x
SuffixAnyCollectionLazy 35252 28555 -19.0% 1.23x
DropLastAnyCollectionLazy 35193 28547 -18.9% 1.23x
ObjectiveCBridgeFromNSArrayAnyObject 29400 24000 -18.4% 1.22x (?)
DictionaryCompactMapValuesOfNilValue 5800 5000 -13.8% 1.16x
ObjectiveCBridgeToNSArray 14900 13150 -11.7% 1.13x (?)
Diffing.Same 9 8 -11.1% 1.12x (?)
DictionaryCompactMapValuesOfCastValue 7884 7020 -11.0% 1.12x (?)
TwoSum 1298 1164 -10.3% 1.12x (?)
FrequenciesUsingReduce 6050 5430 -10.2% 1.11x (?)
AnyHashableWithAClass 88500 79500 -10.2% 1.11x (?)
ObjectiveCBridgeFromNSDictionaryAnyObject 54800 49600 -9.5% 1.10x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 39600 36000 -9.1% 1.10x (?)
PlistPerfDecode 462 421 -8.9% 1.10x (?)
ObjectiveCBridgeFromNSSetAnyObjectToStringForced 97000 88500 -8.8% 1.10x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToString 38200 35100 -8.1% 1.09x (?)
String.replaceSubrange.RepChar.Small 437 402 -8.0% 1.09x (?)
ObjectiveCBridgeFromNSSetAnyObject 41600 38400 -7.7% 1.08x (?)
JSONPerfDecode 435 402 -7.6% 1.08x (?)
ObjectiveCBridgeFromNSSetAnyObjectForced 6500 6020 -7.4% 1.08x (?)

Code size: -Osize

Performance: -Onone

Regression OLD NEW DELTA RATIO
DataToStringMedium 8500 9350 +10.0% 0.91x (?)
ArrayOfPOD 1053 1138 +8.1% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
SubstringRemoveFirst1 1 0 -99.9% 1001.00x
SubstringRemoveLast1 1 0 -99.9% 1001.00x
Set.isDisjoint.Seq.Empty.Box 1330 456 -65.7% 2.92x
Set.isDisjoint.Empty.Box 1609 601 -62.6% 2.68x
Set.subtracting.Empty.Box 332 132 -60.2% 2.52x
Set.subtracting.Seq.Empty.Box 1703 711 -58.3% 2.40x
Set.isDisjoint.Box.Empty 1781 794 -55.4% 2.24x
Set.subtracting.Box.Empty 367 168 -54.2% 2.18x
Set.isDisjoint.Seq.Box.Empty 1625 757 -53.4% 2.15x
ArrayAppendAscii 29512 13872 -53.0% 2.13x
ArrayAppendUTF16 29478 13906 -52.8% 2.12x
ArrayAppendLatin1 29648 14008 -52.8% 2.12x
SetIsSubsetBox0 1782 893 -49.9% 2.00x
Set.isStrictSubset.Box0 1794 913 -49.1% 1.96x
Set.subtracting.Seq.Box.Empty 2003 1026 -48.8% 1.95x
StackPromo 109300 57100 -47.8% 1.91x
Combos 2747 1453 -47.1% 1.89x
NSDictionaryCastToSwift 6820 3950 -42.1% 1.73x
ArrayInitFromSlice 920 535 -41.8% 1.72x
DropLastSequenceLazy 19282 11278 -41.5% 1.71x
DropLastAnySequence 19251 11291 -41.3% 1.70x
DropLastSequence 19272 11306 -41.3% 1.70x
DropLastAnySequenceLazy 19716 11720 -40.6% 1.68x
DictionaryLiteral 12370 7390 -40.3% 1.67x (?)
ArrayPlusEqualSingleElementCollection 274339 164030 -40.2% 1.67x
ArrayValueProp 8516 5163 -39.4% 1.65x
PrefixWhileAnySequence 15495 9429 -39.1% 1.64x
PrefixWhileSequence 15514 9480 -38.9% 1.64x
Breadcrumbs.MutatedUTF16ToIdx.ASCII 13 8 -38.5% 1.62x (?)
StringMatch 68100 42100 -38.2% 1.62x
ArrayPlusEqualFiveElementCollection 218781 136752 -37.5% 1.60x
ArrayLiteral2 5037 3253 -35.4% 1.55x
StringRemoveDupes 1131 742 -34.4% 1.52x
DataCreateSmallArray 56300 37050 -34.2% 1.52x (?)
ArrayValueProp3 9956 6561 -34.1% 1.52x
ArrayValueProp4 9817 6510 -33.7% 1.51x
DropFirstSequence 13564 9068 -33.1% 1.50x
SequenceAlgosUnfoldSequence 8200 5510 -32.8% 1.49x
DropWhileSequenceLazy 19164 12883 -32.8% 1.49x
FindString.Rec3.Substring 1145 770 -32.8% 1.49x
String.replaceSubrange.RepChar 3728 2510 -32.7% 1.49x
DictionaryOfAnyHashableStrings_insert 9534 6454 -32.3% 1.48x
DropFirstSequenceLazy 13573 9211 -32.1% 1.47x
DropWhileAnySequenceLazy 19350 13182 -31.9% 1.47x
ArrayValueProp2 10557 7196 -31.8% 1.47x
FindString.Rec3.String 1190 812 -31.8% 1.47x
DropFirstAnySequenceLazy 13907 9522 -31.5% 1.46x
ArrayPlusEqualThreeElements 10240 7020 -31.4% 1.46x
SuffixSequence 14478 9944 -31.3% 1.46x
StringBuilder 4643 3193 -31.2% 1.45x (?)
SuffixAnySequence 14381 9953 -30.8% 1.44x
DropWhileSequence 19222 13327 -30.7% 1.44x
DropFirstAnySequence 14783 10302 -30.3% 1.43x
SuffixSequenceLazy 14382 10045 -30.2% 1.43x
PrefixWhileSequenceLazy 16196 11318 -30.1% 1.43x
StringBuilderSmallReservingCapacity 4664 3261 -30.1% 1.43x (?)
PrefixWhileAnySequenceLazy 16272 11393 -30.0% 1.43x
MapReduceLazySequence 27277 19115 -29.9% 1.43x
SuffixAnySequenceLazy 14941 10478 -29.9% 1.43x
StringUTF16Builder 4580 3220 -29.7% 1.42x (?)
DropWhileAnySequence 20252 14256 -29.6% 1.42x
PrefixSequence 11708 8259 -29.5% 1.42x
Set.isSuperset.Seq.Box0 3034 2141 -29.4% 1.42x (?)
PrefixSequenceLazy 11744 8377 -28.7% 1.40x (?)
Set.isDisjoint.Box25 3502 2507 -28.4% 1.40x
PrefixAnySequenceLazy 11908 8550 -28.2% 1.39x
StringUTF16SubstringBuilder 19700 14260 -27.6% 1.38x
Set.isDisjoint.Empty.Int 807 585 -27.5% 1.38x
ArrayAppendAsciiSubstring 56304 40932 -27.3% 1.38x (?)
PrefixAnySequence 12747 9304 -27.0% 1.37x
ArrayAppendUTF16Substring 56304 41220 -26.8% 1.37x
ArrayAppendLatin1Substring 56916 41724 -26.7% 1.36x
ErrorHandling 6350 4670 -26.5% 1.36x (?)
COWArrayGuaranteedParameterOverhead 12500 9250 -26.0% 1.35x
Set.isStrictSubset.Int.Empty 565 420 -25.7% 1.35x
DictOfArraysToArrayOfDicts 5329 3976 -25.4% 1.34x
Set.isSubset.Int.Empty 549 411 -25.1% 1.34x
StringEdits 240700 181500 -24.6% 1.33x
Set.isDisjoint.Seq.Empty.Int 584 444 -24.0% 1.32x
DictionaryOfAnyHashableStrings_lookup 6528 4992 -23.5% 1.31x (?)
Set.subtracting.Seq.Empty.Int 900 694 -22.9% 1.30x
Set.isSubset.Empty.Int 653 506 -22.5% 1.29x
ObjectiveCBridgeFromNSDictionaryAnyObjectForced 14900 11550 -22.5% 1.29x (?)
Breadcrumbs.MutatedIdxToUTF16.ASCII 18 14 -22.2% 1.29x (?)
DataCreateMediumArray 9420 7360 -21.9% 1.28x (?)
MapReduceShortString 307 240 -21.8% 1.28x
BucketSort 12353 9685 -21.6% 1.28x
Set.subtracting.Empty.Int 186 146 -21.5% 1.27x
Set.isDisjoint.Int.Empty 970 762 -21.4% 1.27x
Dictionary3OfObjects 1943 1527 -21.4% 1.27x
Set.isStrictSubset.Empty.Int 701 554 -21.0% 1.27x
Set.isStrictSubset.Seq.Int.Empty 1676 1335 -20.3% 1.26x (?)
Diffing.Same 10 8 -20.0% 1.25x (?)
Dictionary 1550 1245 -19.7% 1.24x (?)
SetIsSubsetInt0 810 652 -19.5% 1.24x
Set.isStrictSuperset.Seq.Empty.Int 1815 1467 -19.2% 1.24x (?)
Set.subtracting.Seq.Int.Empty 1206 975 -19.2% 1.24x (?)
FlattenListFlatMap 312472 252622 -19.2% 1.24x (?)
Set.isSuperset.Seq.Empty.Int 794 643 -19.0% 1.23x (?)
Set.isSubset.Seq.Int.Empty 1654 1346 -18.6% 1.23x (?)
Set.isStrictSubset.Int0 815 664 -18.5% 1.23x
Set.isDisjoint.Int100 1176 960 -18.4% 1.22x
COWTree 14040 11520 -17.9% 1.22x (?)
ObjectAllocation 962 792 -17.7% 1.21x
Set.subtracting.Int.Empty 221 182 -17.6% 1.21x
StringEnumRawValueInitialization 16600 13680 -17.6% 1.21x (?)
Prims.NonStrongRef.Unmanaged 1815 1497 -17.5% 1.21x (?)
ObjectiveCBridgeFromNSArrayAnyObject 33700 27800 -17.5% 1.21x (?)
Set.isDisjoint.Seq.Int.Empty 890 735 -17.4% 1.21x (?)
Prims.NonStrongRef.Unmanaged.Closure 1866 1546 -17.1% 1.21x (?)
LuhnAlgoEager 5795 4826 -16.7% 1.20x (?)
FatCompactMap 508960 423890 -16.7% 1.20x (?)
PrefixAnyCollectionLazy 177462 147885 -16.7% 1.20x
RangeReplaceableCollectionPlusDefault 8192 6844 -16.5% 1.20x (?)
DictionarySwapOfObjects 28200 23560 -16.5% 1.20x (?)
DictionarySwap 7720 6456 -16.4% 1.20x (?)
ObjectiveCBridgeToNSArray 15900 13300 -16.4% 1.20x (?)
DropLastAnyCollectionLazy 58999 49411 -16.3% 1.19x
StringBuilderWithLongSubstring 5520 4630 -16.1% 1.19x (?)
CSVParsing.UTF16 643 540 -16.0% 1.19x
DropFirstAnyCollectionLazy 176468 148226 -16.0% 1.19x (?)
SuffixAnyCollectionLazy 59632 50147 -15.9% 1.19x
LuhnAlgoLazy 5779 4862 -15.9% 1.19x (?)
DictionaryGroupOfObjects 9045 7623 -15.7% 1.19x
Dict.CopyKeyValue.24k 7796 6572 -15.7% 1.19x
TwoSum 4274 3610 -15.5% 1.18x (?)
CSVParsing.Scalar 762 644 -15.5% 1.18x
Set.isDisjoint.Int50 1404 1187 -15.5% 1.18x
Dict.CopyKeyValue.20k 6630 5610 -15.4% 1.18x
PopFrontArrayGeneric 6520 5520 -15.3% 1.18x (?)
ConvertFloatingPoint.MockFloat64ToInt64 61449 52029 -15.3% 1.18x (?)
ObjectiveCBridgeFromNSArrayAnyObjectForced 11960 10160 -15.1% 1.18x (?)
Prims.NonStrongRef.UnmanagedUGR.Closure 2056 1747 -15.0% 1.18x (?)
DictionaryOfObjects 5075 4330 -14.7% 1.17x (?)
Prims.NonStrongRef.UnownedUnsafe.Closure 2189 1868 -14.7% 1.17x (?)
Dict.CopyKeyValue.16k 5533 4724 -14.6% 1.17x
Prims.NonStrongRef.UnownedUnsafe 2136 1829 -14.4% 1.17x (?)
Prims.NonStrongRef.UnmanagedUGR 2013 1725 -14.3% 1.17x (?)
Set.isDisjoint.Int25 1430 1226 -14.3% 1.17x (?)
Dict.CopyKeyValue.28k 10127 8706 -14.0% 1.16x
MapReduceSequence 43321 37627 -13.1% 1.15x
ReversedBidirectional 126851 110183 -13.1% 1.15x (?)
CSVParsing.UTF8 682 593 -13.0% 1.15x (?)
Dictionary3 752 654 -13.0% 1.15x
DataCountSmall 1655 1440 -13.0% 1.15x (?)
ParseInt.UIntSmall.Binary 25983 22692 -12.7% 1.15x
RandomTree.insert.UnsafePointer 387 338 -12.7% 1.14x (?)
ObjectiveCBridgeStubFromArrayOfNSString2 3350 2930 -12.5% 1.14x (?)
SetSubtractingInt100 538 471 -12.5% 1.14x (?)
DataCountMedium 1656 1450 -12.4% 1.14x (?)
ProtocolDispatch 16523 14495 -12.3% 1.14x (?)
RandomDoubleLCG 62800 55168 -12.2% 1.14x
RomanNumbers2 9228 8119 -12.0% 1.14x (?)
SetUnionInt25 544 481 -11.6% 1.13x
ParseInt.UInt64.Hex 6410 5687 -11.3% 1.13x (?)
DataSetCountSmall 1751 1554 -11.3% 1.13x (?)
String.data.Small 89 79 -11.2% 1.13x (?)
PointerArithmetics 1640300 1457700 -11.1% 1.13x (?)
Prims.NonStrongRef.UnownedSafe 2846 2530 -11.1% 1.12x (?)
ObjectiveCBridgeFromNSSetAnyObjectToStringForced 101000 90000 -10.9% 1.12x (?)
DictionaryCompactMapValuesOfCastValue 66474 59238 -10.9% 1.12x (?)
SetUnionInt50 479 429 -10.4% 1.12x (?)
Prims.NonStrongRef.UnownedSafe.Closure 2907 2605 -10.4% 1.12x (?)
ObjectiveCBridgeFromNSSetAnyObjectForced 6440 5780 -10.2% 1.11x (?)
JSONPerfDecode 469 421 -10.2% 1.11x (?)
SetSymmetricDifferenceInt100 684 614 -10.2% 1.11x
PlistPerfDecode 490 440 -10.2% 1.11x (?)
ExclusivityGlobal 1735 1560 -10.1% 1.11x (?)
Prims 4810 4330 -10.0% 1.11x (?)
ParseInt.UInt64.Decimal 7124 6419 -9.9% 1.11x (?)
SubstringFromLongString 91 82 -9.9% 1.11x (?)
DictionaryRemove 29980 27030 -9.8% 1.11x (?)
SetSymmetricDifferenceInt50 724 653 -9.8% 1.11x
CSVParsingAltIndices2 5170 4664 -9.8% 1.11x (?)
SetSubtractingInt50 470 424 -9.8% 1.11x (?)
QueueGeneric 22540 20340 -9.8% 1.11x (?)
DataCopyBytesSmall 1773 1601 -9.7% 1.11x (?)
PrimsSplit 4775 4315 -9.6% 1.11x (?)
Dictionary2 1820 1645 -9.6% 1.11x (?)
StringInterpolation 16700 15100 -9.6% 1.11x (?)
SetUnionInt100 337 305 -9.5% 1.10x (?)
SetSubtractingInt25 422 382 -9.5% 1.10x (?)
Dictionary2OfObjects 4655 4215 -9.5% 1.10x (?)
DataAccessBytesMedium 1732 1570 -9.4% 1.10x (?)
RemoveWhereQuadraticString 2827 2563 -9.3% 1.10x (?)
DataAccessBytesSmall 1769 1605 -9.3% 1.10x (?)
DataCopyBytesMedium 1910 1734 -9.2% 1.10x (?)
AnyHashableWithAClass 169000 153500 -9.2% 1.10x (?)
Dictionary4 1135 1031 -9.2% 1.10x (?)
CSVParsing.Char 944 858 -9.1% 1.10x (?)
SetSymmetricDifferenceInt25 748 680 -9.1% 1.10x (?)
MapReduceLazyCollectionShort 44747 40693 -9.1% 1.10x
Set.filter.Int100.24k 4252 3868 -9.0% 1.10x
ArrayAppendLazyMap 286050 260430 -9.0% 1.10x (?)
Set.filter.Int100.20k 3620 3296 -9.0% 1.10x (?)
SetSubtractingInt0 336 306 -8.9% 1.10x
StringFromLongWholeSubstring 91 83 -8.8% 1.10x (?)
SetUnion 8850 8080 -8.7% 1.10x (?)
SetUnionInt0 885 808 -8.7% 1.10x (?)
Set.filter.Int100.16k 3065 2800 -8.6% 1.09x (?)
MapReduceLazyCollection 37045 33880 -8.5% 1.09x (?)
DataAppendBytesSmall 1924 1760 -8.5% 1.09x (?)
DataMutateBytesSmall 1900 1740 -8.4% 1.09x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 45400 41600 -8.4% 1.09x (?)
StringFromLongWholeSubstringGeneric 108 99 -8.3% 1.09x (?)
SubstringFromLongStringGeneric 108 99 -8.3% 1.09x (?)
Set.filter.Int50.24k 2582 2368 -8.3% 1.09x (?)
DropLastAnySeqCntRangeLazy 70795 64942 -8.3% 1.09x (?)
PrefixWhileArrayLazy 21589 19812 -8.2% 1.09x (?)
Set.filter.Int100.28k 5655 5191 -8.2% 1.09x (?)
DataSetCountMedium 1950 1790 -8.2% 1.09x (?)
PrefixWhileAnySeqCRangeIter 53654 49285 -8.1% 1.09x (?)
DictionaryBridgeToObjC_Bridge 37 34 -8.1% 1.09x (?)
Set.filter.Int50.20k 2188 2011 -8.1% 1.09x (?)
Set.isSuperset.Seq.Int0 2028 1866 -8.0% 1.09x (?)
FindString.Rec3.Array 14633 13465 -8.0% 1.09x (?)
StrToInt 45860 42260 -7.8% 1.09x (?)
Set.filter.Int50.16k 1838 1694 -7.8% 1.09x (?)
Set.isSuperset.Seq.Int.Empty 1909 1760 -7.8% 1.08x (?)
DropLastAnySeqCntRange 70303 64819 -7.8% 1.08x (?)
FloatingPointPrinting_Float_description_small 24948 23004 -7.8% 1.08x (?)
DictionaryCompactMapValuesOfNilValue 19950 18400 -7.8% 1.08x (?)
ObjectiveCBridgeStubToArrayOfNSString2 4380 4040 -7.8% 1.08x (?)
DropWhileArrayLazy 26274 24240 -7.7% 1.08x (?)
SequenceAlgosList 9580 8840 -7.7% 1.08x (?)
SetIntersectionInt100 960 886 -7.7% 1.08x
RandomIntegersLCG 44810 41401 -7.6% 1.08x (?)
LessSubstringSubstring 133 123 -7.5% 1.08x (?)
EqualStringSubstring 133 123 -7.5% 1.08x (?)
Data.append.Sequence.64kB.Count.RE 28616 26505 -7.4% 1.08x (?)
Set.filter.Int50.28k 3335 3091 -7.3% 1.08x (?)
DropLastAnySeqCRangeIterLazy 70148 65033 -7.3% 1.08x (?)
ObjectiveCBridgeToNSSet 18550 17200 -7.3% 1.08x (?)
Dictionary4Legacy 1392 1291 -7.3% 1.08x (?)
StringToDataEmpty 3450 3200 -7.2% 1.08x (?)
Data.init.Sequence.64kB.Count.RE.I 28261 26231 -7.2% 1.08x (?)
CharacterLiteralsLarge 2200 2042 -7.2% 1.08x (?)
DataAppendSequence 3533400 3282000 -7.1% 1.08x (?)
ExclusivityIndependent 254 236 -7.1% 1.08x (?)
PrefixWhileAnySeqCntRange 52997 49245 -7.1% 1.08x (?)
Set.isDisjoint.Seq.Int100 2136 1985 -7.1% 1.08x (?)
Data.init.Sequence.809B.Count.RE 35371 32874 -7.1% 1.08x (?)
ChainedFilterMap 335403 311814 -7.0% 1.08x (?)
SetIntersectionInt50 602 560 -7.0% 1.07x (?)
StringToDataSmall 3600 3350 -6.9% 1.07x (?)
Data.append.Sequence.809B.Count.RE 35309 32873 -6.9% 1.07x (?)
DataAppendDataMediumToSmall 6380 5940 -6.9% 1.07x (?)
EqualSubstringSubstringGenericEquatable 132 123 -6.8% 1.07x (?)
EqualSubstringString 132 123 -6.8% 1.07x (?)
LessSubstringSubstringGenericComparable 132 123 -6.8% 1.07x (?)
Data.init.Sequence.64kB.Count.RE 28428 26492 -6.8% 1.07x (?)
ProtocolDispatch2 13525 12606 -6.8% 1.07x (?)
Data.init.Sequence.809B.Count.RE.I 35315 32917 -6.8% 1.07x (?)
Data.init.Sequence.809B.Count0.RE 35081 32736 -6.7% 1.07x (?)
NSStringConversion.Rebridge 674 629 -6.7% 1.07x (?)
Data.append.Sequence.809B.Count.RE.I 35409 33055 -6.6% 1.07x (?)
ArrayAppendRepeatCol 347290 324420 -6.6% 1.07x (?)
Dictionary4OfObjects 1581 1477 -6.6% 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 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

swift-ci commented Nov 2, 2020

Build failed
Swift Test OS X Platform
Git Sha - 1bbd0f4

@nate-chandler
Copy link
Contributor Author

@swift-ci please clean test macos platform

@jckarter
Copy link
Contributor

jckarter commented Nov 2, 2020

Very nice! Should we still use the previous implementation when targeting a 5.3 runtime, or is the code size/performance hit from checking all the specializations one by one just not worth it?

@nate-chandler
Copy link
Contributor Author

@jckarter We're a bit lucky in a way: even before this change, getPrespecializedGenericMetadataAvailability returns getSwift54Availability, the feature wasn't enabled for the stdlib in 5.3, and we couldn't target the 5.3 runtime without additions to the compatibility library.

The 5.3 runtime doesn't know about the new trailing objects on the nominal type descriptors which would be needed to loop over the prespecializations in swift_getGenericMetadata (and its version of swift_getGenericMetadata doesn't know to do that). The comparisons can't be done directly in the metadata accessor itself, either, because the 5.3 runtime lacks swift_compareProtocolConformanceDescriptors which is needed to correctly handle multiple conformances of a type to the same protocol.

I guess if we added support in a compatibility library, we could just add swift_getCanonicalPrespecializedGenericMetadata itself, supposing we can add these trailing objects, if it's worth having this feature available for 5.3. What do you think?

@jckarter
Copy link
Contributor

jckarter commented Nov 2, 2020

Ah, I thought we had shipped partial support for prespecializations in 5.3 already. If we haven't shipped that yet, then it might be interesting to back deploy, but I don't think it's strictly necessary since this is an optimization and not core functionality.

@nate-chandler nate-chandler merged commit 5c59bab into swiftlang:main Nov 5, 2020
@nate-chandler nate-chandler deleted the generic-metadata-prespecialization-components/special-entry branch November 5, 2020 03:35
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