Skip to content
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

[WIP] Conditional conformance to Hashable for Optional, Dictionary and Array types. #14247

Merged
merged 31 commits into from
Feb 10, 2018

Conversation

mortenbekditlevsen
Copy link
Contributor

This PR makes Optional, Dictionary, Array, ArraySlice and ContiguousArray conditionally conform to Hashable.

Resolves SR-NNNN.

The hashValues are now calculated similar to the automatically synthesized values when conforming to Hashable.
This entails using _combineHashValues as values of the collections are iterated - as well as calling _mixInt before returning the hash.
@@ -409,6 +409,28 @@ extension Optional : Equatable where Wrapped : Equatable {
}
}

extension Optional : Hashable where Wrapped : Hashable {
/// The hash value for the optional.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: this file, like others in the standard library, uses two spaces to indent instead of four.

result = 1
result = _combineHashValues(result, wrapped.hashValue)
}
result = _mixInt(result)
Copy link
Member

Choose a reason for hiding this comment

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

_mixInt can be removed here as well.

for element in self {
result = _combineHashValues(result, element.hashValue)
}
result = _mixInt(result)
Copy link
Member

Choose a reason for hiding this comment

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

Call to _mixInt here is superfluous -- Set and Dictionary already calls it on every hash returned from hashValue. (It is probably okay to call it twice, but there doesn't seem to be a good reason to do so.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I recommended that @mortenbekditlevsen model these after synthesized conformances, which do call a final _mixInt. Part of the motivation here is that _combineHashValues is deterministic, but _mixInt can (eventually) have per-execution variation based on the magic number. I think if we're to abandon the final _mixInt, we ought to consider it wholesale and include the synthesized implementations in the discussion.

Copy link
Member

@lorentey lorentey Jan 31, 2018

Choose a reason for hiding this comment

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

The final _mixInt is done by Set and Dictionary; there is no need to do it twice. (Synthesized hashValues aren't doing the right thing yet.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I’m not sure I understand your comment.

We’re still discussing Array conformance, right? There are no other calls to _mixInt here—am I missing something?

Copy link
Member

@lorentey lorentey Jan 31, 2018

Choose a reason for hiding this comment

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

Calling _mixInt directly before returning from hashValue is unnecessary, because Set and Dictionary will call it for you (in _squeezeHashValue, which standard hashed collections use to generate bucket indices).

Doing it anyway does not improve distribution, it just slows things down. As far as I know, _mixInt wasn't designed to be used in the implementation of hashValue at all. (Update: Except of course it's useful for cases like the commutative hash below.)

Copy link
Collaborator

@xwu xwu Jan 31, 2018

Choose a reason for hiding this comment

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

Ah...got it, thanks. We should remove it from the synthesized implementation as well then.

checkHashable([dd1, dd2, dd3, dd4, dd5, dd6, dd7], equalityOracle: { $0 == $1 })

// d5 is equal to d4, but will probably be iterated differently
let d5: Dictionary<Int, String> = [1: "meow", 4: "mooo", 2: "meow"]
Copy link
Member

Choose a reason for hiding this comment

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

A more reliable way to get different ordering for the same values is to use reserveCapacity; each capacity gets a potentially different permutation. (This works too, but only as long as some of the keys collide.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @lorentey ,
I'm not 100% certain that I understood you correctly, but in my latest commit, I tried instantiating two different mutable Dictionaries and reservedCapacity for 3 elements for each of them. Then I assigned values for the keys in different order and tested this with a version of the Dictionary-hashing, that (intentionally wrongfully) imposes the traversal order on the generated hash value.
But the tests still succeed although I would expect them to fail.
Have I perhaps understood you wrong?

var result: Int = _mixInt(0)
for (k, v) in self {
let combined = _combineHashValues(k.hashValue, v.hashValue)
result ^= _mixInt(combined)
Copy link

Choose a reason for hiding this comment

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

I think _combineHashValues() rather than ^= should be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A previous implementation did this, but it was commented that this makes the hash depend on the traversal order.

So that two equal dicts that happen to be traversed in different order would produce different hashes.

let combined = _combineHashValues(k.hashValue, v.hashValue)
result ^= _mixInt(combined)
}
return result
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @lorentey ,
In the current version I removed _mixInt from Array types and from Optional as per your advise.
I am not 100% certain about your recommendation for the Dictionary - should I do the initial _mixInt(0) and the _mixInt(combined) - or are both of these superfluous too (referring to your discussion with @xwu )?
Sincerely,
/morten

Copy link
Member

Choose a reason for hiding this comment

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

The _mixInt(0) is safe to eliminate, but we definitely need the _mixInt(combined).

You can think of _mixInt as a pseudo-random number generator that gives you a different 64-bit random number for every integer on its input. Calling it before the xor operation ensures that the xor won't cancel out bits in case all the elements return hash values within the same limited range. For example, it turns

0 ^ 1 ^ 2 ^ 3 == 0

into

_mixInt(0) ^ _mixInt(1) ^ _mixInt(2) ^ _mixInt(3)
== 0xb2b24f688dc4164d ^ 0x792e33eb068557de ^ 0x66442b5dc51f5134 ^ 0xfbcb7d4146e1660d
== 0x56132a9f08bf76aa,

which looks like a much healthier hash value. (Dictionary then does another round of _mixInt, turning it into 0x16bb592381f12d84, which isn't necessary in this case, but it doesn't really hurt, either.)

d5[2] = "meow"

var d6: Dictionary<Int, String> = Dictionary()
d6.reserveCapacity(3)
Copy link
Member

Choose a reason for hiding this comment

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

You should reserve a different amount here; for example, d6.reserveCapacity(25) would arrange elements in a different permutation (at least with the hash function we currently have). Dictionaries with the same capacity and elements will arrange elements in the same order.

An even better solution would be to reuse the same dictionary but reserve progressively larger capacities, checking that the hash value does not change after each reservation:

var d5: Dictionary<Int, String> = [1: "meow", 4: "mooo", 2: "meow"]
let expected = d5.hashValue
for capacity in [4, 8, 16, 32, 64, 128, 256] {
  d5.reserveCapacity(capacity)
  expectEqual(d5.hashValue, expected)
}

This makes it a lot more likely that the keys will fall into a different order in at least one iteration. To encourage reordering even more, start with a larger dictionary -- 3 elements have just 6 permutations, while, say, 6 elements have 720.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @lorentey ,
With your suggestion the test now correctly fails on a hashValue implementation that depends on the traversal order.

let combined = _combineHashValues(k.hashValue, v.hashValue)
result ^= _mixInt(combined)
}
return result
Copy link
Member

Choose a reason for hiding this comment

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

The _mixInt(0) is safe to eliminate, but we definitely need the _mixInt(combined).

You can think of _mixInt as a pseudo-random number generator that gives you a different 64-bit random number for every integer on its input. Calling it before the xor operation ensures that the xor won't cancel out bits in case all the elements return hash values within the same limited range. For example, it turns

0 ^ 1 ^ 2 ^ 3 == 0

into

_mixInt(0) ^ _mixInt(1) ^ _mixInt(2) ^ _mixInt(3)
== 0xb2b24f688dc4164d ^ 0x792e33eb068557de ^ 0x66442b5dc51f5134 ^ 0xfbcb7d4146e1660d
== 0x56132a9f08bf76aa,

which looks like a much healthier hash value. (Dictionary then does another round of _mixInt, turning it into 0x16bb592381f12d84, which isn't necessary in this case, but it doesn't really hurt, either.)

@mortenbekditlevsen
Copy link
Contributor Author

In the current implementation I think that I have gathered all suggestions from reviewers so far.
Thank you all for taking your time to review!
Can anyone advise on the next step from here? Will cross-post this comment in the Swift evolution forum.

@moiseev
Copy link
Contributor

moiseev commented Feb 2, 2018

@swift-ci Please smoke test

@moiseev
Copy link
Contributor

moiseev commented Feb 2, 2018

@swift-ci Please smoke benchmark

@moiseev
Copy link
Contributor

moiseev commented Feb 2, 2018

@swift-ci please smoke test compiler performance

@NachoSoto
Copy link
Contributor

Awesome! I filed https://bugs.swift.org/browse/SR-6910 today because I missed that this was still WIP.

@swift-ci
Copy link
Contributor

swift-ci commented Feb 2, 2018

Build comment file:

Summary for master smoketest

Unexpected test results, stats may be off for 3

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) (2)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 44,698,568 44,610,188 -88,380 -0.2%
time.swift-driver.wall 60.5s 60.6s 188.5ms 0.31%

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 71,453 71,338 -115 -0.16%
AST.NumLoadedModules 10,870 10,859 -11 -0.1%
AST.NumTotalClangImportedEntities 198,335 197,966 -369 -0.19%
AST.NumUsedConformances 4,207 4,191 -16 -0.38%
IRModule.NumIRBasicBlocks 109,411 109,024 -387 -0.35%
IRModule.NumIRFunctions 60,190 60,035 -155 -0.26%
IRModule.NumIRGlobals 84,890 84,694 -196 -0.23%
IRModule.NumIRInsts 1,280,401 1,277,207 -3,194 -0.25%
IRModule.NumIRValueSymbols 119,887 119,594 -293 -0.24%
LLVM.NumLLVMBytesOutput 44,698,568 44,610,188 -88,380 -0.2%
SILModule.NumSILGenFunctions 77,083 76,905 -178 -0.23%
SILModule.NumSILOptFunctions 53,008 52,842 -166 -0.31%
Sema.NumConformancesDeserialized 182,193 181,918 -275 -0.15%
Sema.NumConstraintScopes 481,852 480,772 -1,080 -0.22%
Sema.NumDeclsDeserialized 1,387,122 1,385,304 -1,818 -0.13%
Sema.NumDeclsValidated 44,323 44,284 -39 -0.09%
Sema.NumFunctionsTypechecked 41,853 41,790 -63 -0.15%
Sema.NumGenericSignatureBuilders 64,080 64,075 -5 -0.01%
Sema.NumLazyGenericEnvironments 254,326 254,112 -214 -0.08%
Sema.NumLazyGenericEnvironmentsLoaded 29,270 29,203 -67 -0.23%
Sema.NumLazyIterableDeclContexts 241,981 242,034 53 0.02%
Sema.NumTypesDeserialized 1,441,385 1,439,270 -2,115 -0.15%
Sema.NumTypesValidated 188,486 188,366 -120 -0.06%

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) (2)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 40,826,736 40,828,304 1,568 0.0%
time.swift-driver.wall 101.1s 101.2s 57.7ms 0.06%

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 10,387 10,387 0 0.0%
AST.NumLoadedModules 365 365 0 0.0%
AST.NumTotalClangImportedEntities 29,955 29,955 0 0.0%
AST.NumUsedConformances 4,243 4,243 0 0.0%
IRModule.NumIRBasicBlocks 89,471 89,471 0 0.0%
IRModule.NumIRFunctions 38,708 38,708 0 0.0%
IRModule.NumIRGlobals 48,551 48,551 0 0.0%
IRModule.NumIRInsts 862,004 862,004 0 0.0%
IRModule.NumIRValueSymbols 77,691 77,691 0 0.0%
LLVM.NumLLVMBytesOutput 40,826,736 40,828,304 1,568 0.0%
SILModule.NumSILGenFunctions 21,816 21,816 0 0.0%
SILModule.NumSILOptFunctions 28,213 28,213 0 0.0%
Sema.NumConformancesDeserialized 94,635 94,704 69 0.07%
Sema.NumConstraintScopes 452,845 452,845 0 0.0%
Sema.NumDeclsDeserialized 200,660 201,083 423 0.21%
Sema.NumDeclsValidated 28,033 28,033 0 0.0%
Sema.NumFunctionsTypechecked 11,257 11,257 0 0.0%
Sema.NumGenericSignatureBuilders 7,718 7,733 15 0.19%
Sema.NumLazyGenericEnvironments 33,027 33,096 69 0.21%
Sema.NumLazyGenericEnvironmentsLoaded 4,006 4,006 0 0.0%
Sema.NumLazyIterableDeclContexts 20,717 20,792 75 0.36%
Sema.NumTypesDeserialized 233,061 233,466 405 0.17%
Sema.NumTypesValidated 56,831 56,831 0 0.0%

@swift-ci
Copy link
Contributor

swift-ci commented Feb 2, 2018

Build comment file:

Optimized (O)

Regression (2)
TEST OLD NEW DELTA SPEEDUP
DropLastAnySeqCRangeIter 3233 3541 +9.5% 0.91x
DropWhileAnySequence 4237 4464 +5.4% 0.95x
Improvement (5)
TEST OLD NEW DELTA SPEEDUP
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 35090 29459 -16.0% 1.19x
ObjectiveCBridgeFromNSArrayAnyObjectForced 3933 3546 -9.8% 1.11x (?)
ObjectiveCBridgeStubNSDateMutationRef 12345 11501 -6.8% 1.07x (?)
ObjectiveCBridgeFromNSDictionaryAnyObject 111900 106091 -5.2% 1.05x (?)
ObjectiveCBridgeToNSSet 42642 40460 -5.1% 1.05x
No Changes (351)
TEST OLD NEW DELTA SPEEDUP
AngryPhonebook 3304 3303 -0.0% 1.00x (?)
AnyHashableWithAClass 61450 61942 +0.8% 0.99x (?)
Array2D 2284 2283 -0.0% 1.00x (?)
ArrayAppend 934 933 -0.1% 1.00x (?)
ArrayAppendArrayOfInt 671 671 +0.0% 1.00x
ArrayAppendAscii 12272 12287 +0.1% 1.00x
ArrayAppendFromGeneric 673 672 -0.1% 1.00x (?)
ArrayAppendGenericStructs 1211 1210 -0.1% 1.00x (?)
ArrayAppendLatin1 34524 34504 -0.1% 1.00x (?)
ArrayAppendLazyMap 1175 1174 -0.1% 1.00x (?)
ArrayAppendOptionals 1211 1210 -0.1% 1.00x
ArrayAppendRepeatCol 1172 1173 +0.1% 1.00x (?)
ArrayAppendReserved 742 738 -0.5% 1.01x
ArrayAppendSequence 989 991 +0.2% 1.00x (?)
ArrayAppendStrings 13705 13713 +0.1% 1.00x (?)
ArrayAppendToFromGeneric 671 673 +0.3% 1.00x (?)
ArrayAppendToGeneric 672 671 -0.1% 1.00x (?)
ArrayAppendUTF16 33916 33457 -1.4% 1.01x
ArrayInClass 77 77 +0.0% 1.00x
ArrayLiteral 0 0 +0.0% 1.00x
ArrayOfGenericPOD2 129 129 +0.0% 1.00x
ArrayOfGenericRef 3944 3953 +0.2% 1.00x
ArrayOfPOD 156 156 +0.0% 1.00x
ArrayOfRef 3928 3933 +0.1% 1.00x (?)
ArrayPlusEqualArrayOfInt 672 671 -0.1% 1.00x (?)
ArrayPlusEqualFiveElementCollection 4946 4998 +1.1% 0.99x
ArrayPlusEqualSingleElementCollection 932 936 +0.4% 1.00x
ArrayPlusEqualThreeElements 1491 1529 +2.5% 0.98x (?)
ArraySubscript 1373 1370 -0.2% 1.00x (?)
ArrayValueProp 7 7 +0.0% 1.00x
ArrayValueProp2 7 7 +0.0% 1.00x
ArrayValueProp3 7 7 +0.0% 1.00x
ArrayValueProp4 7 7 +0.0% 1.00x
BinaryFloatingPointConversionFromBinaryInteger 41 41 +0.0% 1.00x
BitCount 189 181 -4.2% 1.04x
ByteSwap 88 90 +2.3% 0.98x
COWTree 3239 3274 +1.1% 0.99x (?)
CSVParsing 680701 688023 +1.1% 0.99x (?)
CSVParsingAlt 654398 657685 +0.5% 1.00x (?)
CSVParsingAltIndices 338318 328341 -2.9% 1.03x
CStringLongAscii 4287 4285 -0.0% 1.00x (?)
CStringLongNonAscii 1946 1863 -4.3% 1.04x
CStringShortAscii 4241 4243 +0.0% 1.00x (?)
Calculator 388 397 +2.3% 0.98x
CaptureProp 8480 8242 -2.8% 1.03x
CharIndexing_ascii_unicodeScalars 14264 14247 -0.1% 1.00x
CharIndexing_ascii_unicodeScalars_Backwards 12918 12912 -0.0% 1.00x (?)
CharIndexing_chinese_unicodeScalars 10796 10797 +0.0% 1.00x (?)
CharIndexing_chinese_unicodeScalars_Backwards 9788 9781 -0.1% 1.00x (?)
CharIndexing_japanese_unicodeScalars 17058 17047 -0.1% 1.00x (?)
CharIndexing_japanese_unicodeScalars_Backwards 15452 15447 -0.0% 1.00x (?)
CharIndexing_korean_unicodeScalars 13815 13813 -0.0% 1.00x (?)
CharIndexing_korean_unicodeScalars_Backwards 12527 12524 -0.0% 1.00x (?)
CharIndexing_punctuatedJapanese_unicodeScalars 2598 2602 +0.2% 1.00x (?)
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 2364 2366 +0.1% 1.00x
CharIndexing_punctuated_unicodeScalars 3233 3232 -0.0% 1.00x (?)
CharIndexing_punctuated_unicodeScalars_Backwards 2951 2952 +0.0% 1.00x (?)
CharIndexing_russian_unicodeScalars 11862 11867 +0.0% 1.00x (?)
CharIndexing_russian_unicodeScalars_Backwards 10764 10768 +0.0% 1.00x (?)
CharIndexing_tweet_unicodeScalars 28286 28304 +0.1% 1.00x (?)
CharIndexing_tweet_unicodeScalars_Backwards 25557 25576 +0.1% 1.00x
CharIndexing_utf16_unicodeScalars 18701 18708 +0.0% 1.00x (?)
CharIndexing_utf16_unicodeScalars_Backwards 19128 19139 +0.1% 1.00x
CharIteration_ascii_unicodeScalars 18345 18410 +0.4% 1.00x (?)
CharIteration_ascii_unicodeScalars_Backwards 12621 12623 +0.0% 1.00x (?)
CharIteration_chinese_unicodeScalars 13923 13952 +0.2% 1.00x (?)
CharIteration_chinese_unicodeScalars_Backwards 9574 9570 -0.0% 1.00x (?)
CharIteration_japanese_unicodeScalars 22115 22086 -0.1% 1.00x
CharIteration_japanese_unicodeScalars_Backwards 15104 15099 -0.0% 1.00x (?)
CharIteration_korean_unicodeScalars 17848 17868 +0.1% 1.00x
CharIteration_korean_unicodeScalars_Backwards 12237 12243 +0.0% 1.00x (?)
CharIteration_punctuatedJapanese_unicodeScalars 3319 3302 -0.5% 1.01x (?)
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 2317 2317 +0.0% 1.00x
CharIteration_punctuated_unicodeScalars 4142 4155 +0.3% 1.00x (?)
CharIteration_punctuated_unicodeScalars_Backwards 2892 2892 +0.0% 1.00x
CharIteration_russian_unicodeScalars 15351 15365 +0.1% 1.00x (?)
CharIteration_russian_unicodeScalars_Backwards 10536 10521 -0.1% 1.00x (?)
CharIteration_tweet_unicodeScalars 36576 36624 +0.1% 1.00x (?)
CharIteration_tweet_unicodeScalars_Backwards 24636 24641 +0.0% 1.00x (?)
CharIteration_utf16_unicodeScalars 24447 24486 +0.2% 1.00x
CharIteration_utf16_unicodeScalars_Backwards 15186 15200 +0.1% 1.00x (?)
CharacterLiteralsLarge 5489 5495 +0.1% 1.00x (?)
CharacterLiteralsSmall 369 369 +0.0% 1.00x
CharacterPropertiesFetch 4164 4153 -0.3% 1.00x (?)
CharacterPropertiesPrecomputed 909 872 -4.1% 1.04x
CharacterPropertiesStashed 1390 1367 -1.7% 1.02x (?)
CharacterPropertiesStashedMemo 1390 1363 -1.9% 1.02x
Chars 892 870 -2.5% 1.03x
ClassArrayGetter 13 13 +0.0% 1.00x
Combos 425 413 -2.8% 1.03x
DictOfArraysToArrayOfDicts 726 709 -2.3% 1.02x
Dictionary 451 455 +0.9% 0.99x
Dictionary2 1444 1450 +0.4% 1.00x
Dictionary2OfObjects 2663 2668 +0.2% 1.00x (?)
Dictionary3 212 215 +1.4% 0.99x (?)
Dictionary3OfObjects 608 606 -0.3% 1.00x (?)
DictionaryBridge 1824 1801 -1.3% 1.01x (?)
DictionaryGroup 119 119 +0.0% 1.00x
DictionaryGroupOfObjects 1716 1712 -0.2% 1.00x (?)
DictionaryLiteral 1431 1443 +0.8% 0.99x (?)
DictionaryOfObjects 1955 1970 +0.8% 0.99x
DictionaryRemove 2366 2369 +0.1% 1.00x (?)
DictionaryRemoveOfObjects 21249 21231 -0.1% 1.00x (?)
DictionarySubscriptDefaultMutation 129 135 +4.7% 0.96x
DictionarySubscriptDefaultMutationArray 441 441 +0.0% 1.00x
DictionarySubscriptDefaultMutationArrayOfObjects 3400 3407 +0.2% 1.00x (?)
DictionarySubscriptDefaultMutationOfObjects 1241 1245 +0.3% 1.00x (?)
DictionarySwap 420 419 -0.2% 1.00x
DictionarySwapOfObjects 6620 6717 +1.5% 0.99x (?)
DoubleWidthDivision 213 212 -0.5% 1.00x
DropFirstAnyCollection 69 68 -1.4% 1.01x
DropFirstAnyCollectionLazy 60797 61387 +1.0% 0.99x (?)
DropFirstAnySeqCRangeIter 16203 16259 +0.3% 1.00x
DropFirstAnySeqCRangeIterLazy 16158 16241 +0.5% 0.99x
DropFirstAnySeqCntRange 64 64 +0.0% 1.00x
DropFirstAnySeqCntRangeLazy 64 64 +0.0% 1.00x
DropFirstAnySequence 3963 4099 +3.4% 0.97x
DropFirstAnySequenceLazy 3964 4093 +3.3% 0.97x
DropFirstArray 31 31 +0.0% 1.00x
DropFirstArrayLazy 31 31 +0.0% 1.00x
DropFirstCountableRange 31 31 +0.0% 1.00x
DropFirstCountableRangeLazy 31 31 +0.0% 1.00x
DropFirstSequence 2420 2422 +0.1% 1.00x
DropFirstSequenceLazy 2504 2505 +0.0% 1.00x (?)
DropLastAnyCollection 25 25 +0.0% 1.00x
DropLastAnyCollectionLazy 19653 19762 +0.6% 0.99x (?)
DropLastAnySeqCRangeIterLazy 3474 3419 -1.6% 1.02x (?)
DropLastAnySeqCntRange 21 21 +0.0% 1.00x
DropLastAnySeqCntRangeLazy 21 21 +0.0% 1.00x
DropLastAnySequence 4612 4660 +1.0% 0.99x (?)
DropLastAnySequenceLazy 4793 4731 -1.3% 1.01x (?)
DropLastCountableRange 10 10 +0.0% 1.00x
DropLastCountableRangeLazy 10 10 +0.0% 1.00x
DropLastSequence 570 570 +0.0% 1.00x
DropLastSequenceLazy 571 570 -0.2% 1.00x (?)
DropWhileAnyCollection 89 89 +0.0% 1.00x
DropWhileAnyCollectionLazy 132 132 +0.0% 1.00x
DropWhileAnySeqCRangeIter 13191 13434 +1.8% 0.98x
DropWhileAnySeqCRangeIterLazy 132 132 +0.0% 1.00x
DropWhileAnySeqCntRange 85 85 +0.0% 1.00x
DropWhileAnySeqCntRangeLazy 132 132 +0.0% 1.00x
DropWhileAnySequenceLazy 1665 1664 -0.1% 1.00x
DropWhileArrayLazy 116 116 +0.0% 1.00x
DropWhileCountableRange 32 32 +0.0% 1.00x
DropWhileCountableRangeLazy 100 100 +0.0% 1.00x
DropWhileSequence 1204 1202 -0.2% 1.00x
DropWhileSequenceLazy 79 79 +0.0% 1.00x
EqualStringSubstring 388 387 -0.3% 1.00x (?)
EqualSubstringString 388 387 -0.3% 1.00x
EqualSubstringSubstring 388 387 -0.3% 1.00x (?)
EqualSubstringSubstringGenericEquatable 387 387 +0.0% 1.00x
ErrorHandling 2120 2225 +5.0% 0.95x (?)
ExclusivityGlobal 5 5 +0.0% 1.00x
ExclusivityIndependent 2 2 +0.0% 1.00x
FilterEvenUsingReduce 1189 1183 -0.5% 1.01x (?)
FilterEvenUsingReduceInto 134 136 +1.5% 0.99x (?)
FrequenciesUsingReduce 6100 6074 -0.4% 1.00x
FrequenciesUsingReduceInto 2851 2871 +0.7% 0.99x (?)
Hanoi 3256 3251 -0.2% 1.00x (?)
HashTest 1588 1598 +0.6% 0.99x (?)
Histogram 289 290 +0.3% 1.00x
Integrate 195 195 +0.0% 1.00x
IterateData 1274 1281 +0.5% 0.99x (?)
Join 340 333 -2.1% 1.02x (?)
LazilyFilteredArrayContains 34730 34709 -0.1% 1.00x (?)
LazilyFilteredArrays 59057 59636 +1.0% 0.99x (?)
LazilyFilteredRange 3667 3605 -1.7% 1.02x
LessSubstringSubstring 388 387 -0.3% 1.00x
LessSubstringSubstringGenericComparable 388 386 -0.5% 1.01x
LinkedList 6812 6815 +0.0% 1.00x
LuhnAlgoEager 526 525 -0.2% 1.00x (?)
LuhnAlgoLazy 524 526 +0.4% 1.00x (?)
MapReduce 357 358 +0.3% 1.00x (?)
MapReduceAnyCollection 335 333 -0.6% 1.01x (?)
MapReduceAnyCollectionShort 1834 1844 +0.5% 0.99x (?)
MapReduceClass 2726 2726 +0.0% 1.00x
MapReduceClassShort 4117 4124 +0.2% 1.00x (?)
MapReduceLazyCollection 12 12 +0.0% 1.00x
MapReduceLazyCollectionShort 30 30 +0.0% 1.00x
MapReduceLazySequence 78 77 -1.3% 1.01x
MapReduceSequence 421 428 +1.7% 0.98x (?)
MapReduceShort 1812 1816 +0.2% 1.00x
MapReduceShortString 19 19 +0.0% 1.00x
MapReduceString 73 73 +0.0% 1.00x
Memset 198 193 -2.5% 1.03x (?)
MonteCarloE 9279 9211 -0.7% 1.01x
MonteCarloPi 38553 38520 -0.1% 1.00x
NSDictionaryCastToSwift 4818 4880 +1.3% 0.99x (?)
NSError 275 275 +0.0% 1.00x
NSStringConversion 288 280 -2.8% 1.03x
NibbleSort 3556 3555 -0.0% 1.00x (?)
NopDeinit 19370 19367 -0.0% 1.00x (?)
ObjectAllocation 164 165 +0.6% 0.99x (?)
ObjectiveCBridgeFromNSArrayAnyObject 17761 18413 +3.7% 0.96x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToString 34902 34773 -0.4% 1.00x (?)
ObjectiveCBridgeFromNSSetAnyObject 52553 53416 +1.6% 0.98x (?)
ObjectiveCBridgeFromNSSetAnyObjectForced 3927 3745 -4.6% 1.05x (?)
ObjectiveCBridgeFromNSSetAnyObjectToString 63760 61301 -3.9% 1.04x
ObjectiveCBridgeFromNSString 1192 1184 -0.7% 1.01x (?)
ObjectiveCBridgeFromNSStringForced 2149 2154 +0.2% 1.00x (?)
ObjectiveCBridgeStubDataAppend 3537 3533 -0.1% 1.00x (?)
ObjectiveCBridgeStubDateMutation 231 231 +0.0% 1.00x
ObjectiveCBridgeStubFromArrayOfNSString 24486 23577 -3.7% 1.04x (?)
ObjectiveCBridgeStubFromNSDate 3726 3728 +0.1% 1.00x (?)
ObjectiveCBridgeStubFromNSString 755 737 -2.4% 1.02x
ObjectiveCBridgeStubFromNSStringRef 139 139 +0.0% 1.00x
ObjectiveCBridgeStubNSDataAppend 2250 2226 -1.1% 1.01x (?)
ObjectiveCBridgeStubToArrayOfNSString 26539 26523 -0.1% 1.00x (?)
ObjectiveCBridgeStubToNSDate 14405 14135 -1.9% 1.02x (?)
ObjectiveCBridgeStubToNSDateRef 3061 3097 +1.2% 0.99x (?)
ObjectiveCBridgeStubToNSString 1406 1397 -0.6% 1.01x (?)
ObjectiveCBridgeStubToNSStringRef 101 101 +0.0% 1.00x
ObjectiveCBridgeStubURLAppendPath 292399 293505 +0.4% 1.00x (?)
ObjectiveCBridgeStubURLAppendPathRef 303038 297838 -1.7% 1.02x
ObjectiveCBridgeToNSArray 26645 27342 +2.6% 0.97x
ObjectiveCBridgeToNSDictionary 49082 48741 -0.7% 1.01x (?)
ObjectiveCBridgeToNSString 1190 1199 +0.8% 0.99x
ObserverClosure 1928 1926 -0.1% 1.00x
ObserverForwarderStruct 846 845 -0.1% 1.00x (?)
ObserverPartiallyAppliedMethod 3344 3340 -0.1% 1.00x (?)
ObserverUnappliedMethod 2087 2080 -0.3% 1.00x (?)
OpenClose 236 233 -1.3% 1.01x
PartialApplyDynamicType 0 0 +0.0% 1.00x
Phonebook 3695 3694 -0.0% 1.00x (?)
PointerArithmetics 30833 30844 +0.0% 1.00x
PolymorphicCalls 22 22 +0.0% 1.00x
PopFrontArray 1736 1736 +0.0% 1.00x
PopFrontArrayGeneric 1758 1758 +0.0% 1.00x
PopFrontUnsafePointer 8428 8437 +0.1% 1.00x (?)
PrefixAnyCollection 68 68 +0.0% 1.00x
PrefixAnyCollectionLazy 59019 58830 -0.3% 1.00x (?)
PrefixAnySeqCRangeIter 12644 12761 +0.9% 0.99x
PrefixAnySeqCRangeIterLazy 12646 12743 +0.8% 0.99x
PrefixAnySeqCntRange 64 64 +0.0% 1.00x
PrefixAnySeqCntRangeLazy 64 64 +0.0% 1.00x
PrefixAnySequence 3391 3550 +4.7% 0.96x
PrefixAnySequenceLazy 3390 3548 +4.7% 0.96x
PrefixArray 31 31 +0.0% 1.00x
PrefixArrayLazy 31 31 +0.0% 1.00x
PrefixCountableRange 31 31 +0.0% 1.00x
PrefixCountableRangeLazy 31 31 +0.0% 1.00x
PrefixSequence 1189 1189 +0.0% 1.00x
PrefixSequenceLazy 1269 1268 -0.1% 1.00x (?)
PrefixWhileAnyCollection 131 131 +0.0% 1.00x
PrefixWhileAnyCollectionLazy 96 95 -1.0% 1.01x
PrefixWhileAnySeqCRangeIter 8410 8523 +1.3% 0.99x
PrefixWhileAnySeqCRangeIterLazy 95 95 +0.0% 1.00x
PrefixWhileAnySeqCntRange 127 127 +0.0% 1.00x
PrefixWhileAnySeqCntRangeLazy 95 95 +0.0% 1.00x
PrefixWhileAnySequence 9429 9632 +2.2% 0.98x
PrefixWhileAnySequenceLazy 1249 1249 +0.0% 1.00x
PrefixWhileArray 94 94 +0.0% 1.00x
PrefixWhileArrayLazy 63 63 +0.0% 1.00x
PrefixWhileCountableRange 41 41 +0.0% 1.00x
PrefixWhileCountableRangeLazy 31 31 +0.0% 1.00x
PrefixWhileSequence 323 320 -0.9% 1.01x
PrefixWhileSequenceLazy 47 47 +0.0% 1.00x
Prims 674 681 +1.0% 0.99x (?)
PrimsSplit 677 684 +1.0% 0.99x (?)
RC4 151 151 +0.0% 1.00x
RGBHistogram 2697 2719 +0.8% 0.99x (?)
RGBHistogramOfObjects 21449 21392 -0.3% 1.00x (?)
RangeAssignment 317 318 +0.3% 1.00x (?)
RangeIterationSigned 154 154 +0.0% 1.00x
RangeIterationSigned64 179 179 +0.0% 1.00x
RangeIterationUnsigned 179 179 +0.0% 1.00x
RangeReplaceableCollectionPlusDefault 882 884 +0.2% 1.00x (?)
RecursiveOwnedParameter 2133 2132 -0.0% 1.00x (?)
ReversedArray 51 51 +0.0% 1.00x
ReversedBidirectional 13761 13820 +0.4% 1.00x
ReversedDictionary 97 99 +2.1% 0.98x (?)
RomanNumbers 102229 101681 -0.5% 1.01x (?)
SetExclusiveOr 3157 3163 +0.2% 1.00x (?)
SetExclusiveOr_OfObjects 7948 7962 +0.2% 1.00x (?)
SetIntersect 291 292 +0.3% 1.00x (?)
SetIntersect_OfObjects 1604 1592 -0.7% 1.01x
SetIsSubsetOf 267 268 +0.4% 1.00x
SetIsSubsetOf_OfObjects 326 326 +0.0% 1.00x
SetUnion 2825 2856 +1.1% 0.99x
SetUnion_OfObjects 6512 6574 +1.0% 0.99x
SevenBoom 1381 1396 +1.1% 0.99x (?)
Sim2DArray 368 369 +0.3% 1.00x
SortLargeExistentials 6383 6336 -0.7% 1.01x
SortLettersInPlace 1036 1040 +0.4% 1.00x (?)
SortSortedStrings 1086 1083 -0.3% 1.00x
SortStrings 1895 1895 +0.0% 1.00x
SortStringsUnicode 14009 13990 -0.1% 1.00x (?)
StackPromo 19751 19968 +1.1% 0.99x (?)
StaticArray 5 5 +0.0% 1.00x
StrComplexWalk 1406 1405 -0.1% 1.00x
StrToInt 1976 1935 -2.1% 1.02x
StringAdder 3837 3857 +0.5% 0.99x
StringBuilder 1290 1299 +0.7% 0.99x (?)
StringBuilderLong 979 979 +0.0% 1.00x
StringComparison_abnormal 778 773 -0.6% 1.01x (?)
StringComparison_ascii 889 890 +0.1% 1.00x
StringComparison_emoji 2300 2289 -0.5% 1.00x (?)
StringComparison_fastPrenormal 7798 7808 +0.1% 1.00x (?)
StringComparison_latin1 5409 5396 -0.2% 1.00x (?)
StringComparison_longSharedPrefix 10334 10326 -0.1% 1.00x (?)
StringComparison_nonBMPSlowestPrenormal 4195 4184 -0.3% 1.00x (?)
StringComparison_slowerPrenormal 3759 3744 -0.4% 1.00x
StringComparison_zalgo 1562 1551 -0.7% 1.01x
StringEdits 109350 106928 -2.2% 1.02x (?)
StringEnumRawValueInitialization 900 877 -2.6% 1.03x
StringEqualPointerComparison 257 257 +0.0% 1.00x
StringFromLongWholeSubstring 18 18 +0.0% 1.00x
StringFromLongWholeSubstringGeneric 9 9 +0.0% 1.00x
StringHasPrefixAscii 1464 1464 +0.0% 1.00x
StringHasPrefixUnicode 25540 25291 -1.0% 1.01x (?)
StringHasSuffixAscii 1567 1567 +0.0% 1.00x
StringHasSuffixUnicode 76844 76557 -0.4% 1.00x
StringInterpolation 8386 8485 +1.2% 0.99x (?)
StringMatch 6769 6543 -3.3% 1.03x
StringRemoveDupes 1073 1088 +1.4% 0.99x
StringUTF16Builder 2164 2188 +1.1% 0.99x (?)
StringWalk 1459 1460 +0.1% 1.00x (?)
StringWithCString 37985 37936 -0.1% 1.00x (?)
StringWordBuilder 1597 1603 +0.4% 1.00x (?)
StringWordBuilderReservingCapacity 1233 1236 +0.2% 1.00x (?)
SubstringComparable 1906 1897 -0.5% 1.00x (?)
SubstringEqualString 1905 1903 -0.1% 1.00x (?)
SubstringEquatable 2868 2871 +0.1% 1.00x (?)
SubstringFromLongString 9 9 +0.0% 1.00x
SubstringFromLongStringGeneric 71 71 +0.0% 1.00x
SuffixAnyCollection 25 25 +0.0% 1.00x
SuffixAnyCollectionLazy 19818 20193 +1.9% 0.98x (?)
SuffixAnySeqCRangeIter 3483 3552 +2.0% 0.98x
SuffixAnySeqCRangeIterLazy 3443 3485 +1.2% 0.99x (?)
SuffixAnySeqCntRange 21 21 +0.0% 1.00x
SuffixAnySeqCntRangeLazy 21 21 +0.0% 1.00x
SuffixAnySequence 4590 4624 +0.7% 0.99x
SuffixAnySequenceLazy 4663 4670 +0.2% 1.00x (?)
SuffixCountableRange 10 10 +0.0% 1.00x
SuffixCountableRangeLazy 10 10 +0.0% 1.00x
SuffixSequence 3383 3372 -0.3% 1.00x (?)
SuffixSequenceLazy 3413 3385 -0.8% 1.01x
SumUsingReduce 91 91 +0.0% 1.00x
SumUsingReduceInto 91 91 +0.0% 1.00x
SuperChars 37035 38943 +5.2% 0.95x
TwoSum 887 890 +0.3% 1.00x (?)
TypeFlood 0 0 +0.0% 1.00x
UTF8Decode 286 286 +0.0% 1.00x
Walsh 375 378 +0.8% 0.99x
WordCountHistogramASCII 7340 7353 +0.2% 1.00x (?)
WordCountHistogramUTF16 47684 47815 +0.3% 1.00x (?)
WordCountUniqueASCII 1633 1649 +1.0% 0.99x
WordCountUniqueUTF16 20257 20651 +1.9% 0.98x (?)
WordSplitASCII 19082 19327 +1.3% 0.99x
WordSplitUTF16 19838 19940 +0.5% 0.99x (?)
XorLoop 335 336 +0.3% 1.00x

Unoptimized (Onone)

Regression (24)
TEST OLD NEW DELTA SPEEDUP
CharIteration_chinese_unicodeScalars 104252 138532 +32.9% 0.75x
CharIteration_korean_unicodeScalars_Backwards 256203 313377 +22.3% 0.82x
CharIteration_chinese_unicodeScalars_Backwards 198235 236462 +19.3% 0.84x (?)
CharIteration_ascii_unicodeScalars_Backwards 262374 296813 +13.1% 0.88x (?)
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 46852 52751 +12.6% 0.89x (?)
CharIteration_punctuated_unicodeScalars_Backwards 59963 66922 +11.6% 0.90x (?)
CharIndexing_chinese_unicodeScalars_Backwards 289454 321058 +10.9% 0.90x (?)
CharIndexing_japanese_unicodeScalars 425080 471011 +10.8% 0.90x (?)
NSDictionaryCastToSwift 5816 6443 +10.8% 0.90x (?)
CharIndexing_tweet_unicodeScalars_Backwards 772944 847586 +9.7% 0.91x (?)
CharIteration_utf16_unicodeScalars_Backwards 223774 243457 +8.8% 0.92x
DropFirstArrayLazy 23129 25102 +8.5% 0.92x
CharIndexing_korean_unicodeScalars 342838 370909 +8.2% 0.92x (?)
PrefixArrayLazy 23147 25038 +8.2% 0.92x
CharIndexing_ascii_unicodeScalars_Backwards 383926 411840 +7.3% 0.93x (?)
CharIndexing_korean_unicodeScalars_Backwards 371653 398549 +7.2% 0.93x (?)
CharIndexing_russian_unicodeScalars 298586 319844 +7.1% 0.93x (?)
CharIndexing_japanese_unicodeScalars_Backwards 468043 501208 +7.1% 0.93x (?)
StringInterpolation 12597 13480 +7.0% 0.93x (?)
ObjectiveCBridgeStubURLAppendPathRef 304025 325159 +7.0% 0.94x
CharIndexing_utf16_unicodeScalars 290635 309194 +6.4% 0.94x (?)
COWTree 9764 10329 +5.8% 0.95x (?)
StringWithCString 33526 35386 +5.5% 0.95x
ObjectiveCBridgeFromNSArrayAnyObjectForced 7496 7897 +5.3% 0.95x (?)
Improvement (12)
TEST OLD NEW DELTA SPEEDUP
ObjectiveCBridgeStubFromArrayOfNSString 29971 24702 -17.6% 1.21x
ArrayOfPOD 752 676 -10.1% 1.11x
StrToInt 58840 53282 -9.4% 1.10x
ObjectiveCBridgeFromNSSetAnyObjectForced 6385 5793 -9.3% 1.10x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 37252 34130 -8.4% 1.09x
ObjectiveCBridgeFromNSDictionaryAnyObject 122379 115356 -5.7% 1.06x
SubstringEquatable 7651 7219 -5.6% 1.06x (?)
CharIndexing_tweet_unicodeScalars 763216 721800 -5.4% 1.06x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToString 38254 36311 -5.1% 1.05x (?)
Calculator 1594 1516 -4.9% 1.05x (?)
ObjectiveCBridgeStubToNSDate 14442 13741 -4.9% 1.05x (?)
ObjectiveCBridgeStubDataAppend 4215 4011 -4.8% 1.05x
No Changes (322)
TEST OLD NEW DELTA SPEEDUP
AngryPhonebook 4553 4581 +0.6% 0.99x (?)
AnyHashableWithAClass 76848 77504 +0.9% 0.99x (?)
Array2D 568773 568255 -0.1% 1.00x (?)
ArrayAppend 4174 4176 +0.0% 1.00x (?)
ArrayAppendArrayOfInt 724 725 +0.1% 1.00x
ArrayAppendAscii 36072 36033 -0.1% 1.00x (?)
ArrayAppendFromGeneric 726 728 +0.3% 1.00x (?)
ArrayAppendGenericStructs 1270 1268 -0.2% 1.00x (?)
ArrayAppendLatin1 56963 56867 -0.2% 1.00x
ArrayAppendLazyMap 151465 150562 -0.6% 1.01x
ArrayAppendOptionals 1272 1270 -0.2% 1.00x (?)
ArrayAppendRepeatCol 149569 152696 +2.1% 0.98x
ArrayAppendReserved 3838 3840 +0.1% 1.00x (?)
ArrayAppendSequence 126026 126618 +0.5% 1.00x
ArrayAppendStrings 13792 13796 +0.0% 1.00x (?)
ArrayAppendToFromGeneric 725 727 +0.3% 1.00x
ArrayAppendToGeneric 731 730 -0.1% 1.00x
ArrayAppendUTF16 56651 56869 +0.4% 1.00x (?)
ArrayInClass 5560 5553 -0.1% 1.00x
ArrayLiteral 1595 1594 -0.1% 1.00x (?)
ArrayOfGenericPOD2 1063 1019 -4.1% 1.04x
ArrayOfGenericRef 9194 8978 -2.3% 1.02x (?)
ArrayOfRef 8375 8365 -0.1% 1.00x (?)
ArrayPlusEqualArrayOfInt 724 724 +0.0% 1.00x
ArrayPlusEqualFiveElementCollection 209230 209307 +0.0% 1.00x (?)
ArrayPlusEqualSingleElementCollection 206332 206173 -0.1% 1.00x (?)
ArrayPlusEqualThreeElements 8192 8238 +0.6% 0.99x (?)
ArraySubscript 73029 75450 +3.3% 0.97x
ArrayValueProp 3250 3241 -0.3% 1.00x (?)
ArrayValueProp2 14330 14579 +1.7% 0.98x (?)
ArrayValueProp3 3702 3710 +0.2% 1.00x (?)
ArrayValueProp4 3683 3656 -0.7% 1.01x (?)
BinaryFloatingPointConversionFromBinaryInteger 5482 5426 -1.0% 1.01x (?)
BitCount 1980 1984 +0.2% 1.00x
ByteSwap 3534 3506 -0.8% 1.01x (?)
CSVParsing 2181548 2160470 -1.0% 1.01x
CSVParsingAlt 1180308 1200469 +1.7% 0.98x (?)
CSVParsingAltIndices 2249625 2271506 +1.0% 0.99x
CStringLongAscii 4132 4281 +3.6% 0.97x
CStringLongNonAscii 1940 1863 -4.0% 1.04x
CStringShortAscii 6875 6917 +0.6% 0.99x (?)
CaptureProp 230583 228530 -0.9% 1.01x (?)
CharIndexing_ascii_unicodeScalars 379034 361085 -4.7% 1.05x (?)
CharIndexing_chinese_unicodeScalars 292596 284112 -2.9% 1.03x (?)
CharIndexing_punctuatedJapanese_unicodeScalars 67194 65780 -2.1% 1.02x (?)
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 74956 73256 -2.3% 1.02x (?)
CharIndexing_punctuated_unicodeScalars 80549 84484 +4.9% 0.95x (?)
CharIndexing_punctuated_unicodeScalars_Backwards 90125 93844 +4.1% 0.96x (?)
CharIndexing_russian_unicodeScalars_Backwards 322996 339755 +5.2% 0.95x (?)
CharIndexing_utf16_unicodeScalars_Backwards 329491 315562 -4.2% 1.04x (?)
CharIteration_ascii_unicodeScalars 137848 140416 +1.9% 0.98x (?)
CharIteration_japanese_unicodeScalars 165958 166047 +0.1% 1.00x (?)
CharIteration_japanese_unicodeScalars_Backwards 347786 350447 +0.8% 0.99x (?)
CharIteration_korean_unicodeScalars 133369 134978 +1.2% 0.99x (?)
CharIteration_punctuatedJapanese_unicodeScalars 24652 24786 +0.5% 0.99x (?)
CharIteration_punctuated_unicodeScalars 31077 31094 +0.1% 1.00x (?)
CharIteration_russian_unicodeScalars 114498 115947 +1.3% 0.99x (?)
CharIteration_russian_unicodeScalars_Backwards 247238 244200 -1.2% 1.01x (?)
CharIteration_tweet_unicodeScalars 271289 281920 +3.9% 0.96x
CharIteration_tweet_unicodeScalars_Backwards 592806 599207 +1.1% 0.99x (?)
CharIteration_utf16_unicodeScalars 117376 116061 -1.1% 1.01x (?)
CharacterLiteralsLarge 5389 5408 +0.4% 1.00x
CharacterLiteralsSmall 635 641 +0.9% 0.99x
CharacterPropertiesFetch 5089 4983 -2.1% 1.02x (?)
CharacterPropertiesPrecomputed 3816 3850 +0.9% 0.99x (?)
CharacterPropertiesStashed 2122 2080 -2.0% 1.02x (?)
CharacterPropertiesStashedMemo 4500 4490 -0.2% 1.00x (?)
Chars 35501 35478 -0.1% 1.00x (?)
ClassArrayGetter 883 886 +0.3% 1.00x
Combos 1861 1810 -2.7% 1.03x
DictOfArraysToArrayOfDicts 3058 3023 -1.1% 1.01x (?)
Dictionary 2393 2300 -3.9% 1.04x
Dictionary2 2536 2545 +0.4% 1.00x (?)
Dictionary2OfObjects 4993 4961 -0.6% 1.01x (?)
Dictionary3 1162 1134 -2.4% 1.02x
Dictionary3OfObjects 1992 1998 +0.3% 1.00x (?)
DictionaryBridge 1906 1974 +3.6% 0.97x (?)
DictionaryGroup 3786 3782 -0.1% 1.00x (?)
DictionaryGroupOfObjects 6670 6652 -0.3% 1.00x (?)
DictionaryLiteral 7769 7722 -0.6% 1.01x (?)
DictionaryOfObjects 5433 5504 +1.3% 0.99x (?)
DictionaryRemove 16662 16463 -1.2% 1.01x
DictionaryRemoveOfObjects 45981 45044 -2.0% 1.02x (?)
DictionarySubscriptDefaultMutation 1886 1909 +1.2% 0.99x (?)
DictionarySubscriptDefaultMutationArray 2121 2143 +1.0% 0.99x
DictionarySubscriptDefaultMutationArrayOfObjects 8099 8132 +0.4% 1.00x (?)
DictionarySubscriptDefaultMutationOfObjects 4987 5062 +1.5% 0.99x (?)
DictionarySwap 4729 4660 -1.5% 1.01x
DictionarySwapOfObjects 20875 21064 +0.9% 0.99x (?)
DoubleWidthDivision 21433 21761 +1.5% 0.98x
DropFirstAnyCollection 12266 12273 +0.1% 1.00x
DropFirstAnyCollectionLazy 96156 97253 +1.1% 0.99x (?)
DropFirstAnySeqCRangeIter 18822 18398 -2.3% 1.02x
DropFirstAnySeqCRangeIterLazy 18475 18345 -0.7% 1.01x
DropFirstAnySeqCntRange 12120 12264 +1.2% 0.99x
DropFirstAnySeqCntRangeLazy 12318 12476 +1.3% 0.99x
DropFirstAnySequence 9763 9829 +0.7% 0.99x
DropFirstAnySequenceLazy 9663 9843 +1.9% 0.98x
DropFirstArray 3467 3407 -1.7% 1.02x
DropFirstCountableRange 293 291 -0.7% 1.01x
DropFirstCountableRangeLazy 23040 23847 +3.5% 0.97x (?)
DropFirstSequence 9419 9463 +0.5% 1.00x
DropFirstSequenceLazy 9447 9549 +1.1% 0.99x
DropLastAnyCollection 4073 4132 +1.4% 0.99x
DropLastAnyCollectionLazy 32298 31786 -1.6% 1.02x (?)
DropLastAnySeqCRangeIter 33809 33681 -0.4% 1.00x
DropLastAnySeqCRangeIterLazy 33667 33394 -0.8% 1.01x
DropLastAnySeqCntRange 4097 4090 -0.2% 1.00x (?)
DropLastAnySeqCntRangeLazy 4076 4160 +2.1% 0.98x
DropLastAnySequence 25971 26144 +0.7% 0.99x
DropLastAnySequenceLazy 26041 25877 -0.6% 1.01x
DropLastCountableRange 101 100 -1.0% 1.01x
DropLastCountableRangeLazy 7701 7962 +3.4% 0.97x
DropLastSequence 25866 25947 +0.3% 1.00x (?)
DropLastSequenceLazy 26040 25860 -0.7% 1.01x
DropWhileAnyCollection 15671 15810 +0.9% 0.99x
DropWhileAnyCollectionLazy 17089 16842 -1.4% 1.01x
DropWhileAnySeqCRangeIter 19957 19626 -1.7% 1.02x (?)
DropWhileAnySeqCRangeIterLazy 16954 16849 -0.6% 1.01x (?)
DropWhileAnySeqCntRange 15591 15830 +1.5% 0.98x
DropWhileAnySeqCntRangeLazy 17026 16871 -0.9% 1.01x
DropWhileAnySequence 11034 11271 +2.1% 0.98x
DropWhileAnySequenceLazy 9025 9365 +3.8% 0.96x
DropWhileArrayLazy 12661 12265 -3.1% 1.03x
DropWhileCountableRange 3762 3762 +0.0% 1.00x
DropWhileCountableRangeLazy 16781 16692 -0.5% 1.01x
DropWhileSequence 10745 10833 +0.8% 0.99x
DropWhileSequenceLazy 8738 8874 +1.6% 0.98x
EqualStringSubstring 427 427 +0.0% 1.00x
EqualSubstringString 430 428 -0.5% 1.00x
EqualSubstringSubstring 428 428 +0.0% 1.00x
EqualSubstringSubstringGenericEquatable 435 434 -0.2% 1.00x (?)
ErrorHandling 6573 6790 +3.3% 0.97x (?)
ExclusivityGlobal 159 159 +0.0% 1.00x
ExclusivityIndependent 61 60 -1.6% 1.02x
FilterEvenUsingReduce 3343 3348 +0.1% 1.00x (?)
FilterEvenUsingReduceInto 1792 1790 -0.1% 1.00x (?)
FrequenciesUsingReduce 9402 9493 +1.0% 0.99x (?)
FrequenciesUsingReduceInto 4821 4803 -0.4% 1.00x (?)
Hanoi 18212 18219 +0.0% 1.00x (?)
HashTest 14749 14653 -0.7% 1.01x (?)
Histogram 5823 5956 +2.3% 0.98x
Integrate 740 739 -0.1% 1.00x (?)
IterateData 7027 7065 +0.5% 0.99x
Join 1002 994 -0.8% 1.01x (?)
LazilyFilteredArrayContains 694913 696773 +0.3% 1.00x
LazilyFilteredArrays 1320954 1306045 -1.1% 1.01x
LazilyFilteredRange 417480 418679 +0.3% 1.00x
LessSubstringSubstring 428 428 +0.0% 1.00x
LessSubstringSubstringGenericComparable 433 432 -0.2% 1.00x (?)
LinkedList 28999 28901 -0.3% 1.00x
LuhnAlgoEager 4584 4545 -0.9% 1.01x (?)
LuhnAlgoLazy 4761 4678 -1.7% 1.02x (?)
MapReduce 24916 24658 -1.0% 1.01x
MapReduceAnyCollection 24961 24552 -1.6% 1.02x
MapReduceAnyCollectionShort 35501 34999 -1.4% 1.01x (?)
MapReduceClass 28912 28797 -0.4% 1.00x (?)
MapReduceClassShort 38250 38979 +1.9% 0.98x
MapReduceLazyCollection 20895 21430 +2.6% 0.98x
MapReduceLazyCollectionShort 30061 30951 +3.0% 0.97x
MapReduceLazySequence 16491 16151 -2.1% 1.02x
MapReduceSequence 27564 27829 +1.0% 0.99x
MapReduceShort 35677 35136 -1.5% 1.02x (?)
MapReduceShortString 211 217 +2.8% 0.97x (?)
MapReduceString 1736 1729 -0.4% 1.00x (?)
Memset 40109 40148 +0.1% 1.00x (?)
MonteCarloE 814253 813157 -0.1% 1.00x (?)
MonteCarloPi 3487063 3461839 -0.7% 1.01x (?)
NSError 662 680 +2.7% 0.97x (?)
NSStringConversion 328 318 -3.0% 1.03x
NibbleSort 271583 267263 -1.6% 1.02x
NopDeinit 145453 145539 +0.1% 1.00x (?)
ObjectAllocation 1202 1205 +0.2% 1.00x (?)
ObjectiveCBridgeFromNSArrayAnyObject 20707 20599 -0.5% 1.01x (?)
ObjectiveCBridgeFromNSSetAnyObject 58424 57685 -1.3% 1.01x (?)
ObjectiveCBridgeFromNSSetAnyObjectToString 63636 66775 +4.9% 0.95x (?)
ObjectiveCBridgeFromNSString 2877 2839 -1.3% 1.01x (?)
ObjectiveCBridgeFromNSStringForced 2449 2448 -0.0% 1.00x (?)
ObjectiveCBridgeStubDateMutation 566 566 +0.0% 1.00x
ObjectiveCBridgeStubFromNSDate 4437 4435 -0.0% 1.00x (?)
ObjectiveCBridgeStubFromNSString 801 805 +0.5% 1.00x
ObjectiveCBridgeStubFromNSStringRef 181 181 +0.0% 1.00x
ObjectiveCBridgeStubNSDataAppend 2749 2693 -2.0% 1.02x
ObjectiveCBridgeStubNSDateMutationRef 15048 14552 -3.3% 1.03x (?)
ObjectiveCBridgeStubToArrayOfNSString 26447 26771 +1.2% 0.99x (?)
ObjectiveCBridgeStubToNSDateRef 3105 3100 -0.2% 1.00x (?)
ObjectiveCBridgeStubToNSString 1435 1426 -0.6% 1.01x (?)
ObjectiveCBridgeStubToNSStringRef 142 143 +0.7% 0.99x (?)
ObjectiveCBridgeStubURLAppendPath 307259 293534 -4.5% 1.05x (?)
ObjectiveCBridgeToNSArray 26516 26800 +1.1% 0.99x (?)
ObjectiveCBridgeToNSDictionary 49446 51135 +3.4% 0.97x (?)
ObjectiveCBridgeToNSSet 42257 42936 +1.6% 0.98x (?)
ObjectiveCBridgeToNSString 1213 1216 +0.2% 1.00x (?)
ObserverClosure 5699 5677 -0.4% 1.00x (?)
ObserverForwarderStruct 3922 3910 -0.3% 1.00x
ObserverPartiallyAppliedMethod 7026 7029 +0.0% 1.00x (?)
ObserverUnappliedMethod 7353 7406 +0.7% 0.99x
OpenClose 518 510 -1.5% 1.02x
PartialApplyDynamicType 36958 36755 -0.5% 1.01x (?)
Phonebook 18659 18624 -0.2% 1.00x
PointerArithmetics 107957 102853 -4.7% 1.05x
PolymorphicCalls 5635 5436 -3.5% 1.04x
PopFrontArray 4136 4129 -0.2% 1.00x
PopFrontArrayGeneric 5203 5274 +1.4% 0.99x
PopFrontUnsafePointer 10141 10126 -0.1% 1.00x (?)
PrefixAnyCollection 12186 12324 +1.1% 0.99x
PrefixAnyCollectionLazy 96574 95656 -1.0% 1.01x (?)
PrefixAnySeqCRangeIter 15104 14956 -1.0% 1.01x
PrefixAnySeqCRangeIterLazy 14978 14702 -1.8% 1.02x
PrefixAnySeqCntRange 12163 12255 +0.8% 0.99x
PrefixAnySeqCntRangeLazy 12232 12467 +1.9% 0.98x
PrefixAnySequence 8114 8220 +1.3% 0.99x
PrefixAnySequenceLazy 8137 8231 +1.2% 0.99x
PrefixArray 3501 3416 -2.4% 1.02x
PrefixCountableRange 292 292 +0.0% 1.00x
PrefixCountableRangeLazy 23033 23964 +4.0% 0.96x (?)
PrefixSequence 7822 7891 +0.9% 0.99x
PrefixSequenceLazy 7900 8031 +1.7% 0.98x
PrefixWhileAnyCollection 22319 22390 +0.3% 1.00x
PrefixWhileAnyCollectionLazy 14337 14043 -2.1% 1.02x
PrefixWhileAnySeqCRangeIter 29741 29625 -0.4% 1.00x (?)
PrefixWhileAnySeqCRangeIterLazy 14255 14168 -0.6% 1.01x
PrefixWhileAnySeqCntRange 22373 22698 +1.5% 0.99x
PrefixWhileAnySeqCntRangeLazy 14318 14072 -1.7% 1.02x
PrefixWhileAnySequence 23813 23861 +0.2% 1.00x (?)
PrefixWhileAnySequenceLazy 8229 8433 +2.5% 0.98x
PrefixWhileArray 10357 10358 +0.0% 1.00x (?)
PrefixWhileArrayLazy 11055 10712 -3.1% 1.03x
PrefixWhileCountableRange 10618 10548 -0.7% 1.01x
PrefixWhileCountableRangeLazy 14378 13911 -3.2% 1.03x
PrefixWhileSequence 23628 23672 +0.2% 1.00x (?)
PrefixWhileSequenceLazy 8019 8165 +1.8% 0.98x
Prims 8680 8706 +0.3% 1.00x (?)
PrimsSplit 8712 8680 -0.4% 1.00x (?)
RC4 15121 15090 -0.2% 1.00x (?)
RGBHistogram 23997 23988 -0.0% 1.00x (?)
RGBHistogramOfObjects 86397 86444 +0.1% 1.00x (?)
RangeAssignment 2404 2420 +0.7% 0.99x (?)
RangeIterationSigned 14989 14813 -1.2% 1.01x
RangeIterationSigned64 34807 35347 +1.6% 0.98x (?)
RangeIterationUnsigned 30897 32425 +4.9% 0.95x
RangeReplaceableCollectionPlusDefault 8270 7909 -4.4% 1.05x
RecursiveOwnedParameter 7117 7094 -0.3% 1.00x (?)
ReversedArray 11852 11823 -0.2% 1.00x
ReversedBidirectional 42605 42862 +0.6% 0.99x (?)
ReversedDictionary 20330 20382 +0.3% 1.00x (?)
RomanNumbers 1041280 1030675 -1.0% 1.01x
SetExclusiveOr 15568 15276 -1.9% 1.02x
SetExclusiveOr_OfObjects 37344 37599 +0.7% 0.99x (?)
SetIntersect 7305 7296 -0.1% 1.00x (?)
SetIntersect_OfObjects 10727 10840 +1.1% 0.99x (?)
SetIsSubsetOf 1216 1210 -0.5% 1.00x
SetIsSubsetOf_OfObjects 1403 1408 +0.4% 1.00x (?)
SetUnion 10733 10644 -0.8% 1.01x
SetUnion_OfObjects 26267 26322 +0.2% 1.00x (?)
SevenBoom 1517 1479 -2.5% 1.03x (?)
Sim2DArray 39149 39157 +0.0% 1.00x (?)
SortLargeExistentials 14175 14030 -1.0% 1.01x (?)
SortLettersInPlace 2552 2551 -0.0% 1.00x (?)
SortSortedStrings 1206 1202 -0.3% 1.00x (?)
SortStrings 2244 2246 +0.1% 1.00x
SortStringsUnicode 14766 14662 -0.7% 1.01x
StackPromo 81203 82140 +1.2% 0.99x (?)
StaticArray 2386 2375 -0.5% 1.00x (?)
StrComplexWalk 5981 5779 -3.4% 1.03x
StringAdder 4277 4258 -0.4% 1.00x (?)
StringBuilder 6079 6092 +0.2% 1.00x (?)
StringBuilderLong 2457 2423 -1.4% 1.01x (?)
StringComparison_abnormal 1319 1304 -1.1% 1.01x
StringComparison_ascii 8600 8777 +2.1% 0.98x
StringComparison_emoji 3449 3423 -0.8% 1.01x (?)
StringComparison_fastPrenormal 12044 12187 +1.2% 0.99x (?)
StringComparison_latin1 8573 8543 -0.3% 1.00x (?)
StringComparison_longSharedPrefix 11774 11728 -0.4% 1.00x
StringComparison_nonBMPSlowestPrenormal 6252 6204 -0.8% 1.01x (?)
StringComparison_slowerPrenormal 6167 6102 -1.1% 1.01x (?)
StringComparison_zalgo 2580 2557 -0.9% 1.01x (?)
StringEdits 304291 303188 -0.4% 1.00x (?)
StringEnumRawValueInitialization 19024 18938 -0.5% 1.00x (?)
StringEqualPointerComparison 3051 3053 +0.1% 1.00x (?)
StringFromLongWholeSubstring 20 20 +0.0% 1.00x
StringFromLongWholeSubstringGeneric 184 183 -0.5% 1.01x (?)
StringHasPrefixAscii 2857 2852 -0.2% 1.00x (?)
StringHasPrefixUnicode 27704 27746 +0.2% 1.00x
StringHasSuffixAscii 2826 2849 +0.8% 0.99x
StringHasSuffixUnicode 79083 79183 +0.1% 1.00x (?)
StringMatch 29128 29217 +0.3% 1.00x
StringRemoveDupes 1256 1259 +0.2% 1.00x (?)
StringUTF16Builder 6819 6870 +0.7% 0.99x (?)
StringWalk 11503 11124 -3.3% 1.03x
StringWordBuilder 2319 2227 -4.0% 1.04x
StringWordBuilderReservingCapacity 2033 1958 -3.7% 1.04x
SubstringComparable 3718 3718 +0.0% 1.00x
SubstringEqualString 3129 3250 +3.9% 0.96x
SubstringFromLongString 22 22 +0.0% 1.00x
SubstringFromLongStringGeneric 93 92 -1.1% 1.01x
SuffixAnyCollection 4096 4129 +0.8% 0.99x (?)
SuffixAnyCollectionLazy 30475 31868 +4.6% 0.96x
SuffixAnySeqCRangeIter 30186 30024 -0.5% 1.01x
SuffixAnySeqCRangeIterLazy 30099 29927 -0.6% 1.01x
SuffixAnySeqCntRange 4059 4095 +0.9% 0.99x (?)
SuffixAnySeqCntRangeLazy 4090 4143 +1.3% 0.99x
SuffixAnySequence 22564 22614 +0.2% 1.00x (?)
SuffixAnySequenceLazy 22560 22497 -0.3% 1.00x (?)
SuffixCountableRange 100 100 +0.0% 1.00x
SuffixCountableRangeLazy 7705 7959 +3.3% 0.97x
SuffixSequence 22506 22702 +0.9% 0.99x
SuffixSequenceLazy 22608 22519 -0.4% 1.00x
SumUsingReduce 153271 153850 +0.4% 1.00x
SumUsingReduceInto 150000 149762 -0.2% 1.00x
SuperChars 189145 193156 +2.1% 0.98x (?)
TwoSum 3571 3500 -2.0% 1.02x
TypeFlood 140 147 +5.0% 0.95x (?)
UTF8Decode 26883 26802 -0.3% 1.00x
Walsh 10781 10785 +0.0% 1.00x (?)
WordCountHistogramASCII 43542 43399 -0.3% 1.00x (?)
WordCountHistogramUTF16 91511 90696 -0.9% 1.01x (?)
WordCountUniqueASCII 7178 7149 -0.4% 1.00x (?)
WordCountUniqueUTF16 29117 30431 +4.5% 0.96x (?)
WordSplitASCII 22196 22568 +1.7% 0.98x
WordSplitUTF16 24228 24146 -0.3% 1.00x (?)
XorLoop 20959 20996 +0.2% 1.00x
Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 8-Core Intel Xeon E5
  Processor Speed: 3 GHz
  Number of Processors: 1
  Total Number of Cores: 8
  L2 Cache (per Core): 256 KB
  L3 Cache: 25 MB
  Memory: 64 GB

@mortenbekditlevsen
Copy link
Contributor Author

@xwu @lorentey
I removed the Slice conditional conformance.
What about ArraySlice? That implementation lives in the Arrays.swift.gyb along with conformance for Array and ContiguousArray.
Do you think conditional conformance for ArraySlice should be explicitly skipped in this gyb file?

@xwu
Copy link
Collaborator

xwu commented Feb 7, 2018

I think ArraySlice should be fine unless there’s still a plan to remove it in favor of Slice—which, is there?

@lorentey
Copy link
Member

lorentey commented Feb 9, 2018

I think the conclusion on swift-evolution was clear -- Slice should base its concept of equality on the equality of its contents, like all other collections in stdlib. It's OK to restore its conditional conformances.

@lorentey
Copy link
Member

lorentey commented Feb 9, 2018

@swift-ci please smoke test

Copy link
Collaborator

@xwu xwu left a comment

Choose a reason for hiding this comment

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

Looking good. One comment to silence a warning and one nit.

extension AnyCollection : Equatable where Element : Equatable {
@_inlineable // FIXME(sil-serialize-all)
public static func ==(lhs: AnyCollection<Element>, rhs: AnyCollection<Element>) -> Bool {
let lhsCount = lhs.count
Copy link
Collaborator

Choose a reason for hiding this comment

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

Delete this line.

if lhs.count != rhs.count {
return false
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: unnecessary empty line.

@lorentey
Copy link
Member

lorentey commented Feb 9, 2018

There are three failures:

  1. The AnyHashableDiagnostics test failure is expected, since Array and Dictionary now implement Hashable. We should update the test to use Array<NotHashable> and Dictionary<Int, NotHashable>, where NotHashable is a dummy custom type. Update: We should implement custom AnyHashable representations for these types and remove the test.

  2. The ClangImporter/objc_bridging_generics.swift failure looks more interesting:

    @interface ObjCBridgeNonconforming
    @property NSSet<NSDictionary<NSString *, id> *> * _Nonnull foo;
    @end
    
    /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/test/ClangImporter/objc_bridging_generics.swift:399:43: error: incorrect message found
      let _: Int = bnc.foo // expected-error{{cannot convert value of type 'Set<AnyHashable>' to specified type 'Int'}}
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                              cannot convert value of type 'Set<[String : Any]>' to specified type 'Int'
    

    I don't think ObjCBridgeNonconforming.foo should be imported with type Set<[String: Any]>, since [String: Any] isn't Hashable, even with this PR. cc @DougGregor

  3. The package manager tests fail on Linux because swiftpm comes with its own DictionaryLiteral.== implementation. That definition should be deprecated when this lands. @aciidb0mb3r, how should we coordinate this?

@xwu
Copy link
Collaborator

xwu commented Feb 9, 2018

The third failure you list actually portends a bigger issue, I think. These conditional conformances should not be source-breaking, but this one is because static == isn’t being shadowed or overridden—which it absolutely should be.

IMO, making tests pass by deleting the code in SwiftPM just punts the issue down the road and affects end users; hopefully, we can actually solve the problem.

Thinko; both conflicting implementations are on the concrete type. The only way we can make it not source breaking is to use @_implements—probably too elaborate. Deleting the SwiftPM code would be reasonable then.

@lorentey
Copy link
Member

lorentey commented Feb 9, 2018

We can add appropriate @available attributes to the conformances and the new ==/hashValue implementations so that they don't get enabled in old language modes.

(I think this can be done in a followup PR.) Edit: nope, we should not break swiftpm

@aciidgh
Copy link
Contributor

aciidgh commented Feb 9, 2018

I don't think we should change SwiftPM code in a way that it will stop working with older version of (trunk) compiler. Unless it is absolutely necessary to land this PR with broken source compatibility story, we shouldn't change SwiftPM.

@xwu
Copy link
Collaborator

xwu commented Feb 9, 2018

A pragmatic solution would be to leave DictionaryLiteral alone; it’s on thin ice as far as its future and we don’t need to give it all the bells and whistles; I’d hate for that to hold up conditional Hashable conformance for Array.

@lorentey
Copy link
Member

lorentey commented Feb 9, 2018

I expect swiftpm is not the only codebase out there that defined ==/hashValue for some of these types, and DictionaryLiteral is probably not even the most problematic.

We don't need to remove anything; we just need to add @available(swift, introduced: 4.1) to all of these.

@lorentey
Copy link
Member

lorentey commented Feb 9, 2018

@aciidb0mb3r I believe if you add @available(swift, deprecated: x.y) to the definition of DictionaryLiteral.== in swiftpm, then the code will keep working with old & new compilers. (Luckily, the two definitions are equivalent.)

@lorentey
Copy link
Member

lorentey commented Feb 9, 2018

@swift-ci please test source compatibility

@xwu
Copy link
Collaborator

xwu commented Feb 9, 2018

@swift-ci Please test source compatibility

@mortenbekditlevsen
Copy link
Contributor Author

Does anyone have any pointers to get me started on adding AnyHashable for bridging dictionary and array types from Objective-C as stated in the failing test:

// If this test fails, the following types started to conditionally conform to
// `Hashable`.  When that happens, please add a custom `AnyHashable`
// representation to corresponding Objective-C types.

func isHashable<T : Hashable>(_: T.Type) {}

isHashable(Int.self) // no-error // Test that `isHashable(_:)` works.

isHashable(Array<Int>.self) // expected-error {{'Array<Int>' does not conform to expected type 'Hashable'}}
isHashable(Dictionary<Int, Int>.self) // expected-error {{'Dictionary<Int, Int>' does not conform to expected type 'Hashable'}}

Any help would be greatly appreciated. :-)

@lorentey
Copy link
Member

We'll need to implement _HasCustomAnyHashableRepresentation for NSArray and NSDictionary in the Foundation overlay. NSSet is a good example of how to do this; Set already implemented Hashable, so it had a custom AnyHashable representation.

@lorentey lorentey changed the base branch from master to conditional-hashable February 10, 2018 18:28
@lorentey
Copy link
Member

I created a new branch for this work so that we can collaborate on getting the tests fixed and landing this soon. I'll squash and merge this PR to that branch, and I'll open a new PR to continue tracking development.

@lorentey lorentey merged commit d80bea6 into swiftlang:conditional-hashable Feb 10, 2018
@lorentey
Copy link
Member

lorentey commented Feb 10, 2018

PR #14527 is now open; development continues there.

lorentey pushed a commit to lorentey/swift that referenced this pull request Mar 23, 2018
…d Array types. (swiftlang#14247)

* Add conditional Hashable conformance to Optional, Dictionary, Array, ArraySlice and ContiguousArray

* Modified hashValue implementations
The hashValues are now calculated similar to the automatically synthesized values when conforming to Hashable.
This entails using _combineHashValues as values of the collections are iterated - as well as calling _mixInt before returning the hash.

* Added FIXMEs as suggested by Max Moiseev

* Use checkHashable to check Hashable conformance

* Use 2 space indentation

* Hashing of Dictionary is now independent of traversal order

* Added a test to proof failure of (previous) wrong implementation of Dictionary hashValue. Unfortunately it does not work.

* Removed '_mixInt' from 'hashValue' implementation of Optional and Array types based on recommendations from lorentey

* Another attempt at detecting bad hashing due to traversal order

* Dictionary Hashable validation tests now detect bad hashing due to dependence on traversal order

* Removed superfluous initial _mixInt call for Dictionary hashValue implementation.

* Add more elements to dictionary in test to increase the number of possible permutations - making it more likely to detect order-dependent hashes

* Added Hashable conformance to CollectionOfOne, EmptyCollection and Range types

* Fix indirect referral to the only member of CollectionOfOne

* Re-added Hashable conformance to Range after merge from master

* Change hashValue based on comment from @lorentey

* Remove tests for conditional Hashable conformance for Range types. This is left for a followup PR

* Added tests for CollectionOfOne and EmptyCollection

* Added conditional conformance fo Equatable and Hashable for DictionaryLiteral. Added tests too.

* Added conditional Equatable and Hashable conformance to Slice

* Use 'elementsEqual' for Slice equality operator

* Fixed documentation comment and indentation

* Fix DictionaryLiteral equality implementation

* Revert "Fix DictionaryLiteral equality implementation"

This reverts commit 7fc1510.

* Fix DictionaryLiteral equality implementation

* Use equalElements(:by:) to compare DictionaryLiteral elements

* Added conditional conformance for Equatable and Hashable to AnyCollection

* Revert "Use 'elementsEqual' for Slice equality operator"

This reverts commit 0ba2278.

* Revert "Added conditional Equatable and Hashable conformance to Slice"

This reverts commit 84f9934.

* Added conditional conformance for Equatable and Hashable for ClosedRange
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.

9 participants