[stdlib] Rewriting native hashed collection indices (rebased)

This is a rebase of #3046. The majority of the work here is @austinzheng's, and can be found in the first commit. However the codebase had changed enough that the patch had to be significantly modified. I'm mostly relying on the test suite to verify that there weren't errors in resolving all the conflicts.
Changes:
- Native dictionary and set indices no longer hold references to storage
- Cocoa-based dictionary and set indices no longer hold references to storage
- Removed double indirection trick from hashed collections
- Rewrote storage types to reflect simpler model
- Updated unit tests

As a consequence of removing the double indirection, Dictionary -> NSDictionary now always requires an allocation for a wrapper class. This means that if you bridge a Dictionary multiple times, the resultant NSDictionaries will not be referentially identical. I briefly investigated trying to restore the previous behaviour; or at least perform the optimizations that Array does to make the verbatim-bridgeable case free.
Discussion with @dabrahams lead to the conclusion that restoring the previous behaviour isn't necessary or even strictly desirable. In particular, the old behaviour could lead to the bridged buffer being kept alive much longer than necessary. This design ensures those are cleaned up as soon as possible.
My own research into adopting Array's optimization appears to be infeasible, as _NativeDictionaryStorage already inherits from ManagedBuffer, and so can't inherit from _NSDictionaryCore as well (right?).
Still, it should be noted that this will almost certainly lead to regressions in bridging performance. At least in micro-benchmarks.
It should also be noted that this redesign is necessary for soundness, as the double-indirection design is unsound for multi-threading (as discussed in SE-0065: https://github.com/apple/swift-evolution/blob/master/proposals/0065-collections-move-indices.md).

TODO before merge:

[x] re-instate empty-collection-singleton
[x] fix comparison change
[ ] evaluate benches
[x] fix documentation

(repearing this comment from the other PR)
The only outstanding problem is that the new bridging implementation seems to be breaking equality comparisons for [AnyHashable: Hashable] when bridged to NSDictionary. In particular, this assert is now failing: https://github.com/apple/swift/blob/c3b7709a7c4789f1ad7249d357f69509fb8be731/test/stdlib/TestUserInfo.swift#L101
I'm guessing this is because this kind of Dictionary doesn't provide its own equality comparison, that it's falling back to some object identity stuff, which is no longer holding? Not sure what guarantees we're providing here, or how to proceed. Any idea what the right solution is?
CC @moiseev @dabrahams

@swift-ci please smoke test

@swift-ci please benchmark

Oh interesting. The new source-stability machinery caught that we removed Index.successor(). I genuinely have no idea how we can source-stability bridge that.

@dabrahams to be honest, I don't even understand how it was passing before. Why would two independently constructed empty dictionaries have the same address?

Wait are you referring to the comment I made above, or the last commit I pushed?

Dictionary2
2038
1945
-4.6%
1.05x(?)

Dictionary
742
708
-4.6%
1.05x

StringHasPrefixUnicode
14418
13777
-4.5%
1.05x

ObjectiveCBridgeStubToNSDate
14353
13754
-4.2%
1.04x(?)

Prims
714
690
-3.4%
1.03x(?)

DictionarySwapOfObjects
6753
6573
-2.7%
1.03x

SortStringsUnicode
8320
8111
-2.5%
1.03x

StackPromo
21527
21188
-1.6%
1.02x(?)

ObjectiveCBridgeStubFromNSDateRef
3709
3626
-2.2%
1.02x

ObjectiveCBridgeToNSArray
30308
29725
-1.9%
1.02x(?)

Dictionary2OfObjects
3384
3320
-1.9%
1.02x

ObjectiveCBridgeToNSString
1072
1066
-0.6%
1.01x(?)

StringInterpolation
10880
10727
-1.4%
1.01x(?)

ErrorHandling
2914
2891
-0.8%
1.01x(?)

ArrayOfRef
3543
3515
-0.8%
1.01x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToString
119695
118388
-1.1%
1.01x(?)

ArraySubscript
1419
1422
+0.2%
1.00x(?)

MonteCarloPi
45209
45135
-0.2%
1.00x(?)

PopFrontArray
1111
1116
+0.5%
1.00x(?)

RecursiveOwnedParameter
1937
1934
-0.1%
1.00x(?)

ObjectiveCBridgeStubToNSString
1280
1280
+0.0%
1.00x

AnyHashableWithAClass
63128
62941
-0.3%
1.00x(?)

ClassArrayGetter
12
12
+0.0%
1.00x

Array2D
2028
2029
+0.1%
1.00x(?)

ArrayOfGenericPOD
220
220
+0.0%
1.00x

StringWithCString
155027
155199
+0.1%
1.00x(?)

ObjectiveCBridgeFromNSArrayAnyObjectForced
6023
6016
-0.1%
1.00x(?)

SortLettersInPlace
973
974
+0.1%
1.00x(?)

StrComplexWalk
2890
2877
-0.5%
1.00x(?)

ByteSwap
0
0
+0.0%
1.00x

SuperChars
211420
211362
-0.0%
1.00x(?)

XorLoop
380
380
+0.0%
1.00x

Integrate
239
238
-0.4%
1.00x

ObjectiveCBridgeStubFromNSStringRef
128
128
+0.0%
1.00x

ProtocolDispatch
3040
3040
+0.0%
1.00x

ObjectAllocation
153
153
+0.0%
1.00x

TypeFlood
0
0
+0.0%
1.00x

ArrayLiteral
1178
1179
+0.1%
1.00x(?)

ProtocolDispatch2
159
159
+0.0%
1.00x

HashTest
1749
1742
-0.4%
1.00x(?)

ObjectiveCBridgeStubDateMutation
273
273
+0.0%
1.00x

DictionaryOfObjects
2284
2295
+0.5%
1.00x(?)

PopFrontArrayGeneric
1117
1117
+0.0%
1.00x

PopFrontUnsafePointer
9176
9200
+0.3%
1.00x(?)

StringEqualPointerComparison
7323
7355
+0.4%
1.00x(?)

PolymorphicCalls
22
22
+0.0%
1.00x

ObjectiveCBridgeStubToNSStringRef
116
116
+0.0%
1.00x

MapReduce
342
342
+0.0%
1.00x

UTF8Decode
288
289
+0.3%
1.00x

NopDeinit
36662
36661
-0.0%
1.00x(?)

ObjectiveCBridgeStubToArrayOfNSString
29428
29402
-0.1%
1.00x(?)

GlobalClass
0
0
+0.0%
1.00x

StringBuilder
1318
1318
+0.0%
1.00x

ArrayInClass
62
62
+0.0%
1.00x

ArrayOfGenericRef
3571
3579
+0.2%
1.00x(?)

ObjectiveCBridgeFromNSString
1804
1810
+0.3%
1.00x(?)

ObjectiveCBridgeStubDateAccess
182
182
+0.0%
1.00x

Sim2DArray
277
277
+0.0%
1.00x

StringHasSuffixUnicode
63350
63147
-0.3%
1.00x(?)

Walsh
320
320
+0.0%
1.00x

ArrayAppend
774
774
+0.0%
1.00x

LinkedList
7257
7260
+0.0%
1.00x(?)

NSStringConversion
817
814
-0.4%
1.00x(?)

ArrayValueProp4
6
6
+0.0%
1.00x

ArrayOfPOD
182
182
+0.0%
1.00x

Chars
630
630
+0.0%
1.00x

DeadArray
185
185
+0.0%
1.00x

ArrayValueProp2
6
6
+0.0%
1.00x

BitCount
1
1
+0.0%
1.00x

AngryPhonebook
2819
2825
+0.2%
1.00x(?)

StringWalk
5883
5883
+0.0%
1.00x

ArrayValueProp
6
6
+0.0%
1.00x

RC4
165
165
+0.0%
1.00x

Memset
235
236
+0.4%
1.00x

ArrayAppendReserved
536
536
+0.0%
1.00x

ArrayValueProp3
6
6
+0.0%
1.00x

135
3188720
3224071
+1.1%
0.99x

ObjectiveCBridgeFromNSStringForced
2647
2675
+1.1%
0.99x(?)

ObjectiveCBridgeStubURLAppendPathRef
231853
235124
+1.4%
0.99x(?)

NSError
324
326
+0.6%
0.99x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
135323
136991
+1.2%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObject
75571
76624
+1.4%
0.99x(?)

ObjectiveCBridgeStubDataAppend
2941
2958
+0.6%
0.99x(?)

MonteCarloE
10451
10530
+0.8%
0.99x(?)

SevenBoom
1337
1348
+0.8%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
90297
91421
+1.2%
0.99x(?)

ObjectiveCBridgeStubFromArrayOfNSString
58551
59118
+1.0%
0.99x(?)

ObjectiveCBridgeStubNSDateMutationRef
12323
12438
+0.9%
0.99x(?)

ObjectiveCBridgeStubNSDataAppend
2416
2434
+0.8%
0.99x(?)

DictionaryBridge
3782
3853
+1.9%
0.98x(?)

Join
459
467
+1.7%
0.98x(?)

IterateData
2539
2602
+2.5%
0.98x

ObjectiveCBridgeStubURLAppendPath
229623
234485
+2.1%
0.98x(?)

RGBHistogramOfObjects
21979
22337
+1.6%
0.98x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
208742
215025
+3.0%
0.97x(?)

SortStrings
1771
1834
+3.6%
0.97x

ObjectiveCBridgeStubFromNSString
763
790
+3.5%
0.97x

Dictionary3
507
523
+3.2%
0.97x

RangeAssignment
274
286
+4.4%
0.96x(?)

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
106263
110210
+3.7%
0.96x(?)

StringHasPrefix
608
639
+5.1%
0.95x

OpenClose
54
57
+5.6%
0.95x

ObjectiveCBridgeFromNSSetAnyObjectToString
142266
150535
+5.8%
0.95x(?)

Prims
13599
13371
-1.7%
1.02x

Dictionary2
4488
4381
-2.4%
1.02x

StringEqualPointerComparison
9887
9732
-1.6%
1.02x

SetExclusiveOr_OfObjects
46794
46060
-1.6%
1.02x

SetUnion_OfObjects
34380
33857
-1.5%
1.02x

DictionaryRemove
17392
17085
-1.8%
1.02x

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
120658
118061
-2.1%
1.02x(?)

NSStringConversion
3023
2967
-1.9%
1.02x(?)

StringBuilder
2714
2666
-1.8%
1.02x(?)

StringWalk
21493
21098
-1.8%
1.02x

ObjectiveCBridgeToNSString
1111
1103
-0.7%
1.01x

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
222523
219915
-1.2%
1.01x(?)

ObjectiveCBridgeStubFromNSDateRef
4101
4068
-0.8%
1.01x

RangeAssignment
27747
27566
-0.7%
1.01x(?)

SuperChars
264407
261897
-0.9%
1.01x(?)

StringInterpolation
15817
15648
-1.1%
1.01x

ObjectAllocation
562
556
-1.1%
1.01x(?)

StringHasSuffixUnicode
64928
64565
-0.6%
1.01x

AnyHashableWithAClass
78212
77492
-0.9%
1.01x

ObjectiveCBridgeStubURLAppendPathRef
241500
239732
-0.7%
1.01x(?)

PopFrontArrayGeneric
9711
9640
-0.7%
1.01x(?)

AngryPhonebook
2992
2970
-0.7%
1.01x(?)

Hanoi
20684
20421
-1.3%
1.01x

ObjectiveCBridgeStubURLAppendPath
235101
233225
-0.8%
1.01x(?)

SortStringsUnicode
9455
9361
-1.0%
1.01x

MonteCarloE
109384
108684
-0.6%
1.01x

Chars
5049
4997
-1.0%
1.01x

ArraySubscript
5616
5599
-0.3%
1.00x(?)

StackPromo
128119
128265
+0.1%
1.00x(?)

135
5574266
5560601
-0.2%
1.00x

RecursiveOwnedParameter
10923
10883
-0.4%
1.00x(?)

ObjectiveCBridgeStubToNSString
1335
1337
+0.1%
1.00x(?)

ClassArrayGetter
1267
1267
+0.0%
1.00x

Array2D
813177
811793
-0.2%
1.00x(?)

ArrayOfGenericPOD
3613
3597
-0.4%
1.00x(?)

StringWithCString
154737
154728
-0.0%
1.00x(?)

ObjectiveCBridgeFromNSStringForced
3081
3084
+0.1%
1.00x(?)

SortLettersInPlace
2571
2559
-0.5%
1.00x

ByteSwap
9
9
+0.0%
1.00x

XorLoop
19988
20011
+0.1%
1.00x(?)

Join
1464
1462
-0.1%
1.00x(?)

ObjectiveCBridgeStubFromNSString
833
830
-0.4%
1.00x(?)

StaticArray
34855
34883
+0.1%
1.00x(?)

ProtocolDispatch2
444
444
+0.0%
1.00x

HashTest
5398
5385
-0.2%
1.00x(?)

ErrorHandling
3805
3805
+0.0%
1.00x

NSError
679
677
-0.3%
1.00x(?)

ObjectiveCBridgeStubToNSDateRef
3357
3366
+0.3%
1.00x(?)

MapReduce
45097
45074
-0.1%
1.00x(?)

IterateData
10622
10638
+0.1%
1.00x(?)

UTF8Decode
43530
43580
+0.1%
1.00x(?)

SetIntersect
15256
15317
+0.4%
1.00x(?)

StrToInt
5787
5775
-0.2%
1.00x(?)

ArrayInClass
3956
3953
-0.1%
1.00x(?)

ArrayOfGenericRef
10055
10095
+0.4%
1.00x(?)

Sim2DArray
14575
14589
+0.1%
1.00x

MonteCarloPi
53712
53508
-0.4%
1.00x

RC4
9367
9370
+0.0%
1.00x(?)

Walsh
13181
13178
-0.0%
1.00x(?)

LinkedList
27666
27780
+0.4%
1.00x(?)

ArrayOfPOD
2329
2328
-0.0%
1.00x(?)

DeadArray
120969
120581
-0.3%
1.00x(?)

ObjectiveCBridgeStubNSDataAppend
2796
2803
+0.2%
1.00x(?)

ArrayLiteral
1245
1248
+0.2%
1.00x(?)

SevenBoom
1497
1493
-0.3%
1.00x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
91841
92026
+0.2%
1.00x(?)

ArrayValueProp
2618
2616
-0.1%
1.00x(?)

ObjectiveCBridgeStubNSDateMutationRef
14702
14672
-0.2%
1.00x(?)

GlobalClass
0
0
+0.0%
1.00x

Memset
20650
20672
+0.1%
1.00x(?)

ArrayValueProp4
3022
3025
+0.1%
1.00x(?)

ArrayValueProp2
3135
3143
+0.3%
1.00x

ArrayValueProp3
3074
3079
+0.2%
1.00x(?)

PopFrontArray
24005
24164
+0.7%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToString
120893
121997
+0.9%
0.99x(?)

SortStrings
2691
2716
+0.9%
0.99x

Integrate
366
368
+0.6%
0.99x(?)

ArrayOfRef
9344
9395
+0.6%
0.99x(?)

ObjectiveCBridgeToNSArray
30694
30925
+0.8%
0.99x(?)

DictionaryOfObjects
4890
4927
+0.8%
0.99x(?)

ObjectiveCBridgeStubToNSStringRef
155
156
+0.7%
0.99x(?)

OpenClose
457
461
+0.9%
0.99x(?)

ObjectiveCBridgeStubToArrayOfNSString
29814
29991
+0.6%
0.99x(?)

ObjectiveCBridgeFromNSString
5062
5126
+1.3%
0.99x

ObjectiveCBridgeStubFromArrayOfNSString
58698
59417
+1.2%
0.99x(?)

DictionarySwapOfObjects
21129
21458
+1.6%
0.98x(?)

ObjectiveCBridgeFromNSArrayAnyObjectForced
10088
10286
+2.0%
0.98x(?)

ObjectiveCBridgeStubFromNSStringRef
159
163
+2.5%
0.98x

TypeFlood
184
188
+2.2%
0.98x(?)

Dictionary3
1606
1643
+2.3%
0.98x

PolymorphicCalls
1128
1149
+1.9%
0.98x

NopDeinit
59685
61119
+2.4%
0.98x

ObjectiveCBridgeFromNSArrayAnyObject
78137
79360
+1.6%
0.98x(?)

ObjectiveCBridgeStubDataAppend
3299
3374
+2.3%
0.98x

StringHasPrefixUnicode
15376
15668
+1.9%
0.98x

Dictionary2OfObjects
6259
6383
+2.0%
0.98x(?)

DictionaryBridge
3876
4008
+3.4%
0.97x(?)

Dictionary3OfObjects
2264
2338
+3.3%
0.97x

SetIntersect_OfObjects
13921
14363
+3.2%
0.97x

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
140464
144250
+2.7%
0.97x(?)

ObjectiveCBridgeStubDateAccess
1064
1096
+3.0%
0.97x

ArrayAppend
3337
3433
+2.9%
0.97x(?)

StringHasPrefix
1561
1628
+4.3%
0.96x

ObjectiveCBridgeStubNSDateRefAccess
1201
1254
+4.4%
0.96x

ObjectiveCBridgeStubFromNSDate
3655
3791
+3.7%
0.96x

ObjectiveCBridgeFromNSDictionaryAnyObject
209708
221473
+5.6%
0.95x

ObjectiveCBridgeStubToNSDate
13780
14433
+4.7%
0.95x(?)

DictionaryRemoveOfObjects
46925
49569
+5.6%
0.95x(?)

ObjectiveCBridgeFromNSSetAnyObjectToString
157543
165467
+5.0%
0.95x

**Hardware Overview**
      Model Name: Mac mini
      Model Identifier: Macmini7,1
      Processor Name: Intel Core i5
      Processor Speed: 2.8 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Memory: 16 GB

These bench results seem pretty promising! Major regressions are in the expected place (bridging), and there's some big wins on a few native benchmarks!

@bob-wilson Can someone on your team evaluate the performance results?

@jrose-apple I'm told you're the right person to ask about the correct behaviour for https://github.com/apple/swift/pull/5291#issuecomment-253812855

I can't see how it ever could have been depending on object identity, but those two dictionaries definitely should remain equal. They're being created from the same source.
(It's possible, of course, that something is broken in either AnyHashable or our SwiftValue box, but then I'd expect it to be broken everywhere.)
@jckarter is the other person to ask here (especially without Dmitri). Any insights, Joe?

Ah, it could conceivably be fallout from @DougGregor's https://github.com/apple/swift/commit/25e00d78d14cc174bfe924ed28c3355a33e22e59 as well.

The source-stability checker seems to be a false positive. .successor() is internal and unversioned. There shouldn't be any problem in removing it. How do we assert this to the system? (Just ignore it and manually merge when everything else is resolved?)

Reverting https://github.com/apple/swift/commit/25e00d78d14cc174bfe924ed28c3355a33e22e59 doesn't seem to affect this test.
@jrose-apple how does the == implementation for NSDictionary even come into existence? What features of our implementation of NSDictionary are used to synthesize it? Genuinely can't find this information.

== for NSDictionary is provided by == for NSObject, which invokes isEqual(_:), which calls NSDictionary's override of that, which should check "contains same key-value pairs", which will call isEqual(_:) on keys and values. In this case the keys and values aren't Objective-C types, so I would expect them to be boxed, but it's also stretching beyond any areas I worked on. (Hence poking Joe.)

Ok yeah, that makes sense. I can see why this was working before and now it's broken.
Here's a minimal example demonstrating the problem:
import Foundation

struct MyType {
    var data: Int = 0
}

let dictOfEqs: [AnyHashable: Any] = [AnyHashable(1): 1]
let dictOfMisc: [AnyHashable: Any] = [AnyHashable(1): MyType()]
let dictOfDupe: [AnyHashable: Any] = [AnyHashable(1): MyType()]

let nsDictOfEqs1 = dictOfEqs as NSDictionary
let nsDictOfEqs2 = dictOfEqs as NSDictionary

print(nsDictOfEqs1 == nsDictOfEqs2)

let nsDictOfMisc1 = dictOfMisc as NSDictionary
let nsDictOfMisc2 = dictOfMisc as NSDictionary

print(nsDictOfMisc1 == nsDictOfMisc2)

let nsDictOfDupe = dictOfDupe as NSDictionary

print(nsDictOfMisc1 == nsDictOfDupe)

In Swift 3, this code prints:
true
true
false

With this patch, we get:
true
false
false

Why? Before, Dictionary cached the bridged buffer. So multiple bridgings stored the exact same elements if they had to be boxed. This is relevant for types which aren't natively comparable in Swift, because ObjC is forced to fall back to pointer identity. With a cached buffer, pointer identity holds for a dictionary that has been bridged multiple times!
But this is easily broken by making two Dictionaries which don't share the same cache, so this behaviour isn't especially reliable (hence why we always get false for the last case).
I would argue that while the Swift 3 behaviour is nice, it's arguably incorrect. Or at best, a foot gun. A model where as is understood as "pass by value", and therefore makes values with distinct identity is an easier to understand one.
Note that with this patch [AnyHashable: Any] is still well behaved if the Any'd type provides its own implementation of ==.  This only breaks people relying on two non-comparable values having equal boxings.

Ah, that makes sense!
It's (unfortunately) a requirement of NSDictionary and NSArray that getting elements repeatedly results in the same pointer value, which is why that cache was there at all. But there's no reason to assume the cache would be shared between elements, and it's certainly a coincidence to be able to do it at all. The same would apply in Objective-C to value-like types that don't override -isEqual:, so this seems like reasonable behavior.
Just to check, if you make MyType Equatable, we get the first result, right?

Huh, seemingly no? I had assumed that Any was peeking into that. Need to investigate why ints are doing magic to Any...

I would argue that while the Swift 3 behaviour is nice, it's
arguably incorrect. Or at best, a foot gun.

No, this is exactly what I explained to you was happening with
_SwiftDeferredNSArray, just repeated for dictionaries.  It would be
“nice” if we could get away with ignoring Cocoa programmers'
expectations that they get back the same objects (by identity) every
time they traverse an immutable collection, but, at least today, we
can't.
--
-Dave

I agree with @Gankro. I think this behavior change is unavoidable with eager bridging. Since MyType isn't Equatable, there's no equality behavior we can offer in the bridged NSDictionary beyond object identity, and there's no way to preserve object identity if we build a fresh NSDictionary every time we bridge. If we cached the NSDictionary in the Dictionary value somehow, that's just pushing the problem around, since the Dictionary in Swift is a value type and we can't guarantee any instance-specific behavior.

@dabrahams _SwiftDeferredNSArray has the behaviour this patch is introducing.
import Foundation

struct MyType {
    var data: Int = 0

    static func ==(lhs: MyType, rhs: MyType) -> Bool {
        return lhs.data == rhs.data
    }
}

let arrayOfEqs: [Any] = [1]
let arrayOfMisc: [Any] = [MyType()]
let arrayOfDupe: [Any] = [MyType()]

let nsArrayOfEqs1 = arrayOfEqs as NSArray
let nsArrayOfEqs2 = arrayOfEqs as NSArray

print(nsArrayOfEqs1 == nsArrayOfEqs2)

let nsArrayOfMisc1 = arrayOfMisc as NSArray
let nsArrayOfMisc2 = arrayOfMisc as NSArray

print(nsArrayOfMisc1 == nsArrayOfMisc2)

let nsArrayOfDupe = arrayOfDupe as NSArray

print(nsArrayOfMisc1 == nsArrayOfDupe)

yields
true
false
false

We ensure that once bridged, an NSDictionary yields stable addresses. What NSDictionary is currently doing is ensuring that different NSDictionarys bridged from the same Dictionary have stable addresses.

Can anyone direct me to where the isEqual impl for Any/AnyObject is constructed? I can't figure out why Int's == impl is being passed through, but MyType's isn't.

@Gankro Look at SwiftValue.mm. AFAICT, in your example MyType doesn't have an Equatable conformance, so the _SwiftValue bridging box ought to fall back to object identity. This is all behaving correctly AFAICT.

@jckarter yeah my posted examples don't, but adding the conformance doesn't seem to affect the behaviour of the code:
import Foundation

struct MyType: Equatable {
    var data: Int = 0

    static func ==(lhs: MyType, rhs: MyType) -> Bool {
        return lhs.data == rhs.data
    }
}

let dictOfEqs: [AnyHashable: Any] = [AnyHashable(1): 1]
let dictOfEqsDupe: [AnyHashable: Any] = [AnyHashable(1): 2]
let dictOfMisc: [AnyHashable: Any] = [AnyHashable(1): MyType()]
let dictOfDupe: [AnyHashable: Any] = [AnyHashable(1): MyType()]

let nsDictOfEqs1 = dictOfEqs as NSDictionary
let nsDictOfEqs2 = dictOfEqs as NSDictionary

print(nsDictOfEqs1 == nsDictOfEqs2)

let nsDictOfEqsDupe = dictOfEqsDupe as NSDictionary

print(nsDictOfEqs1 == nsDictOfEqsDupe)

let nsDictOfMisc1 = dictOfMisc as NSDictionary
let nsDictOfMisc2 = dictOfMisc as NSDictionary

print(nsDictOfMisc1 == nsDictOfMisc2)

let nsDictOfDupe = dictOfDupe as NSDictionary

print(nsDictOfMisc1 == nsDictOfDupe)

print("\narrays:")

let arrayOfEqs: [Any] = [1]
let arrayOfMisc: [Any] = [MyType()]
let arrayOfDupe: [Any] = [MyType()]

let nsArrayOfEqs1 = arrayOfEqs as NSArray
let nsArrayOfEqs2 = arrayOfEqs as NSArray

print(nsArrayOfEqs1 == nsArrayOfEqs2)

let nsArrayOfMisc1 = arrayOfMisc as NSArray
let nsArrayOfMisc2 = arrayOfMisc as NSArray

print(nsArrayOfMisc1 == nsArrayOfMisc2)

let nsArrayOfDupe = arrayOfDupe as NSArray

print(nsArrayOfMisc1 == nsArrayOfDupe)

before patch:
true
false
true
false

arrays:
true
false
false

after patch:
true
false
false
false

arrays:
true
false
false

@_@ the isEqual impl uses Hashable, not Equatable

on Mon Oct 17 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

We ensure that once bridged, an NSDictionary yields stable
addresses. What NSDictionary is currently doing is ensuring that
different NSDictionarys bridged from the same Dictionary have stable
addresses.

Oh!  In that case, yeah, kill that behavior.  Nobody asked for that
behavior AFAIK.
--
-Dave

on Mon Oct 17 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

@_@ the isEqual impl uses Hashable, not Equatable

Arguably we ought to have an AnyEquatable, too, but that's a separate
project.
--
-Dave

Looks like rdar://problem/27574348 (Forward -isEqual: and -hash through SwiftObject, SwiftValue, and SwiftNativeNSError) was never fully implemented. I can't find any discussion of why only the Hashable conformance was used rather than Equatable here.
But it seems like we can just ignore that as an unrelated bug for now.

@dabrahams I've added the logic to include an empty singleton, but after doing that I realized the failing test is actually verifying an empty set bridged NSDictionary is also a singleton. Unfortunately, as discussed this no longer comes free with Dictionary, so I'd need to further refactor _NativeSelfBridgingStorage to also be a class hierarchy like I have with _NativeSelfStorage.
Before I proceed I'd like to verify that:

My solution to this problem is acceptable
We care about bridging empty sets/dictionaries enough to bother

on Mon Oct 17 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

@dabrahams I've added the logic to include an empty singleton, but
after doing that I realized the failing test is actually verifying an
empty set bridged NSDictionary is also a singleton. Unfortunately,
as discussed this no longer comes free with Dictionary, so I'd need to
further refactor _NativeSelfBridgingStorage to also be a class
hierarchy like I have with _NativeSelfStorage.
Before I proceed I'd like to verify that:

My solution to this problem is acceptable

I'm afraid I don't know what the problem or your solution is.  Is there
any reason you can think of that it might be unacceptable?  If this is
more complicated, we should talk; I should be in the office around 10:30
PST.

We care about bridging empty sets/dictionaries enough to bother

I think the empty case is common enough to be worth optimizing for.
Normally what we'd do is make our singleton buffer also be-a
NSDictionary.
 I don't have any specific concerns with the design, it seems like the best one given the constraints. But I'm not a swift expert so I just want to verify that it actually is.
Current design:

NativeRawBuffer (class) provides an untyped header/buffer
NativeBuffer (class) inherits this to add enough type info to implement deinit
NativeStorage stores a NativeRawBuffer, also providing type info, and all actual functionality
99% of the time, NativeStorage stores a NativeBuffer. However, the empty singleton is a "pure" NativeRawBuffer. Using a NativeRawBuffer is necessary to satisfy strict aliasing, because we want to reinterpret its absence of elements as whatever type the Dictionary has.

In my ideal world, either:

NativeBuffer doesn't exist. It encodes redundant type info, and bloats up the runtime's class metadata system. Whenever a Dictionary is destroyed, it just checks for uniqueness of its buffer, and if true, runs the deinit it provides. This is currently impossible, as structs can't provide deinits. I doubt this will ever be possible, because even if we opt to provide them on move-only types, I doubt we'll provide them on copyable structs.

NativeRawBuffer doesn't exist. It exists only to satisfy strict aliasing. Type safety of the stored elements would be well-preserved by having the singleton be a NativeBuffer<(), ()> that we cast to NativeBuffer<K, V>, because there's no way to actually read/write keys/values to the empty singleton (unclear: whether this would melt some metadata system regardless of strict aliasing). I doubt this will ever be possible, because strict aliasing is pretty clearly here to stay.

FWIW, I think NativeRawBuffer is the right solution to the singleton-which-may-standin-for-any-type problem. It might be better spelled NativeBufferBase or something...

It would be nice if we could represent a non-protocol existential like exists T, U. NativeBuffer<T, U> in the type system, which would avoid the need for the formal base class.

@swift-ci Please benchmark

@swift-ci Please smoke test

OK!
So here's the new design. After digging through how Array actually accomplishes what it does, I realized I had a benign but deceptive rebase error. (I was inheriting from ManagedBuffer and manually tail-allocating self). Removing that error resolved the double-inheritance issue, allowing verbatim bridging to be a thing!
Changes to design:
There's a new typed inserted between RawNativeBuffer and NativeBuffer<K: Hashable, V> -- TypedBuffer<K, V>. The purpose of this type is literally to provide typing without the Hashable bound. This is necessary to support NativeStorage<AnyObject, AnyObject>, which is now used by SwiftDeferredNSDictionary<K, V> (previously called Native${Self}BridgingStorage, which I thought was confusing).
RawNativeBuffer inherits from NSDictionary, but only providing code for "nothing is contained". NativeBuffer replaces this implementation with a proper one. Note that TypedNativeBuffer can't do this, because you can't mess with objc methods in constrained conformances (and the "real" implementation needs K: Hashable).
If K and V are verbatim bridgeable, or the backing store is the empty singleton, bridging to ObjC just returns the buffer. Toll free bridging!
Otherwise, we toss the NativeStorage<K, V> into SwiftDeferredNSDictionary, which will construct a bridged NativeStorage<AnyObject, AnyObject> on first use.
Some miscellaneous cleanup:

BridgedNativeDictionaryStorage, which was just a clone of NativeStorage with <K, V> hardcoded to <AnyObject, AnyObject> has been completely deleted. NativeStorage is the only remaining "storage" type.

NativeDictionaryStorageKeyNSEnumerator has been renamed to NativeDictionaryNSEnumerator, because I hated that name (very Swift 2.0-ish).

SwiftDeferredNSDictionary has been significantly simplified, because there is no longer a "verbatim bridgeable" fastpath; nothing verbatim bridgeable should ever be fed to it.

Some conveniences for getting (bridged) keys/values were added to NativeStorage to deduplicate some logic.

Locally I'm seeing this assertion failing:
https://github.com/apple/swift/blob/master/validation-test/stdlib/Set.swift#L2047
Digging into it, I don't really understand what guarantee it's trying to uphold. To be clear, it appears to be testing that two empty Actually-From-ObjC-NSArrays bridge into the same backing storage. However in my testing, they don't have the same backing storage even in ObjC. The only way I see to make this test pass would be to check if the NSDictionary is empty, and native bridge it to the empty singleton. But that would just fail assertions on a different line, since this test requires that the Dictionary is bridged in a non-native way.
I'm very confused by the compilation error the smoke test is giving.
The linux error isn't surprising; I expected to get the #if runtime(objc) checks wrong.

(can reproduce OSX smoke failure; it appears to be a bug in master based on the same crash appearing in everyone's PRs)

Rebased onto crashy master.
Added tons of comments.
I'm aware the commit messages are suboptimal; I'll be squashing/cleaning those up when this design is signed off on.

Build comment file:
Optimized (O)

Regression (8)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeToNSDictionary
15774
66997
+324.7%
0.24x

ObjectiveCBridgeToNSSet
15580
40793
+161.8%
0.38x

ObjectiveCBridgeFromNSSetAnyObjectForced
4569
5499
+20.4%
0.83x

ObjectiveCBridgeFromNSDictionaryAnyObjectForced
5340
6350
+18.9%
0.84x

Calculator
30
35
+16.7%
0.86x

StringHasSuffix
710
804
+13.2%
0.88x

ObjectiveCBridgeFromNSDictionaryAnyObject
193068
209215
+8.4%
0.92x(?)

SetExclusiveOr
2623
2810
+7.1%
0.93x

Improvement (18)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

OpenClose
54
51
-5.6%
1.06x

DictionarySwapOfObjects
6717
6213
-7.5%
1.08x(?)

ObjectiveCBridgeStubNSDateRefAccess
338
308
-8.9%
1.10x

TwoSum
1584
1423
-10.2%
1.11x

CaptureProp
4565
4032
-11.7%
1.13x

RGBHistogram
2810
2449
-12.8%
1.15x

SetUnion
3015
2518
-16.5%
1.20x

StringWithCString
198736
154501
-22.3%
1.29x

DictionarySwap
630
485
-23.0%
1.30x

NSDictionaryCastToSwift
6883
4789
-30.4%
1.44x

SetIntersect_OfObjects
2168
1422
-34.4%
1.52x

DictionaryRemove
4602
2933
-36.3%
1.57x

SetIsSubsetOf_OfObjects
559
323
-42.2%
1.73x

Histogram
661
347
-47.5%
1.90x

SetIsSubsetOf
500
247
-50.6%
2.02x

DictionaryLiteral
2733
1348
-50.7%
2.03x

SetIntersect
1081
414
-61.7%
2.61x

ByteSwap
1
0
-99.9%
1001.00x

No Changes (110)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

PolymorphicCalls
22
21
-4.5%
1.05x

RGBHistogramOfObjects
22852
21776
-4.7%
1.05x

Dictionary3
580
556
-4.1%
1.04x

ObjectiveCBridgeFromNSString
1822
1776
-2.5%
1.03x(?)

ObjectiveCBridgeStubFromNSDateRef
3757
3666
-2.4%
1.02x

AnyHashableWithAClass
63877
62339
-2.4%
1.02x(?)

ObjectiveCBridgeStubURLAppendPath
235304
229746
-2.4%
1.02x(?)

NSStringConversion
803
787
-2.0%
1.02x

DeadArray
185
182
-1.6%
1.02x

StrComplexWalk
2906
2886
-0.7%
1.01x(?)

ObjectAllocation
154
153
-0.7%
1.01x(?)

ProtocolDispatch2
159
158
-0.6%
1.01x

HashTest
1748
1739
-0.5%
1.01x(?)

ObjectiveCBridgeToNSArray
30152
29897
-0.8%
1.01x(?)

PopFrontArrayGeneric
1116
1110
-0.5%
1.01x(?)

ObjectiveCBridgeStubToNSStringRef
117
116
-0.8%
1.01x(?)

ObjectiveCBridgeFromNSArrayAnyObject
73707
73223
-0.7%
1.01x(?)

MonteCarloE
10509
10445
-0.6%
1.01x(?)

LinkedList
7253
7206
-0.7%
1.01x(?)

ObjectiveCBridgeStubNSDataAppend
2429
2408
-0.9%
1.01x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
88469
87588
-1.0%
1.01x(?)

ArraySubscript
1409
1405
-0.3%
1.00x(?)

MonteCarloPi
44992
45199
+0.5%
1.00x

StackPromo
21480
21423
-0.3%
1.00x

PopFrontArray
1112
1115
+0.3%
1.00x(?)

RecursiveOwnedParameter
1936
1936
+0.0%
1.00x

ObjectiveCBridgeStubToNSString
1281
1280
-0.1%
1.00x(?)

ClassArrayGetter
12
12
+0.0%
1.00x

ObjectiveCBridgeFromNSArrayAnyObjectForced
6120
6119
-0.0%
1.00x(?)

ObjectiveCBridgeFromNSStringForced
2673
2667
-0.2%
1.00x(?)

SortLettersInPlace
971
973
+0.2%
1.00x(?)

RangeAssignment
283
283
+0.0%
1.00x

SuperChars
211393
210943
-0.2%
1.00x(?)

ObjectiveCBridgeStubToNSDate
13529
13508
-0.2%
1.00x(?)

XorLoop
380
380
+0.0%
1.00x

StringInterpolation
10863
10829
-0.3%
1.00x(?)

Integrate
238
238
+0.0%
1.00x

ProtocolDispatch
3038
3040
+0.1%
1.00x(?)

TypeFlood
0
0
+0.0%
1.00x

ArrayLiteral
1178
1174
-0.3%
1.00x

ErrorHandling
2905
2905
+0.0%
1.00x

ObjectiveCBridgeStubURLAppendPathRef
233907
233050
-0.4%
1.00x(?)

ObjectiveCBridgeStubDateMutation
273
273
+0.0%
1.00x

DictionaryOfObjects
2321
2329
+0.3%
1.00x(?)

ObjectiveCBridgeStubToNSDateRef
3262
3266
+0.1%
1.00x(?)

PopFrontUnsafePointer
9188
9229
+0.5%
1.00x(?)

StringEqualPointerComparison
7325
7298
-0.4%
1.00x(?)

MapReduce
343
342
-0.3%
1.00x(?)

IterateData
2593
2603
+0.4%
1.00x(?)

ArrayOfGenericPOD
220
220
+0.0%
1.00x

UTF8Decode
288
289
+0.3%
1.00x(?)

SortStringsUnicode
8289
8327
+0.5%
1.00x(?)

StringBuilder
1316
1318
+0.1%
1.00x(?)

StringWalk
5884
5900
+0.3%
1.00x

ArrayValueProp
6
6
+0.0%
1.00x

GlobalClass
0
0
+0.0%
1.00x

Memset
235
235
+0.0%
1.00x

ArrayAppendReserved
536
536
+0.0%
1.00x

ArrayValueProp2
6
6
+0.0%
1.00x

ArrayValueProp3
6
6
+0.0%
1.00x

ObjectiveCBridgeToNSString
1070
1078
+0.8%
0.99x(?)

Array2D
2024
2037
+0.6%
0.99x(?)

Join
461
466
+1.1%
0.99x(?)

ObjectiveCBridgeStubFromNSString
767
778
+1.4%
0.99x

StaticArray
2753
2772
+0.7%
0.99x(?)

ArrayOfRef
3520
3550
+0.8%
0.99x(?)

NSError
324
327
+0.9%
0.99x(?)

ObjectiveCBridgeStubToArrayOfNSString
29016
29423
+1.4%
0.99x(?)

ArrayOfGenericRef
3570
3595
+0.7%
0.99x(?)

SetExclusiveOr_OfObjects
7743
7835
+1.2%
0.99x(?)

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
106597
107803
+1.1%
0.99x(?)

Chars
630
636
+0.9%
0.99x

ObjectiveCBridgeStubFromArrayOfNSString
57349
58172
+1.4%
0.99x(?)

ObjectiveCBridgeStubNSDateMutationRef
11829
11972
+1.2%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToString
117281
119903
+2.2%
0.98x(?)

ObjectiveCBridgeStubFromNSStringRef
128
131
+2.3%
0.98x

StringHasSuffixUnicode
62727
63758
+1.6%
0.98x

Dictionary2
2049
2090
+2.0%
0.98x(?)

Hanoi
3273
3326
+1.6%
0.98x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
135282
138035
+2.0%
0.98x(?)

ObjectiveCBridgeStubDataAppend
2934
2993
+2.0%
0.98x(?)

SevenBoom
1337
1361
+1.8%
0.98x(?)

Dictionary2OfObjects
3452
3525
+2.1%
0.98x(?)

DictionaryBridge
3708
3821
+3.0%
0.97x(?)

Prims
719
738
+2.6%
0.97x

DictionaryRemoveOfObjects
19782
20326
+2.8%
0.97x(?)

SetUnion_OfObjects
6524
6701
+2.7%
0.97x

135
2998898
3118584
+4.0%
0.96x

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
203869
212255
+4.1%
0.96x(?)

SortStrings
1767
1832
+3.7%
0.96x(?)

NopDeinit
36646
38127
+4.0%
0.96x

ObjectiveCBridgeFromNSSetAnyObjectToString
139000
145410
+4.6%
0.96x(?)

StringHasPrefixUnicode
13725
14242
+3.8%
0.96x(?)

Dictionary3OfObjects
868
917
+5.7%
0.95x

ObjectiveCBridgeFromNSSetAnyObject
94128
99235
+5.4%
0.95x(?)

Improvement (16)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

SetIsSubsetOf_OfObjects
1960
1846
-5.8%
1.06x

TypeFlood
204
190
-6.9%
1.07x(?)

PopFrontUnsafePointer
258914
242401
-6.4%
1.07x

SetIsSubsetOf
2203
2063
-6.3%
1.07x

SetExclusiveOr
27803
25753
-7.4%
1.08x

Histogram
10555
9641
-8.7%
1.09x

ProtocolDispatch
6126
5613
-8.4%
1.09x

SetUnion
16092
14721
-8.5%
1.09x

StrComplexWalk
7867
7165
-8.9%
1.10x

MonteCarloE
113943
103311
-9.3%
1.10x

RGBHistogram
38573
35187
-8.8%
1.10x

TwoSum
5931
5373
-9.4%
1.10x

StringWalk
23587
21329
-9.6%
1.11x(?)

DictionarySwap
6528
5686
-12.9%
1.15x

StringHasSuffix
1775
1536
-13.5%
1.16x

NSDictionaryCastToSwift
8264
6013
-27.2%
1.37x

No Changes (108)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

DictionarySwapOfObjects
20363
19412
-4.7%
1.05x(?)

StringHasPrefix
1637
1553
-5.1%
1.05x

Dictionary3
1525
1463
-4.1%
1.04x

SetIntersect_OfObjects
13338
12791
-4.1%
1.04x

SetIntersect
14442
13869
-4.0%
1.04x

Dictionary3OfObjects
2193
2121
-3.3%
1.03x(?)

ObjectiveCBridgeStubFromNSString
811
790
-2.6%
1.03x

StaticArray
35286
34406
-2.5%
1.03x(?)

Dictionary
1964
1904
-3.0%
1.03x

RGBHistogramOfObjects
87600
85349
-2.6%
1.03x

ObjectiveCBridgeStubDateAccess
1095
1064
-2.8%
1.03x

ArrayOfPOD
2392
2328
-2.7%
1.03x

StringBuilder
2798
2729
-2.5%
1.03x(?)

OpenClose
440
431
-2.0%
1.02x

NSStringConversion
2994
2932
-2.1%
1.02x(?)

SortStrings
2750
2732
-0.7%
1.01x

StringWithCString
154580
153806
-0.5%
1.01x

Prims
13151
13073
-0.6%
1.01x(?)

SortLettersInPlace
2569
2555
-0.5%
1.01x(?)

Dictionary2
4325
4289
-0.8%
1.01x(?)

ObjectiveCBridgeStubToNSDateRef
3358
3337
-0.6%
1.01x(?)

PolymorphicCalls
1134
1128
-0.5%
1.01x(?)

Calculator
996
990
-0.6%
1.01x

DictionaryLiteral
15399
15238
-1.1%
1.01x

ObjectiveCBridgeStubURLAppendPath
237050
234770
-1.0%
1.01x(?)

StrToInt
5806
5740
-1.1%
1.01x

DeadArray
121547
119890
-1.4%
1.01x(?)

ObjectiveCBridgeStubFromArrayOfNSString
57780
57115
-1.1%
1.01x(?)

ArraySubscript
5410
5434
+0.4%
1.00x(?)

ObjectiveCBridgeToNSString
1103
1099
-0.4%
1.00x(?)

MonteCarloPi
53699
53498
-0.4%
1.00x

StackPromo
126395
126249
-0.1%
1.00x(?)

RecursiveOwnedParameter
10844
10852
+0.1%
1.00x(?)

ObjectiveCBridgeStubToNSString
1336
1335
-0.1%
1.00x(?)

ClassArrayGetter
1270
1270
+0.0%
1.00x

Array2D
796687
797104
+0.1%
1.00x(?)

ByteSwap
9
9
+0.0%
1.00x

SuperChars
262069
262835
+0.3%
1.00x(?)

XorLoop
20013
20015
+0.0%
1.00x(?)

Integrate
365
365
+0.0%
1.00x

Join
1385
1383
-0.1%
1.00x(?)

AnyHashableWithAClass
77701
77492
-0.3%
1.00x

ProtocolDispatch2
442
444
+0.5%
1.00x

ErrorHandling
3782
3786
+0.1%
1.00x(?)

ArrayOfRef
8810
8854
+0.5%
1.00x(?)

ObjectiveCBridgeStubURLAppendPathRef
239679
239746
+0.0%
1.00x(?)

NSError
679
680
+0.1%
1.00x(?)

DictionaryOfObjects
4788
4765
-0.5%
1.00x(?)

StringEqualPointerComparison
9930
9960
+0.3%
1.00x

CaptureProp
118239
117978
-0.2%
1.00x

MapReduce
43304
43393
+0.2%
1.00x(?)

Hanoi
18655
18667
+0.1%
1.00x(?)

ArrayOfGenericPOD
3608
3609
+0.0%
1.00x(?)

UTF8Decode
40371
40275
-0.2%
1.00x(?)

ObjectiveCBridgeFromNSArrayAnyObject
76840
76872
+0.0%
1.00x(?)

GlobalClass
0
0
+0.0%
1.00x

ArrayInClass
3957
3955
-0.1%
1.00x(?)

ArrayOfGenericRef
9479
9522
+0.5%
1.00x(?)

Sim2DArray
14578
14588
+0.1%
1.00x(?)

StringHasSuffixUnicode
64980
65048
+0.1%
1.00x(?)

Walsh
13132
13129
-0.0%
1.00x(?)

ArrayAppend
3439
3437
-0.1%
1.00x(?)

StringHasPrefixUnicode
15655
15663
+0.1%
1.00x(?)

ArrayLiteral
1547
1552
+0.3%
1.00x(?)

ArrayAppendReserved
3191
3189
-0.1%
1.00x(?)

Chars
5000
4993
-0.1%
1.00x(?)

ObjectiveCBridgeStubNSDataAppend
2787
2795
+0.3%
1.00x(?)

ArrayValueProp
3184
3181
-0.1%
1.00x(?)

RC4
9364
9367
+0.0%
1.00x(?)

Memset
20659
20649
-0.1%
1.00x(?)

ArrayValueProp4
3545
3540
-0.1%
1.00x(?)

ArrayValueProp2
3745
3732
-0.3%
1.00x(?)

ArrayValueProp3
3599
3600
+0.0%
1.00x(?)

PopFrontArray
23375
23542
+0.7%
0.99x(?)

ObjectiveCBridgeFromNSStringForced
3068
3086
+0.6%
0.99x(?)

ObjectiveCBridgeStubToNSDate
13835
14009
+1.3%
0.99x(?)

StringInterpolation
15610
15847
+1.5%
0.99x

ObjectAllocation
590
596
+1.0%
0.99x(?)

HashTest
5383
5424
+0.8%
0.99x(?)

ObjectiveCBridgeStubToNSStringRef
155
156
+0.7%
0.99x(?)

IterateData
10571
10650
+0.8%
0.99x

ObjectiveCBridgeFromNSString
5094
5134
+0.8%
0.99x(?)

Phonebook
63144
63593
+0.7%
0.99x(?)

LinkedList
27656
27910
+0.9%
0.99x(?)

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
116983
118764
+1.5%
0.99x(?)

BitCount
96
97
+1.0%
0.99x(?)

AngryPhonebook
2970
2988
+0.6%
0.99x

SevenBoom
1486
1507
+1.4%
0.99x(?)

ObjectiveCBridgeStubNSDateMutationRef
14450
14618
+1.2%
0.99x(?)

ObjectiveCBridgeStubFromNSDateRef
4036
4109
+1.8%
0.98x

RangeAssignment
25615
26089
+1.9%
0.98x(?)

PopFrontArrayGeneric
9126
9286
+1.8%
0.98x

ObjectiveCBridgeStubToArrayOfNSString
29151
29623
+1.6%
0.98x(?)

ObjectiveCBridgeStubDataAppend
3299
3365
+2.0%
0.98x

ObjectiveCBridgeStubNSDateRefAccess
1198
1226
+2.3%
0.98x

135
5318735
5507404
+3.5%
0.97x

ObjectiveCBridgeFromNSArrayAnyObjectToString
118424
121635
+2.7%
0.97x(?)

ObjectiveCBridgeFromNSArrayAnyObjectForced
9938
10254
+3.2%
0.97x(?)

ObjectiveCBridgeStubFromNSDate
3828
3929
+2.6%
0.97x

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
211319
219157
+3.7%
0.96x(?)

DictionaryBridge
3771
3926
+4.1%
0.96x(?)

ObjectiveCBridgeStubFromNSStringRef
157
164
+4.5%
0.96x(?)

ObjectiveCBridgeToNSArray
29537
30660
+3.8%
0.96x(?)

SortStringsUnicode
9150
9528
+4.1%
0.96x

Dictionary2OfObjects
6098
6325
+3.7%
0.96x

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
139557
146765
+5.2%
0.95x(?)

NopDeinit
58115
61134
+5.2%
0.95x(?)

SetExclusiveOr_OfObjects
44210
46647
+5.5%
0.95x

**Hardware Overview**
      Model Name: Mac mini
      Model Identifier: Macmini7,1
      Processor Name: Intel Core i5
      Processor Speed: 2.8 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Memory: 16 GB

Benchmark results: looks like some of the optimized regressions are gone, but there are some new unoptimized regressions. Probably just needs some TLC with inline/final annotations, as I've shifted around implementations a lot.
Bridging performance probably didn't improve because I forgot to implement toll-free bridging the other way. Oops! (fixing now)

@swift-ci Please benchmark

@swift-ci Please smoke test

Correctness-wise, looks like we just need to settle the intent of EqualityTest_Empty.

@swift-ci Please benchmark

Build comment file:
Optimized (O)

Regression (11)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeToNSDictionary
16132
71424
+342.8%
0.23x

ObjectiveCBridgeToNSSet
15609
44248
+183.5%
0.35x

ObjectiveCBridgeFromNSDictionaryAnyObjectForced
5273
6634
+25.8%
0.79x

ObjectiveCBridgeFromNSSetAnyObjectForced
4559
5700
+25.0%
0.80x

StringHasPrefix
608
740
+21.7%
0.82x

SetExclusiveOr
2634
3044
+15.6%
0.87x

CaptureProp
4049
4563
+12.7%
0.89x

StringHasSuffix
710
800
+12.7%
0.89x

ObjectiveCBridgeStubNSDateRefAccess
308
338
+9.7%
0.91x

ObjectiveCBridgeFromNSDictionaryAnyObject
202353
214177
+5.8%
0.94x

ObjectiveCBridgeStubFromNSString
747
794
+6.3%
0.94x

Improvement (13)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

TwoSum
1566
1415
-9.6%
1.11x

RGBHistogram
2820
2436
-13.6%
1.16x

SetUnion
2985
2519
-15.6%
1.18x

StringWithCString
198927
156179
-21.5%
1.27x(?)

DictionarySwap
628
477
-24.0%
1.32x

NSDictionaryCastToSwift
7021
5011
-28.6%
1.40x

SetIntersect_OfObjects
2286
1516
-33.7%
1.51x

DictionaryRemove
4634
2953
-36.3%
1.57x

SetIsSubsetOf_OfObjects
524
316
-39.7%
1.66x

Histogram
656
334
-49.1%
1.96x

DictionaryLiteral
2768
1383
-50.0%
2.00x

SetIsSubsetOf
510
252
-50.6%
2.02x

SetIntersect
1072
425
-60.4%
2.52x

No Changes (112)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

DictionarySwapOfObjects
6752
6407
-5.1%
1.05x

StrToInt
5221
5040
-3.5%
1.04x

SortStringsUnicode
8067
7864
-2.5%
1.03x

ObjectiveCBridgeStubFromNSDateRef
3737
3652
-2.3%
1.02x

ErrorHandling
2962
2903
-2.0%
1.02x(?)

ObjectiveCBridgeStubURLAppendPathRef
236682
231036
-2.4%
1.02x(?)

ObjectiveCBridgeStubToArrayOfNSString
29608
28968
-2.2%
1.02x(?)

SetExclusiveOr_OfObjects
7918
7798
-1.5%
1.02x(?)

SortStrings
1755
1730
-1.4%
1.01x(?)

SortLettersInPlace
976
968
-0.8%
1.01x(?)

SuperChars
213858
210945
-1.4%
1.01x(?)

ObjectiveCBridgeStubToNSDate
13283
13208
-0.6%
1.01x(?)

ProtocolDispatch2
159
157
-1.3%
1.01x

HashTest
1755
1732
-1.3%
1.01x(?)

ObjectiveCBridgeToNSArray
30136
29930
-0.7%
1.01x(?)

AngryPhonebook
2821
2799
-0.8%
1.01x(?)

ObjectiveCBridgeStubURLAppendPath
234032
232449
-0.7%
1.01x(?)

ObjectiveCBridgeStubDataAppend
2977
2957
-0.7%
1.01x(?)

ArrayOfGenericRef
3601
3579
-0.6%
1.01x(?)

RGBHistogramOfObjects
21937
21743
-0.9%
1.01x(?)

Chars
630
623
-1.1%
1.01x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
91660
90383
-1.4%
1.01x(?)

ArraySubscript
1419
1417
-0.1%
1.00x(?)

ObjectiveCBridgeToNSString
1072
1068
-0.4%
1.00x(?)

MonteCarloPi
44932
44975
+0.1%
1.00x(?)

PopFrontArray
1111
1116
+0.5%
1.00x(?)

RecursiveOwnedParameter
1935
1934
-0.1%
1.00x(?)

Integrate
238
238
+0.0%
1.00x

ClassArrayGetter
12
12
+0.0%
1.00x

Array2D
2030
2026
-0.2%
1.00x(?)

ArrayOfGenericPOD
220
220
+0.0%
1.00x

ObjectiveCBridgeFromNSArrayAnyObjectForced
6073
6086
+0.2%
1.00x(?)

ObjectiveCBridgeFromNSStringForced
2646
2647
+0.0%
1.00x(?)

ByteSwap
0
0
+0.0%
1.00x

XorLoop
380
380
+0.0%
1.00x

ObjectiveCBridgeStubToNSString
1283
1283
+0.0%
1.00x

ObjectiveCBridgeStubFromNSStringRef
128
128
+0.0%
1.00x

StaticArray
2748
2740
-0.3%
1.00x(?)

ProtocolDispatch
3039
3038
-0.0%
1.00x(?)

ObjectAllocation
153
153
+0.0%
1.00x

TypeFlood
0
0
+0.0%
1.00x

AnyHashableWithAClass
63829
63728
-0.2%
1.00x(?)

ArrayOfRef
3528
3530
+0.1%
1.00x(?)

ObjectiveCBridgeStubDateMutation
273
273
+0.0%
1.00x

NSError
325
326
+0.3%
1.00x(?)

ObjectiveCBridgeStubToNSDateRef
3238
3225
-0.4%
1.00x(?)

PopFrontArrayGeneric
1116
1116
+0.0%
1.00x

StringEqualPointerComparison
7298
7299
+0.0%
1.00x(?)

PolymorphicCalls
22
22
+0.0%
1.00x

RC4
165
165
+0.0%
1.00x

Calculator
33
33
+0.0%
1.00x

MapReduce
342
342
+0.0%
1.00x

OpenClose
54
54
+0.0%
1.00x

UTF8Decode
288
288
+0.0%
1.00x

NopDeinit
36654
36635
-0.1%
1.00x(?)

ObjectiveCBridgeFromNSArrayAnyObject
76106
76145
+0.1%
1.00x(?)

StringBuilder
1320
1318
-0.1%
1.00x(?)

ObjectiveCBridgeStubDateAccess
182
182
+0.0%
1.00x

Sim2DArray
277
277
+0.0%
1.00x

ArrayAppend
773
772
-0.1%
1.00x(?)

LinkedList
7250
7258
+0.1%
1.00x(?)

ArrayValueProp4
6
6
+0.0%
1.00x

ArrayOfPOD
182
182
+0.0%
1.00x

DeadArray
185
185
+0.0%
1.00x

ArrayValueProp2
6
6
+0.0%
1.00x

BitCount
1
1
+0.0%
1.00x

ArrayLiteral
1177
1182
+0.4%
1.00x(?)

ArrayValueProp
6
6
+0.0%
1.00x

GlobalClass
0
0
+0.0%
1.00x

Memset
235
235
+0.0%
1.00x

ArrayAppendReserved
536
535
-0.2%
1.00x(?)

ArrayValueProp3
6
6
+0.0%
1.00x

StackPromo
21443
21586
+0.7%
0.99x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
212637
214921
+1.1%
0.99x(?)

StringInterpolation
10749
10815
+0.6%
0.99x(?)

StrComplexWalk
2882
2914
+1.1%
0.99x(?)

DictionaryOfObjects
2284
2314
+1.3%
0.99x(?)

ObjectiveCBridgeStubToNSStringRef
116
117
+0.9%
0.99x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
136557
137948
+1.0%
0.99x(?)

ObjectiveCBridgeFromNSString
1767
1786
+1.1%
0.99x(?)

Phonebook
7053
7093
+0.6%
0.99x(?)

MonteCarloE
10473
10564
+0.9%
0.99x(?)

SetUnion_OfObjects
6613
6655
+0.6%
0.99x(?)

StringHasSuffixUnicode
63326
63794
+0.7%
0.99x

Walsh
309
312
+1.0%
0.99x

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
107032
108256
+1.1%
0.99x(?)

SevenBoom
1345
1361
+1.2%
0.99x(?)

StringWalk
5880
5912
+0.5%
0.99x

ObjectiveCBridgeFromNSArrayAnyObjectToString
119526
122126
+2.2%
0.98x(?)

DictionaryBridge
3787
3863
+2.0%
0.98x(?)

Dictionary2
2027
2075
+2.4%
0.98x

Join
458
466
+1.8%
0.98x

PopFrontUnsafePointer
9176
9319
+1.6%
0.98x(?)

IterateData
2551
2596
+1.8%
0.98x(?)

ObjectiveCBridgeFromNSSetAnyObjectToString
146634
148940
+1.6%
0.98x(?)

ArrayInClass
62
63
+1.6%
0.98x(?)

NSStringConversion
788
804
+2.0%
0.98x

Dictionary2OfObjects
3378
3444
+1.9%
0.98x(?)

ObjectiveCBridgeStubNSDataAppend
2433
2480
+1.9%
0.98x(?)

135
3061059
3162098
+3.3%
0.97x

Prims
718
738
+2.8%
0.97x

Dictionary3OfObjects
860
888
+3.3%
0.97x

RangeAssignment
275
284
+3.3%
0.97x(?)

Hanoi
3168
3272
+3.3%
0.97x(?)

DictionaryRemoveOfObjects
19694
20355
+3.4%
0.97x

Dictionary
732
755
+3.1%
0.97x

StringHasPrefixUnicode
13516
13900
+2.8%
0.97x

ObjectiveCBridgeStubFromArrayOfNSString
58160
59768
+2.8%
0.97x(?)

ObjectiveCBridgeStubFromNSDate
3588
3685
+2.7%
0.97x

Dictionary3
509
531
+4.3%
0.96x

ObjectiveCBridgeStubNSDateMutationRef
11519
12005
+4.2%
0.96x(?)

ObjectiveCBridgeFromNSSetAnyObject
95684
100416
+5.0%
0.95x(?)

**Unoptimized (Onone)**

Regression (13)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeToNSDictionary
16869
71427
+323.4%
0.24x

ObjectiveCBridgeToNSSet
15828
44346
+180.2%
0.36x

DictionaryRemove
17636
24218
+37.3%
0.73x

DictionaryRemoveOfObjects
46913
58152
+24.0%
0.81x

ObjectiveCBridgeFromNSDictionaryAnyObjectForced
7614
9164
+20.4%
0.83x

ObjectiveCBridgeFromNSSetAnyObjectForced
7382
8632
+16.9%
0.86x

ProtocolDispatch
5777
6648
+15.1%
0.87x

ObjectiveCBridgeStubDateMutation
486
547
+12.6%
0.89x

ObjectiveCBridgeFromNSArrayAnyObjectToString
119233
127577
+7.0%
0.93x

ArrayOfGenericPOD
3428
3692
+7.7%
0.93x

ObjectiveCBridgeFromNSSetAnyObject
101443
108544
+7.0%
0.93x

ArrayOfPOD
2327
2513
+8.0%
0.93x

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
92043
97662
+6.1%
0.94x(?)

Improvement (15)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeStubToNSDate
13990
13234
-5.4%
1.06x(?)

RGBHistogramOfObjects
93619
88048
-6.0%
1.06x

DictionarySwapOfObjects
21136
19793
-6.3%
1.07x

SetIsSubsetOf
2446
2288
-6.5%
1.07x

Dictionary
2147
1993
-7.2%
1.08x(?)

Dictionary3
1604
1478
-7.9%
1.09x

MonteCarloE
119267
109292
-8.4%
1.09x

SetIsSubsetOf_OfObjects
2238
2056
-8.1%
1.09x

SetExclusiveOr
30488
26741
-12.3%
1.14x

RGBHistogram
44176
37998
-14.0%
1.16x

Histogram
11788
10088
-14.4%
1.17x

TwoSum
6544
5548
-15.2%
1.18x

DictionarySwap
7569
6208
-18.0%
1.22x

SetUnion
18497
15056
-18.6%
1.23x

NSDictionaryCastToSwift
8350
6231
-25.4%
1.34x

No Changes (108)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeFromNSArrayAnyObjectForced
10653
10184
-4.4%
1.05x(?)

Dictionary3OfObjects
2256
2151
-4.7%
1.05x

SetIntersect_OfObjects
13945
13286
-4.7%
1.05x

SetIntersect
15166
14396
-5.1%
1.05x

StringHasPrefix
1619
1553
-4.1%
1.04x

DictionaryLiteral
17010
16395
-3.6%
1.04x

ObjectiveCBridgeStubToNSDateRef
3399
3311
-2.6%
1.03x

OpenClose
446
433
-2.9%
1.03x(?)

Dictionary2
4460
4352
-2.4%
1.02x(?)

StringEqualPointerComparison
9950
9750
-2.0%
1.02x

AngryPhonebook
3031
2976
-1.8%
1.02x

ObjectiveCBridgeStubNSDateMutationRef
14349
14108
-1.7%
1.02x(?)

Chars
5148
5042
-2.1%
1.02x

ObjectiveCBridgeStubNSDataAppend
2784
2740
-1.6%
1.02x(?)

ObjectiveCBridgeToNSString
1107
1099
-0.7%
1.01x(?)

Prims
13568
13498
-0.5%
1.01x(?)

StringHasSuffixUnicode
65173
64212
-1.5%
1.01x

NSError
687
683
-0.6%
1.01x(?)

DictionaryOfObjects
4886
4816
-1.4%
1.01x

PopFrontArrayGeneric
9784
9729
-0.6%
1.01x

Calculator
1023
1013
-1.0%
1.01x

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
148355
147219
-0.8%
1.01x(?)

ObjectiveCBridgeStubToArrayOfNSString
29848
29487
-1.2%
1.01x(?)

ObjectiveCBridgeStubDataAppend
3330
3284
-1.4%
1.01x(?)

ArrayOfGenericRef
10072
9996
-0.8%
1.01x(?)

StrToInt
5820
5751
-1.2%
1.01x

ArraySubscript
5602
5593
-0.2%
1.00x(?)

MonteCarloPi
53676
53728
+0.1%
1.00x(?)

StackPromo
128376
128383
+0.0%
1.00x(?)

RecursiveOwnedParameter
10929
10882
-0.4%
1.00x(?)

Integrate
365
365
+0.0%
1.00x

ClassArrayGetter
1266
1267
+0.1%
1.00x(?)

Array2D
812061
812892
+0.1%
1.00x(?)

ObjectiveCBridgeStubFromNSDateRef
4087
4107
+0.5%
1.00x

StringWithCString
154983
155015
+0.0%
1.00x(?)

ObjectiveCBridgeFromNSStringForced
3083
3081
-0.1%
1.00x(?)

SortLettersInPlace
2585
2573
-0.5%
1.00x(?)

PopFrontArray
23942
24009
+0.3%
1.00x(?)

ByteSwap
9
9
+0.0%
1.00x

SuperChars
262926
262577
-0.1%
1.00x(?)

XorLoop
19985
19978
-0.0%
1.00x(?)

StringInterpolation
15691
15679
-0.1%
1.00x(?)

ObjectiveCBridgeStubToNSString
1368
1368
+0.0%
1.00x

Join
1458
1464
+0.4%
1.00x(?)

ProtocolDispatch2
443
441
-0.5%
1.00x

HashTest
5403
5422
+0.3%
1.00x

StrComplexWalk
7179
7186
+0.1%
1.00x(?)

ErrorHandling
3824
3813
-0.3%
1.00x(?)

ArrayOfRef
9371
9383
+0.1%
1.00x(?)

ObjectiveCBridgeStubURLAppendPathRef
239098
237962
-0.5%
1.00x(?)

PopFrontUnsafePointer
258693
258759
+0.0%
1.00x(?)

CaptureProp
115855
115720
-0.1%
1.00x

MapReduce
45212
45116
-0.2%
1.00x

IterateData
10587
10592
+0.1%
1.00x(?)

UTF8Decode
43484
43513
+0.1%
1.00x(?)

ObjectiveCBridgeStubURLAppendPath
236641
236020
-0.3%
1.00x(?)

SortStringsUnicode
9331
9304
-0.3%
1.00x

StringBuilder
2739
2743
+0.1%
1.00x(?)

ArrayInClass
3953
3956
+0.1%
1.00x(?)

Sim2DArray
14584
14571
-0.1%
1.00x(?)

GlobalClass
0
0
+0.0%
1.00x

Walsh
13101
13094
-0.1%
1.00x(?)

ArrayAppend
3359
3359
+0.0%
1.00x

DeadArray
121326
120767
-0.5%
1.00x(?)

ArrayLiteral
1245
1246
+0.1%
1.00x(?)

StringWalk
21335
21393
+0.3%
1.00x(?)

ArrayValueProp
2614
2627
+0.5%
1.00x(?)

RC4
9371
9370
-0.0%
1.00x(?)

Memset
20644
20667
+0.1%
1.00x(?)

ArrayValueProp4
3008
3016
+0.3%
1.00x(?)

ArrayValueProp2
3132
3135
+0.1%
1.00x

ArrayValueProp3
3088
3076
-0.4%
1.00x

RangeAssignment
27531
27927
+1.4%
0.99x(?)

StaticArray
34941
35184
+0.7%
0.99x(?)

ObjectAllocation
560
563
+0.5%
0.99x(?)

TypeFlood
192
193
+0.5%
0.99x(?)

AnyHashableWithAClass
77424
77869
+0.6%
0.99x

ObjectiveCBridgeToNSArray
30157
30369
+0.7%
0.99x(?)

PolymorphicCalls
1129
1140
+1.0%
0.99x

ObjectiveCBridgeStubToNSStringRef
155
157
+1.3%
0.99x

ObjectiveCBridgeFromNSArrayAnyObject
78701
79220
+0.7%
0.99x(?)

Phonebook
62983
63462
+0.8%
0.99x(?)

SetExclusiveOr_OfObjects
46713
47346
+1.4%
0.99x

StringHasPrefixUnicode
15202
15420
+1.4%
0.99x

LinkedList
27705
28018
+1.1%
0.99x

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
120052
121114
+0.9%
0.99x(?)

ArrayAppendReserved
3100
3116
+0.5%
0.99x

BitCount
102
103
+1.0%
0.99x

SevenBoom
1495
1508
+0.9%
0.99x

ObjectiveCBridgeStubFromArrayOfNSString
59250
59790
+0.9%
0.99x(?)

Dictionary2OfObjects
6307
6341
+0.5%
0.99x(?)

ObjectiveCBridgeStubFromNSStringRef
159
162
+1.9%
0.98x

Hanoi
20360
20678
+1.6%
0.98x

ObjectiveCBridgeFromNSSetAnyObjectToString
164340
167465
+1.9%
0.98x(?)

ObjectiveCBridgeStubDateAccess
1095
1122
+2.5%
0.98x

SetUnion_OfObjects
34431
35179
+2.2%
0.98x

ObjectiveCBridgeFromNSString
5057
5149
+1.8%
0.98x(?)

135
5414508
5597892
+3.4%
0.97x

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
217154
224981
+3.6%
0.97x(?)

SortStrings
2701
2780
+2.9%
0.97x

DictionaryBridge
3908
4047
+3.6%
0.97x(?)

ObjectiveCBridgeStubFromNSString
810
836
+3.2%
0.97x

ObjectiveCBridgeStubNSDateRefAccess
1199
1231
+2.7%
0.97x

NSStringConversion
2946
3024
+2.6%
0.97x(?)

StringHasSuffix
1571
1641
+4.5%
0.96x

ObjectiveCBridgeStubFromNSDate
3752
3928
+4.7%
0.96x

ObjectiveCBridgeFromNSDictionaryAnyObject
209223
220652
+5.5%
0.95x(?)

NopDeinit
59602
62618
+5.1%
0.95x

**Hardware Overview**
      Model Name: Mac mini
      Model Identifier: Macmini7,1
      Processor Name: Intel Core i5
      Processor Speed: 2.8 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Memory: 16 GB

Build comment file:
Optimized (O)

Regression (11)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeToNSDictionary
16221
71512
+340.9%
0.23x

ObjectiveCBridgeToNSSet
15585
44081
+182.8%
0.35x

ObjectiveCBridgeFromNSDictionaryAnyObjectForced
5268
6666
+26.5%
0.79x

ObjectiveCBridgeFromNSSetAnyObjectForced
4548
5703
+25.4%
0.80x

StringHasPrefix
609
724
+18.9%
0.84x

SetExclusiveOr
2632
3050
+15.9%
0.86x

CaptureProp
4021
4565
+13.5%
0.88x

StringHasSuffix
705
800
+13.5%
0.88x

ObjectiveCBridgeStubNSDateRefAccess
308
338
+9.7%
0.91x

ObjectiveCBridgeFromNSDictionaryAnyObject
203873
216049
+6.0%
0.94x

ObjectiveCBridgeStubFromNSString
747
792
+6.0%
0.94x

Improvement (14)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

DictionarySwapOfObjects
6765
6386
-5.6%
1.06x

TwoSum
1576
1420
-9.9%
1.11x

RGBHistogram
2811
2442
-13.1%
1.15x

SetUnion
2985
2516
-15.7%
1.19x

StringWithCString
198753
156023
-21.5%
1.27x(?)

DictionarySwap
628
477
-24.0%
1.32x

NSDictionaryCastToSwift
6974
5025
-27.9%
1.39x

SetIntersect_OfObjects
2286
1514
-33.8%
1.51x

DictionaryRemove
4595
2956
-35.7%
1.55x

SetIsSubsetOf_OfObjects
524
316
-39.7%
1.66x

Histogram
656
334
-49.1%
1.96x

DictionaryLiteral
2760
1384
-49.9%
1.99x

SetIsSubsetOf
510
247
-51.6%
2.06x

SetIntersect
1072
424
-60.5%
2.53x

No Changes (111)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeStubFromNSDateRef
3792
3653
-3.7%
1.04x

StrToInt
5221
5037
-3.5%
1.04x

SortStringsUnicode
8075
7867
-2.6%
1.03x

SortStrings
1757
1731
-1.5%
1.02x

HashTest
1758
1732
-1.5%
1.02x

SetExclusiveOr_OfObjects
7943
7795
-1.9%
1.02x

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
91607
89975
-1.8%
1.02x(?)

Array2D
2037
2026
-0.5%
1.01x(?)

SortLettersInPlace
980
969
-1.1%
1.01x

ObjectiveCBridgeStubToNSDate
13557
13377
-1.3%
1.01x(?)

ErrorHandling
2941
2905
-1.2%
1.01x(?)

ProtocolDispatch2
159
157
-1.3%
1.01x(?)

AngryPhonebook
2817
2799
-0.6%
1.01x(?)

ObjectiveCBridgeStubToArrayOfNSString
29466
29207
-0.9%
1.01x(?)

ObjectiveCBridgeStubDataAppend
2975
2947
-0.9%
1.01x(?)

RGBHistogramOfObjects
21938
21783
-0.7%
1.01x(?)

Chars
631
623
-1.3%
1.01x

ArraySubscript
1425
1420
-0.3%
1.00x(?)

ObjectiveCBridgeToNSString
1072
1068
-0.4%
1.00x(?)

MonteCarloPi
44953
44987
+0.1%
1.00x(?)

StackPromo
21507
21587
+0.4%
1.00x(?)

PopFrontArray
1110
1115
+0.5%
1.00x(?)

RecursiveOwnedParameter
1935
1936
+0.1%
1.00x(?)

Integrate
238
238
+0.0%
1.00x

ClassArrayGetter
12
12
+0.0%
1.00x

ArrayOfGenericPOD
220
220
+0.0%
1.00x

ObjectiveCBridgeFromNSArrayAnyObjectForced
6248
6269
+0.3%
1.00x(?)

ObjectiveCBridgeFromNSStringForced
2647
2650
+0.1%
1.00x(?)

ByteSwap
0
0
+0.0%
1.00x

SuperChars
211113
210955
-0.1%
1.00x(?)

XorLoop
380
380
+0.0%
1.00x

StringInterpolation
10940
10893
-0.4%
1.00x(?)

ObjectiveCBridgeStubToNSString
1283
1284
+0.1%
1.00x(?)

ObjectiveCBridgeStubFromNSStringRef
128
128
+0.0%
1.00x

ProtocolDispatch
3039
3040
+0.0%
1.00x(?)

ObjectAllocation
153
153
+0.0%
1.00x

TypeFlood
0
0
+0.0%
1.00x

ArrayLiteral
1175
1180
+0.4%
1.00x(?)

StrComplexWalk
2880
2872
-0.3%
1.00x(?)

ArrayOfRef
3535
3551
+0.5%
1.00x(?)

ObjectiveCBridgeStubURLAppendPathRef
235998
235535
-0.2%
1.00x(?)

ObjectiveCBridgeStubDateMutation
273
273
+0.0%
1.00x

NSError
325
326
+0.3%
1.00x(?)

ObjectiveCBridgeStubToNSDateRef
3289
3284
-0.1%
1.00x(?)

PopFrontArrayGeneric
1117
1115
-0.2%
1.00x(?)

PopFrontUnsafePointer
9176
9207
+0.3%
1.00x(?)

StringEqualPointerComparison
7297
7299
+0.0%
1.00x(?)

PolymorphicCalls
22
22
+0.0%
1.00x

RC4
165
165
+0.0%
1.00x

ObjectiveCBridgeStubToNSStringRef
116
116
+0.0%
1.00x

Calculator
33
33
+0.0%
1.00x

MapReduce
342
342
+0.0%
1.00x

OpenClose
54
54
+0.0%
1.00x

UTF8Decode
288
288
+0.0%
1.00x

ObjectiveCBridgeStubURLAppendPath
235772
234761
-0.4%
1.00x(?)

NopDeinit
36646
36626
-0.1%
1.00x(?)

StringBuilder
1319
1318
-0.1%
1.00x(?)

Phonebook
7056
7091
+0.5%
1.00x(?)

ObjectiveCBridgeStubDateAccess
182
182
+0.0%
1.00x

Sim2DArray
277
277
+0.0%
1.00x

ArrayAppend
772
772
+0.0%
1.00x

LinkedList
7245
7254
+0.1%
1.00x(?)

ArrayValueProp4
6
6
+0.0%
1.00x

ArrayOfPOD
182
182
+0.0%
1.00x

DeadArray
185
185
+0.0%
1.00x

ArrayValueProp2
6
6
+0.0%
1.00x

BitCount
1
1
+0.0%
1.00x

AnyHashableWithAClass
63849
63732
-0.2%
1.00x(?)

ArrayValueProp3
6
6
+0.0%
1.00x

ArrayValueProp
6
6
+0.0%
1.00x

GlobalClass
0
0
+0.0%
1.00x

Memset
235
235
+0.0%
1.00x

ArrayAppendReserved
536
536
+0.0%
1.00x

StaticArray
2748
2769
+0.8%
0.99x(?)

ObjectiveCBridgeToNSArray
30079
30272
+0.6%
0.99x(?)

DictionaryOfObjects
2286
2312
+1.1%
0.99x

ArrayOfGenericRef
3578
3599
+0.6%
0.99x(?)

ObjectiveCBridgeFromNSString
1767
1788
+1.2%
0.99x(?)

MonteCarloE
10479
10584
+1.0%
0.99x(?)

SetUnion_OfObjects
6617
6666
+0.7%
0.99x(?)

StringHasSuffixUnicode
63309
63803
+0.8%
0.99x

Walsh
309
312
+1.0%
0.99x(?)

StringWalk
5877
5915
+0.7%
0.99x(?)

ObjectiveCBridgeStubNSDateMutationRef
12025
12184
+1.3%
0.99x(?)

SevenBoom
1342
1358
+1.2%
0.99x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
212369
215884
+1.7%
0.98x(?)

Dictionary2
2030
2077
+2.3%
0.98x(?)

Join
459
470
+2.4%
0.98x

IterateData
2554
2596
+1.6%
0.98x

ArrayInClass
62
63
+1.6%
0.98x(?)

NSStringConversion
790
805
+1.9%
0.98x

ObjectiveCBridgeStubFromArrayOfNSString
59049
60553
+2.5%
0.98x(?)

Dictionary2OfObjects
3373
3450
+2.3%
0.98x(?)

ObjectiveCBridgeStubNSDataAppend
2443
2496
+2.2%
0.98x(?)

DictionaryBridge
3847
3953
+2.8%
0.97x(?)

Prims
718
737
+2.6%
0.97x(?)

Dictionary3OfObjects
859
888
+3.4%
0.97x

RangeAssignment
275
284
+3.3%
0.97x(?)

Hanoi
3171
3274
+3.2%
0.97x

DictionaryRemoveOfObjects
19681
20333
+3.3%
0.97x

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
135602
140372
+3.5%
0.97x(?)

Dictionary
734
755
+2.9%
0.97x

ObjectiveCBridgeFromNSArrayAnyObject
76055
78096
+2.7%
0.97x(?)

ObjectiveCBridgeFromNSSetAnyObjectToString
146789
150765
+2.7%
0.97x(?)

StringHasPrefixUnicode
13525
13892
+2.7%
0.97x

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
106549
110274
+3.5%
0.97x(?)

ObjectiveCBridgeStubFromNSDate
3589
3683
+2.6%
0.97x

Dictionary3
510
531
+4.1%
0.96x

135
3029973
3189406
+5.3%
0.95x

ObjectiveCBridgeFromNSArrayAnyObjectToString
116930
122991
+5.2%
0.95x(?)

ObjectiveCBridgeFromNSSetAnyObject
96290
100886
+4.8%
0.95x(?)

**Unoptimized (Onone)**

Regression (12)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeToNSDictionary
16521
71903
+335.2%
0.23x

ObjectiveCBridgeToNSSet
16092
44588
+177.1%
0.36x

DictionaryRemove
17830
24266
+36.1%
0.73x

DictionaryRemoveOfObjects
47040
58210
+23.8%
0.81x

ObjectiveCBridgeFromNSSetAnyObjectForced
7393
8798
+19.0%
0.84x

ProtocolDispatch
5778
6654
+15.2%
0.87x

ObjectiveCBridgeFromNSDictionaryAnyObjectForced
8074
9114
+12.9%
0.89x

ObjectiveCBridgeStubDateMutation
486
547
+12.6%
0.89x

TypeFlood
191
209
+9.4%
0.91x(?)

ArrayOfGenericPOD
3428
3694
+7.8%
0.93x

ArrayOfPOD
2331
2514
+7.8%
0.93x

ObjectiveCBridgeStubFromNSDate
3743
3973
+6.1%
0.94x

Improvement (14)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

RGBHistogramOfObjects
93603
87964
-6.0%
1.06x

DictionarySwapOfObjects
21466
20138
-6.2%
1.07x

SetIsSubsetOf
2460
2287
-7.0%
1.08x

Dictionary
2150
1992
-7.3%
1.08x

Dictionary3
1613
1480
-8.2%
1.09x

MonteCarloE
119161
108965
-8.6%
1.09x

SetIsSubsetOf_OfObjects
2238
2056
-8.1%
1.09x

SetExclusiveOr
30496
26719
-12.4%
1.14x

RGBHistogram
44317
38174
-13.9%
1.16x

Histogram
11865
10179
-14.2%
1.17x

TwoSum
6570
5557
-15.4%
1.18x

DictionarySwap
7499
6216
-17.1%
1.21x

SetUnion
18468
15053
-18.5%
1.23x

NSDictionaryCastToSwift
8322
6225
-25.2%
1.34x

No Changes (110)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

Dictionary3OfObjects
2262
2145
-5.2%
1.05x

SetIntersect_OfObjects
13959
13273
-4.9%
1.05x

SetIntersect
15163
14393
-5.1%
1.05x(?)

StringHasPrefix
1621
1554
-4.1%
1.04x

ObjectiveCBridgeStubToNSDate
13918
13448
-3.4%
1.03x(?)

Dictionary2
4444
4333
-2.5%
1.03x

NSError
689
671
-2.6%
1.03x(?)

OpenClose
445
432
-2.9%
1.03x

StackPromo
129505
127054
-1.9%
1.02x(?)

StringHasSuffixUnicode
65189
64175
-1.6%
1.02x

ObjectiveCBridgeStubToNSDateRef
3353
3295
-1.7%
1.02x(?)

StringEqualPointerComparison
9975
9770
-2.1%
1.02x

AngryPhonebook
3035
2982
-1.8%
1.02x

ObjectiveCBridgeStubURLAppendPath
241745
235915
-2.4%
1.02x(?)

ObjectiveCBridgeStubToArrayOfNSString
30038
29450
-2.0%
1.02x(?)

ObjectiveCBridgeFromNSSetAnyObjectToString
168542
164929
-2.1%
1.02x(?)

Chars
5135
5042
-1.8%
1.02x

StrToInt
5840
5743
-1.7%
1.02x

ObjectiveCBridgeToNSString
1110
1102
-0.7%
1.01x

Prims
13614
13460
-1.1%
1.01x

ObjectAllocation
562
558
-0.7%
1.01x(?)

ObjectiveCBridgeStubURLAppendPathRef
240341
238628
-0.7%
1.01x(?)

DictionaryOfObjects
4878
4827
-1.1%
1.01x(?)

Calculator
1024
1012
-1.2%
1.01x

DictionaryLiteral
16649
16433
-1.3%
1.01x(?)

ObjectiveCBridgeStubDataAppend
3336
3306
-0.9%
1.01x(?)

StringBuilder
2787
2767
-0.7%
1.01x(?)

ArrayOfGenericRef
10069
10014
-0.6%
1.01x

Phonebook
63366
62671
-1.1%
1.01x(?)

ObjectiveCBridgeStubNSDateMutationRef
14219
14128
-0.6%
1.01x(?)

ObjectiveCBridgeStubNSDataAppend
2817
2781
-1.3%
1.01x(?)

ArraySubscript
5611
5603
-0.1%
1.00x(?)

MonteCarloPi
53697
53746
+0.1%
1.00x(?)

RecursiveOwnedParameter
10935
10888
-0.4%
1.00x(?)

Integrate
365
365
+0.0%
1.00x

ClassArrayGetter
1266
1266
+0.0%
1.00x

Array2D
811603
812542
+0.1%
1.00x(?)

ObjectiveCBridgeStubFromNSDateRef
4094
4106
+0.3%
1.00x(?)

StringWithCString
154760
154692
-0.0%
1.00x(?)

ObjectiveCBridgeFromNSStringForced
3083
3085
+0.1%
1.00x(?)

SortLettersInPlace
2578
2574
-0.2%
1.00x(?)

RangeAssignment
27645
27682
+0.1%
1.00x(?)

ByteSwap
9
9
+0.0%
1.00x

SuperChars
263090
262727
-0.1%
1.00x(?)

XorLoop
19990
19980
-0.1%
1.00x(?)

StringInterpolation
15726
15769
+0.3%
1.00x(?)

ObjectiveCBridgeStubToNSString
1367
1369
+0.1%
1.00x(?)

Join
1463
1462
-0.1%
1.00x(?)

StaticArray
34781
34794
+0.0%
1.00x(?)

ProtocolDispatch2
443
441
-0.5%
1.00x

HashTest
5406
5414
+0.1%
1.00x(?)

StrComplexWalk
7190
7178
-0.2%
1.00x(?)

ErrorHandling
3818
3831
+0.3%
1.00x(?)

ArrayOfRef
9399
9402
+0.0%
1.00x(?)

PopFrontUnsafePointer
258746
258838
+0.0%
1.00x(?)

CaptureProp
116208
115684
-0.5%
1.00x

MapReduce
45179
45154
-0.1%
1.00x(?)

IterateData
10564
10598
+0.3%
1.00x

UTF8Decode
43497
43449
-0.1%
1.00x(?)

SortStringsUnicode
9337
9308
-0.3%
1.00x(?)

ArrayInClass
3957
3957
+0.0%
1.00x

Sim2DArray
14580
14572
-0.1%
1.00x(?)

GlobalClass
0
0
+0.0%
1.00x

Walsh
13111
13104
-0.1%
1.00x(?)

ArrayAppend
3360
3360
+0.0%
1.00x

DeadArray
120697
120840
+0.1%
1.00x(?)

ArrayLiteral
1249
1245
-0.3%
1.00x(?)

ArrayValueProp
2614
2620
+0.2%
1.00x(?)

RC4
9375
9371
-0.0%
1.00x(?)

Memset
20642
20658
+0.1%
1.00x(?)

ArrayValueProp4
3016
3016
+0.0%
1.00x

ArrayValueProp2
3134
3139
+0.2%
1.00x(?)

ArrayValueProp3
3092
3077
-0.5%
1.00x

PopFrontArray
23863
24086
+0.9%
0.99x(?)

DictionaryBridge
3963
4002
+1.0%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObjectForced
10560
10637
+0.7%
0.99x(?)

AnyHashableWithAClass
77461
77888
+0.6%
0.99x(?)

PolymorphicCalls
1130
1141
+1.0%
0.99x

ObjectiveCBridgeStubToNSStringRef
155
157
+1.3%
0.99x

Hanoi
20387
20654
+1.3%
0.99x

ObjectiveCBridgeStubDateAccess
1097
1107
+0.9%
0.99x(?)

SetExclusiveOr_OfObjects
46745
47412
+1.4%
0.99x(?)

StringHasPrefixUnicode
15205
15428
+1.5%
0.99x

LinkedList
27598
27949
+1.3%
0.99x

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
120095
121796
+1.4%
0.99x(?)

NSStringConversion
2960
2998
+1.3%
0.99x(?)

ArrayAppendReserved
3100
3117
+0.6%
0.99x

BitCount
102
103
+1.0%
0.99x

SevenBoom
1491
1502
+0.7%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
92210
93275
+1.1%
0.99x(?)

Dictionary2OfObjects
6270
6336
+1.1%
0.99x(?)

135
5463770
5598820
+2.5%
0.98x

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
217269
221670
+2.0%
0.98x(?)

ObjectiveCBridgeStubFromNSStringRef
158
162
+2.5%
0.98x

PopFrontArrayGeneric
9573
9736
+1.7%
0.98x(?)

ObjectiveCBridgeFromNSArrayAnyObject
79104
81037
+2.4%
0.98x(?)

SetUnion_OfObjects
34453
35207
+2.2%
0.98x(?)

StringWalk
21365
21875
+2.4%
0.98x

ObjectiveCBridgeFromNSString
5049
5147
+1.9%
0.98x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToString
121484
125416
+3.2%
0.97x(?)

SortStrings
2702
2782
+3.0%
0.97x

ObjectiveCBridgeStubFromNSString
811
835
+3.0%
0.97x

ObjectiveCBridgeToNSArray
29860
30667
+2.7%
0.97x(?)

ObjectiveCBridgeStubNSDateRefAccess
1201
1235
+2.8%
0.97x

ObjectiveCBridgeStubFromArrayOfNSString
59381
61265
+3.2%
0.97x(?)

StringHasSuffix
1571
1642
+4.5%
0.96x

ObjectiveCBridgeFromNSDictionaryAnyObject
208320
219970
+5.6%
0.95x(?)

ObjectiveCBridgeFromNSSetAnyObject
101731
107437
+5.6%
0.95x

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
143381
151662
+5.8%
0.95x

NopDeinit
59641
62608
+5.0%
0.95x

**Hardware Overview**
      Model Name: Mac mini
      Model Identifier: Macmini7,1
      Processor Name: Intel Core i5
      Processor Speed: 2.8 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Memory: 16 GB

on Thu Oct 20 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

Gankro commented on this pull request.

     return true

   }

 if lhsNative.count != rhsNative.count {

 if lhsNative._count != rhsNative._count {

What does it mean for a field to be an implementation detail, when the
containing type is entirely implementation detail? Just that the other
parts that use it shouldn't directly make use of that particular
implementation detail?

Yes.

Why aren't we just taking advantage of Swift's privacy system for
this?

Because we can't use private/fileprivate due to the way the standard
library is compiled.  Ask Jordan if you want more detail.  I don't
understand why, but it's a restriction we have always had to live with.

To be clear, all of the Storage/Buffer types, I believe, could be
marked fileprivate with no impact.

Would that it were so!
--
-Dave

@swift-ci Please Smoke Test

@swift-ci Please smoke test

on Thu Nov 03 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

From a quick skim, It makes the common mistake of using
tombstones. Other things seem solid.

That should not be a problem, as they are incidental to the point,
right?

on Thu Nov 03 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

A small one: emptying out a dictionary doesn't regress it to the empty storage. Only constructing it
without any capacity (e.g. init()) does.

OK, I think I was being to nitpicky; the language is fine in context.
--
-Dave

on Thu Nov 03 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

Can you elaborate on what the correct code for this might be? I'm still learning all the different
cast idioms here. Gut: changed .bridged() to return _NSSet.

I can't find this comment/commit from the GitHub web interface (!) so
it's hard to say, but if you can have .bridged() return _NSSet
without introducing any unsafeBitCasts, that's almost certainly the
right answer!
--
-Dave

@swift-ci Please smoke test

@swift-ci please benchmark

@dabrahams I believe I've addressed all of your comments
(also fixed a mem-safety bug, yay!)

@swift-ci Please smoke test

on Thu Nov 03 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

@dabrahams I believe I've addressed all of your comments

W00t! I trust that it's ready to go as soon as the tests pass; feel free
to merge then.

@swift-ci please smoke test

@swift-ci Please benchmark

@swift-ci Please smoke test

@swift-ci Please smoke test

@swift-ci Please smoke test

Build comment file:
Optimized (O)

Regression (5)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeToNSDictionary
16291
70358
+331.9%
0.23x

ObjectiveCBridgeToNSSet
15242
43852
+187.7%
0.35x

ObjectiveCBridgeFromNSDictionaryAnyObjectForced
5260
6454
+22.7%
0.81x

ObjectiveCBridgeFromNSSetAnyObjectForced
4556
5651
+24.0%
0.81x

ArraySubscript
1435
1525
+6.3%
0.94x

Improvement (20)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeStubFromNSDate
3644
3408
-6.5%
1.07x(?)

MapReduce
373
342
-8.3%
1.09x

StrToInt
5495
5057
-8.0%
1.09x

PopFrontArrayGeneric
1229
1119
-8.9%
1.10x(?)

DictionarySwapOfObjects
6753
6046
-10.5%
1.12x

OpenClose
59
51
-13.6%
1.16x

ProtocolDispatch2
187
160
-14.4%
1.17x

CaptureProp
4882
4136
-15.3%
1.18x

TwoSum
1582
1341
-15.2%
1.18x

RGBHistogram
2826
2296
-18.8%
1.23x

SetUnion
2984
2185
-26.8%
1.37x

NSDictionaryCastToSwift
6913
5001
-27.7%
1.38x

SetIntersect_OfObjects
2272
1494
-34.2%
1.52x

DictionarySwap
632
410
-35.1%
1.54x

SetIsSubsetOf_OfObjects
523
310
-40.7%
1.69x

DictionaryRemove
4604
2492
-45.9%
1.85x

DictionaryLiteral
2730
1291
-52.7%
2.11x

SetIsSubsetOf
508
237
-53.4%
2.14x

Histogram
656
288
-56.1%
2.28x

SetIntersect
1084
308
-71.6%
3.52x

No Changes (122)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

PolymorphicCalls
22
21
-4.5%
1.05x

SetExclusiveOr_OfObjects
7947
7533
-5.2%
1.05x

NopDeinit
38085
36627
-3.8%
1.04x

SetUnion_OfObjects
6630
6355
-4.2%
1.04x

SortStrings
1837
1784
-2.9%
1.03x

ObjectiveCBridgeFromNSString
1844
1784
-3.2%
1.03x(?)

ObjectiveCBridgeStubToNSDate
13840
13389
-3.3%
1.03x(?)

AnyHashableWithAClass
66545
64661
-2.8%
1.03x

Calculator
36
35
-2.8%
1.03x

StringHasSuffix
800
780
-2.5%
1.03x(?)

ErrorHandling
2934
2877
-1.9%
1.02x(?)

HashTest
1752
1710
-2.4%
1.02x

SetExclusiveOr
2628
2589
-1.5%
1.02x(?)

ArrayInClass
63
62
-1.6%
1.02x(?)

RGBHistogramOfObjects
22008
21554
-2.1%
1.02x

DeadArray
185
182
-1.6%
1.02x

StackPromo
21618
21489
-0.6%
1.01x(?)

PopFrontArray
1128
1120
-0.7%
1.01x(?)

SuperChars
213338
212245
-0.5%
1.01x(?)

ObjectiveCBridgeStubFromNSStringRef
131
130
-0.8%
1.01x(?)

StringHasSuffixUnicode
63105
62636
-0.7%
1.01x

ArrayOfRef
3544
3526
-0.5%
1.01x(?)

ObjectiveCBridgeToNSArray
30450
30145
-1.0%
1.01x(?)

PopFrontUnsafePointer
9175
9124
-0.6%
1.01x(?)

StringEqualPointerComparison
7361
7302
-0.8%
1.01x(?)

ObjectiveCBridgeStubURLAppendPath
231609
229097
-1.1%
1.01x(?)

SortStringsUnicode
8335
8221
-1.4%
1.01x

Dictionary
740
734
-0.8%
1.01x

ObjectiveCBridgeStubDataAppend
2948
2931
-0.6%
1.01x(?)

ArrayOfGenericRef
3611
3580
-0.9%
1.01x(?)

MonteCarloE
10501
10430
-0.7%
1.01x(?)

Walsh
312
310
-0.6%
1.01x(?)

StringHasPrefixUnicode
13705
13541
-1.2%
1.01x

LinkedList
7268
7226
-0.6%
1.01x(?)

Chars
630
625
-0.8%
1.01x

ObjectiveCBridgeStubNSDateMutationRef
12365
12270
-0.8%
1.01x(?)

ObjectiveCBridgeToNSString
1071
1074
+0.3%
1.00x(?)

MonteCarloPi
45008
45000
-0.0%
1.00x(?)

RecursiveOwnedParameter
1933
1934
+0.1%
1.00x(?)

ObjectiveCBridgeStubToNSString
1281
1278
-0.2%
1.00x(?)

ClassArrayGetter
12
12
+0.0%
1.00x

Array2D
2029
2027
-0.1%
1.00x(?)

ObjectiveCBridgeStubFromNSDateRef
3712
3708
-0.1%
1.00x(?)

StringWithCString
154915
154981
+0.0%
1.00x(?)

ObjectiveCBridgeFromNSStringForced
2670
2660
-0.4%
1.00x(?)

Prims
738
735
-0.4%
1.00x(?)

SortLettersInPlace
975
974
-0.1%
1.00x(?)

StringHasPrefix
732
731
-0.1%
1.00x(?)

ByteSwap
0
0
+0.0%
1.00x

ArrayAppendGenericStructs
1233
1232
-0.1%
1.00x(?)

XorLoop
380
380
+0.0%
1.00x

ObserverClosure
1956
1964
+0.4%
1.00x(?)

Integrate
239
240
+0.4%
1.00x(?)

ArrayAppendStrings
12108
12123
+0.1%
1.00x(?)

ObjectiveCBridgeStubFromNSString
761
764
+0.4%
1.00x(?)

StaticArray
2737
2746
+0.3%
1.00x(?)

ProtocolDispatch
3040
3041
+0.0%
1.00x(?)

TypeFlood
0
0
+0.0%
1.00x

Dictionary2
2061
2058
-0.1%
1.00x(?)

ObserverUnappliedMethod
2380
2376
-0.2%
1.00x(?)

ObjectiveCBridgeStubURLAppendPathRef
230842
230887
+0.0%
1.00x(?)

ObjectiveCBridgeStubDateMutation
273
273
+0.0%
1.00x

NSError
325
325
+0.0%
1.00x

ObjectiveCBridgeStubToNSDateRef
3274
3280
+0.2%
1.00x(?)

ArrayAppendReserved
536
536
+0.0%
1.00x

ObjectiveCBridgeStubToNSStringRef
116
116
+0.0%
1.00x

ArrayAppendOptionals
1233
1230
-0.2%
1.00x(?)

ArrayOfGenericPOD
220
220
+0.0%
1.00x

DictionaryRemoveOfObjects
19727
19720
-0.0%
1.00x(?)

UTF8Decode
288
288
+0.0%
1.00x

ObjectiveCBridgeStubToArrayOfNSString
29347
29341
-0.0%
1.00x(?)

ObjectiveCBridgeFromNSArrayAnyObject
75660
75950
+0.4%
1.00x(?)

ObjectiveCBridgeStubNSDateRefAccess
308
308
+0.0%
1.00x

StringBuilder
1311
1317
+0.5%
1.00x(?)

ObjectiveCBridgeStubDateAccess
182
182
+0.0%
1.00x

Sim2DArray
277
277
+0.0%
1.00x

ArrayAppendRepeatCol
643
643
+0.0%
1.00x

RC4
165
165
+0.0%
1.00x

ArrayAppend
775
775
+0.0%
1.00x

ArrayAppendSequence
1062
1061
-0.1%
1.00x(?)

ArrayAppendArrayOfInt
599
599
+0.0%
1.00x

ArrayOfPOD
182
182
+0.0%
1.00x

ObserverForwarderStruct
899
895
-0.4%
1.00x(?)

ObjectiveCBridgeStubNSDataAppend
2398
2395
-0.1%
1.00x(?)

BitCount
1
1
+0.0%
1.00x

AngryPhonebook
2817
2815
-0.1%
1.00x(?)

SevenBoom
1355
1354
-0.1%
1.00x(?)

StringWalk
5879
5896
+0.3%
1.00x(?)

ArrayValueProp
6
6
+0.0%
1.00x

GlobalClass
0
0
+0.0%
1.00x

Memset
235
235
+0.0%
1.00x

ArrayValueProp4
6
6
+0.0%
1.00x

ArrayValueProp2
6
6
+0.0%
1.00x

ArrayValueProp3
6
6
+0.0%
1.00x

ObserverPartiallyAppliedMethod
3338
3345
+0.2%
1.00x(?)

DictionaryBridge
3780
3834
+1.4%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObjectForced
6082
6171
+1.5%
0.99x(?)

RangeAssignment
281
284
+1.1%
0.99x(?)

ArrayAppendLazyMap
842
852
+1.2%
0.99x(?)

ObjectAllocation
152
153
+0.7%
0.99x(?)

ArrayLiteral
1173
1181
+0.7%
0.99x(?)

StrComplexWalk
2886
2906
+0.7%
0.99x(?)

DictionaryOfObjects
2286
2312
+1.1%
0.99x(?)

Phonebook
7513
7613
+1.3%
0.99x

NSStringConversion
799
811
+1.5%
0.99x(?)

ObjectiveCBridgeStubFromArrayOfNSString
58803
59222
+0.7%
0.99x(?)

StringInterpolation
10778
10993
+2.0%
0.98x(?)

Join
464
472
+1.7%
0.98x

IterateData
2546
2597
+2.0%
0.98x

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
135467
138904
+2.5%
0.98x(?)

Dictionary2OfObjects
3378
3439
+1.8%
0.98x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
209584
216079
+3.1%
0.97x(?)

ObjectiveCBridgeFromNSSetAnyObject
90521
93338
+3.1%
0.97x(?)

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
106562
109768
+3.0%
0.97x(?)

146
3040151
3142544
+3.4%
0.97x

ObjectiveCBridgeFromNSDictionaryAnyObject
194886
203999
+4.7%
0.96x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToString
118010
122316
+3.6%
0.96x(?)

Dictionary3OfObjects
857
891
+4.0%
0.96x

Hanoi
3344
3472
+3.8%
0.96x

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
90346
94366
+4.5%
0.96x(?)

Dictionary3
511
536
+4.9%
0.95x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
92206
97576
+5.8%
0.94x

Improvement (20)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

TypeFlood
210
198
-5.7%
1.06x(?)

SetIntersect_OfObjects
14090
13253
-5.9%
1.06x

Calculator
984
929
-5.6%
1.06x

SetIntersect
15199
14321
-5.8%
1.06x

Dictionary3OfObjects
2239
2085
-6.9%
1.07x

ObjectiveCBridgeStubFromNSDate
3993
3718
-6.9%
1.07x

DictionarySwapOfObjects
20841
19243
-7.7%
1.08x

RGBHistogramOfObjects
93478
86857
-7.1%
1.08x

SetIsSubsetOf
2449
2248
-8.2%
1.09x

Dictionary3
1607
1460
-9.2%
1.10x

Dictionary
2137
1937
-9.4%
1.10x

SetIsSubsetOf_OfObjects
2228
2032
-8.8%
1.10x

BitCount
108
96
-11.1%
1.12x

SetExclusiveOr
30625
26437
-13.7%
1.16x

Histogram
11731
9834
-16.2%
1.19x

RGBHistogram
44452
37212
-16.3%
1.19x

TwoSum
6577
5417
-17.6%
1.21x

SetUnion
18388
14883
-19.1%
1.24x

DictionarySwap
7510
5996
-20.2%
1.25x

NSDictionaryCastToSwift
8251
6223
-24.6%
1.33x

No Changes (115)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ArrayAppendGenericStructs
1348
1292
-4.2%
1.04x(?)

Dictionary2
4466
4302
-3.7%
1.04x

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
125236
120376
-3.9%
1.04x(?)

AnyHashableWithAClass
80987
79004
-2.5%
1.03x

ObjectiveCBridgeToNSArray
30969
30064
-2.9%
1.03x(?)

DictionaryOfObjects
4890
4749
-2.9%
1.03x

ObjectiveCBridgeStubNSDataAppend
2835
2757
-2.8%
1.03x

ObjectiveCBridgeFromNSArrayAnyObjectForced
10606
10443
-1.5%
1.02x(?)

Prims
13597
13395
-1.5%
1.02x

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
142662
140430
-1.6%
1.02x(?)

ObjectiveCBridgeStubToArrayOfNSString
29930
29475
-1.5%
1.02x(?)

StrToInt
5910
5800
-1.9%
1.02x

ObjectiveCBridgeFromNSStringForced
3068
3052
-0.5%
1.01x

SortLettersInPlace
2569
2555
-0.5%
1.01x

PopFrontArray
24477
24343
-0.6%
1.01x(?)

StringInterpolation
15773
15622
-1.0%
1.01x(?)

ErrorHandling
3815
3772
-1.1%
1.01x(?)

ObjectAllocation
557
553
-0.7%
1.01x(?)

AngryPhonebook
2990
2974
-0.5%
1.01x(?)

ProtocolDispatch2
460
454
-1.3%
1.01x(?)

ObjectiveCBridgeStubURLAppendPathRef
235454
233760
-0.7%
1.01x(?)

ObjectiveCBridgeStubToNSDateRef
3331
3313
-0.5%
1.01x(?)

StringEqualPointerComparison
9654
9532
-1.3%
1.01x

CaptureProp
118962
118278
-0.6%
1.01x

PolymorphicCalls
1152
1137
-1.3%
1.01x

DictionaryLiteral
16550
16316
-1.4%
1.01x(?)

Hanoi
19678
19528
-0.8%
1.01x

Phonebook
63677
63009
-1.1%
1.01x(?)

StringHasPrefixUnicode
15529
15319
-1.4%
1.01x(?)

LinkedList
27866
27572
-1.1%
1.01x

NSStringConversion
3033
3006
-0.9%
1.01x(?)

ArraySubscript
5619
5639
+0.4%
1.00x(?)

MonteCarloPi
53595
53579
-0.0%
1.00x(?)

Integrate
368
368
+0.0%
1.00x

ClassArrayGetter
1265
1265
+0.0%
1.00x

Array2D
812819
814193
+0.2%
1.00x(?)

StringWithCString
153371
152635
-0.5%
1.00x

RangeAssignment
13246
13280
+0.3%
1.00x(?)

ByteSwap
9
9
+0.0%
1.00x

SuperChars
263865
262860
-0.4%
1.00x(?)

ArrayAppendLazyMap
244769
244685
-0.0%
1.00x(?)

XorLoop
19999
20010
+0.1%
1.00x(?)

ObserverClosure
6945
6946
+0.0%
1.00x(?)

ObjectiveCBridgeStubToNSString
1334
1334
+0.0%
1.00x

ArrayAppendStrings
11849
11834
-0.1%
1.00x(?)

HashTest
5244
5263
+0.4%
1.00x(?)

StrComplexWalk
8064
8075
+0.1%
1.00x(?)

Join
1460
1457
-0.2%
1.00x(?)

ArrayOfRef
9133
9148
+0.2%
1.00x(?)

ObserverUnappliedMethod
8693
8690
-0.0%
1.00x(?)

ObjectiveCBridgeStubDateMutation
517
517
+0.0%
1.00x

PopFrontArrayGeneric
9705
9714
+0.1%
1.00x(?)

PopFrontUnsafePointer
242508
242703
+0.1%
1.00x(?)

ObjectiveCBridgeStubToNSStringRef
155
155
+0.0%
1.00x

ArrayAppendOptionals
1297
1291
-0.5%
1.00x(?)

UTF8Decode
43540
43638
+0.2%
1.00x

ObjectiveCBridgeStubURLAppendPath
238749
238139
-0.3%
1.00x(?)

SortStringsUnicode
9224
9229
+0.1%
1.00x(?)

ObjectiveCBridgeStubDataAppend
3318
3326
+0.2%
1.00x(?)

ObjectiveCBridgeStubNSDateRefAccess
1232
1228
-0.3%
1.00x(?)

ArrayInClass
3958
3957
-0.0%
1.00x(?)

ArrayOfGenericRef
10058
10035
-0.2%
1.00x(?)

ObjectiveCBridgeFromNSString
5104
5095
-0.2%
1.00x(?)

Sim2DArray
14780
14783
+0.0%
1.00x(?)

SetExclusiveOr_OfObjects
46941
46776
-0.3%
1.00x

ArrayAppendRepeatCol
212900
212224
-0.3%
1.00x(?)

MonteCarloE
108890
108623
-0.2%
1.00x(?)

RC4
9402
9395
-0.1%
1.00x(?)

Walsh
13318
13322
+0.0%
1.00x(?)

ArrayAppend
3552
3554
+0.1%
1.00x(?)

MapReduce
45039
45019
-0.0%
1.00x(?)

ArrayAppendArrayOfInt
641
641
+0.0%
1.00x

ArrayOfPOD
2515
2513
-0.1%
1.00x(?)

Chars
5023
5042
+0.4%
1.00x

ObserverForwarderStruct
5207
5213
+0.1%
1.00x(?)

ArrayLiteral
1252
1248
-0.3%
1.00x(?)

ArrayValueProp3
3072
3070
-0.1%
1.00x(?)

ArrayValueProp4
3020
3023
+0.1%
1.00x(?)

ArrayValueProp
2635
2636
+0.0%
1.00x(?)

GlobalClass
0
0
+0.0%
1.00x

Memset
20953
20959
+0.0%
1.00x(?)

Dictionary2OfObjects
6325
6306
-0.3%
1.00x(?)

ArrayAppendReserved
3298
3303
+0.1%
1.00x(?)

ArrayValueProp2
3146
3152
+0.2%
1.00x(?)

SevenBoom
1513
1513
+0.0%
1.00x

ObserverPartiallyAppliedMethod
8336
8316
-0.2%
1.00x(?)

ObjectiveCBridgeToNSString
1100
1110
+0.9%
0.99x

StackPromo
128293
129589
+1.0%
0.99x(?)

RecursiveOwnedParameter
10884
10960
+0.7%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToString
121020
122658
+1.4%
0.99x(?)

SortStrings
2740
2767
+1.0%
0.99x(?)

ObjectiveCBridgeStubFromNSDateRef
4019
4076
+1.4%
0.99x

ObjectiveCBridgeStubFromNSString
798
803
+0.6%
0.99x(?)

StringHasSuffixUnicode
64506
65023
+0.8%
0.99x

NSError
674
683
+1.3%
0.99x(?)

IterateData
10572
10629
+0.5%
0.99x

ObjectiveCBridgeStubDateAccess
1090
1097
+0.6%
0.99x(?)

SetUnion_OfObjects
34390
34806
+1.2%
0.99x

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
220662
225355
+2.1%
0.98x(?)

ObjectiveCBridgeStubToNSDate
13992
14242
+1.8%
0.98x(?)

StaticArray
34887
35425
+1.5%
0.98x(?)

StringBuilder
2700
2748
+1.8%
0.98x(?)

ArrayAppendSequence
105810
108085
+2.1%
0.98x

146
5998987
6135620
+2.3%
0.98x

DeadArray
119178
121204
+1.7%
0.98x(?)

ObjectiveCBridgeFromNSArrayAnyObject
79157
81404
+2.8%
0.97x(?)

StringWalk
22082
22820
+3.3%
0.97x

ObjectiveCBridgeStubNSDateMutationRef
13827
14247
+3.0%
0.97x(?)

ObjectiveCBridgeFromNSDictionaryAnyObject
200337
208785
+4.2%
0.96x

DictionaryBridge
3908
4065
+4.0%
0.96x

ObjectiveCBridgeFromNSSetAnyObject
94545
98619
+4.3%
0.96x(?)

ObjectiveCBridgeStubFromArrayOfNSString
59303
61857
+4.3%
0.96x(?)

ObjectiveCBridgeStubFromNSStringRef
164
173
+5.5%
0.95x

ArrayOfGenericPOD
3520
3702
+5.2%
0.95x

NopDeinit
58098
61126
+5.2%
0.95x

**Hardware Overview**
      Model Name: Mac mini
      Model Identifier: Macmini7,1
      Processor Name: Intel Core i5
      Processor Speed: 2.8 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 3 MB
      Memory: 16 GB

Build comment file:
Optimized (O)

Regression (5)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeToNSDictionary
15307
59296
+287.4%
0.26x

ObjectiveCBridgeToNSSet
14918
37842
+153.7%
0.39x

ObjectiveCBridgeFromNSSetAnyObjectForced
4300
5379
+25.1%
0.80x

ObjectiveCBridgeFromNSDictionaryAnyObjectForced
4969
6121
+23.2%
0.81x

ObserverForwarderStruct
843
928
+10.1%
0.91x(?)

Improvement (24)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

AnyHashableWithAClass
62814
59352
-5.5%
1.06x

OpenClose
56
53
-5.4%
1.06x(?)

StrToInt
5175
4898
-5.3%
1.06x

SetUnion_OfObjects
6270
5932
-5.4%
1.06x

SetExclusiveOr_OfObjects
7507
7029
-6.4%
1.07x(?)

DictionarySwapOfObjects
6368
5918
-7.1%
1.08x

ObjectiveCBridgeFromNSDictionaryAnyObject
183663
169182
-7.9%
1.09x(?)

MapReduce
352
323
-8.2%
1.09x

StringHasPrefix
690
603
-12.6%
1.14x

PopFrontArray
1186
1029
-13.2%
1.15x(?)

ProtocolDispatch2
176
149
-15.3%
1.18x

TwoSum
1494
1261
-15.6%
1.18x

CaptureProp
4602
3855
-16.2%
1.19x

RGBHistogram
2670
2151
-19.4%
1.24x

NSDictionaryCastToSwift
6552
4687
-28.5%
1.40x

SetUnion
2822
1999
-29.2%
1.41x

DictionarySwap
596
401
-32.7%
1.49x

SetIntersect_OfObjects
2141
1370
-36.0%
1.56x

SetIsSubsetOf_OfObjects
494
286
-42.1%
1.73x

DictionaryRemove
4345
2170
-50.1%
2.00x

SetIsSubsetOf
480
229
-52.3%
2.10x

DictionaryLiteral
2597
1197
-53.9%
2.17x

Histogram
619
269
-56.5%
2.30x

SetIntersect
1023
334
-67.3%
3.06x

No Changes (118)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeFromNSString
1741
1665
-4.4%
1.05x(?)

ObjectiveCBridgeFromNSSetAnyObjectToStringForced
99724
94931
-4.8%
1.05x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
199283
191065
-4.1%
1.04x(?)

ObjectiveCBridgeFromNSSetAnyObject
84906
81680
-3.8%
1.04x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
127986
122578
-4.2%
1.04x(?)

NopDeinit
35859
34553
-3.6%
1.04x

SortStrings
1733
1687
-2.6%
1.03x

ObjectiveCBridgeStubURLAppendPathRef
222758
215698
-3.2%
1.03x(?)

Calculator
34
33
-2.9%
1.03x

ObjectiveCBridgeStubURLAppendPath
223235
216213
-3.1%
1.03x(?)

SortStringsUnicode
7864
7631
-3.0%
1.03x

ObjectiveCBridgeStubFromNSDate
3435
3335
-2.9%
1.03x

DictionaryBridge
3612
3534
-2.2%
1.02x(?)

ObjectiveCBridgeStubToNSDate
12901
12594
-2.4%
1.02x(?)

Dictionary2
1944
1906
-1.9%
1.02x

Dictionary
699
684
-2.1%
1.02x

ArrayInClass
60
59
-1.7%
1.02x(?)

RGBHistogramOfObjects
20756
20390
-1.8%
1.02x(?)

DeadArray
175
172
-1.7%
1.02x

StackPromo
20408
20274
-0.7%
1.01x(?)

Prims
695
687
-1.1%
1.01x(?)

SuperChars
200267
199136
-0.6%
1.01x(?)

Walsh
294
292
-0.7%
1.01x

ObserverUnappliedMethod
2230
2217
-0.6%
1.01x(?)

ObjectiveCBridgeStubToNSDateRef
3108
3063
-1.4%
1.01x(?)

PopFrontUnsafePointer
8659
8612
-0.5%
1.01x(?)

StringEqualPointerComparison
6943
6889
-0.8%
1.01x

DictionaryRemoveOfObjects
18620
18483
-0.7%
1.01x(?)

ObjectiveCBridgeStubToArrayOfNSString
28186
27853
-1.2%
1.01x(?)

ObjectiveCBridgeFromNSArrayAnyObject
71493
71007
-0.7%
1.01x(?)

MonteCarloE
9902
9835
-0.7%
1.01x(?)

HashTest
1652
1639
-0.8%
1.01x(?)

Chars
594
589
-0.8%
1.01x

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
85967
85202
-0.9%
1.01x(?)

ObjectiveCBridgeStubFromArrayOfNSString
55579
54943
-1.1%
1.01x(?)

ObjectiveCBridgeStubNSDateMutationRef
11367
11218
-1.3%
1.01x(?)

ObjectiveCBridgeToNSString
1011
1011
+0.0%
1.00x

MonteCarloPi
42469
42465
-0.0%
1.00x(?)

RecursiveOwnedParameter
1824
1828
+0.2%
1.00x

ObjectiveCBridgeStubToNSString
1209
1210
+0.1%
1.00x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToString
110654
110976
+0.3%
1.00x(?)

ClassArrayGetter
12
12
+0.0%
1.00x

Array2D
1941
1938
-0.1%
1.00x(?)

ObjectiveCBridgeStubFromNSDateRef
3500
3494
-0.2%
1.00x(?)

ObjectiveCBridgeFromNSStringForced
2520
2527
+0.3%
1.00x(?)

SortLettersInPlace
919
918
-0.1%
1.00x(?)

ByteSwap
0
0
+0.0%
1.00x

ArrayAppendGenericStructs
1142
1142
+0.0%
1.00x

ArrayAppendLazyMap
799
799
+0.0%
1.00x

XorLoop
358
359
+0.3%
1.00x(?)

ArrayAppendReserved
506
506
+0.0%
1.00x

ObserverClosure
1838
1843
+0.3%
1.00x(?)

ArrayAppendStrings
11372
11367
-0.0%
1.00x(?)

Join
436
438
+0.5%
1.00x(?)

ProtocolDispatch
2868
2868
+0.0%
1.00x

TypeFlood
0
0
+0.0%
1.00x

AngryPhonebook
2653
2663
+0.4%
1.00x(?)

ErrorHandling
2758
2756
-0.1%
1.00x(?)

ObjectiveCBridgeStubDateMutation
258
258
+0.0%
1.00x

ObjectiveCBridgeToNSArray
28870
28921
+0.2%
1.00x(?)

NSError
306
307
+0.3%
1.00x(?)

DictionaryOfObjects
2155
2152
-0.1%
1.00x(?)

PolymorphicCalls
20
20
+0.0%
1.00x

RC4
156
156
+0.0%
1.00x

ObjectiveCBridgeStubToNSStringRef
109
109
+0.0%
1.00x

ArrayAppendOptionals
1141
1143
+0.2%
1.00x(?)

IterateData
2402
2396
-0.2%
1.00x

ArrayOfGenericPOD
207
207
+0.0%
1.00x

UTF8Decode
272
272
+0.0%
1.00x

ObjectiveCBridgeStubNSDateRefAccess
291
291
+0.0%
1.00x

StringBuilder
1238
1241
+0.2%
1.00x(?)

StringHasSuffix
755
757
+0.3%
1.00x

ObjectiveCBridgeStubDateAccess
172
172
+0.0%
1.00x

Sim2DArray
261
261
+0.0%
1.00x

ArrayAppendRepeatCol
607
607
+0.0%
1.00x

StringHasSuffixUnicode
59550
59584
+0.1%
1.00x(?)

ArrayAppend
732
730
-0.3%
1.00x(?)

LinkedList
6862
6867
+0.1%
1.00x(?)

ArrayAppendSequence
1002
1001
-0.1%
1.00x(?)

ArrayAppendArrayOfInt
565
565
+0.0%
1.00x

ArrayOfPOD
171
171
+0.0%
1.00x

BitCount
1
1
+0.0%
1.00x

ArrayLiteral
1105
1108
+0.3%
1.00x(?)

ArrayValueProp3
5
5
+0.0%
1.00x

StringWalk
5566
5564
-0.0%
1.00x(?)

ArrayValueProp
5
5
+0.0%
1.00x

GlobalClass
0
0
+0.0%
1.00x

Memset
222
222
+0.0%
1.00x

ArrayValueProp4
5
5
+0.0%
1.00x

ArrayValueProp2
5
5
+0.0%
1.00x

SevenBoom
1276
1278
+0.2%
1.00x(?)

ObserverPartiallyAppliedMethod
3181
3175
-0.2%
1.00x(?)

StringWithCString
146218
146965
+0.5%
0.99x(?)

ObjectiveCBridgeFromNSArrayAnyObjectForced
5875
5908
+0.6%
0.99x(?)

Dictionary3OfObjects
809
821
+1.5%
0.99x(?)

StringInterpolation
10069
10209
+1.4%
0.99x(?)

Integrate
225
227
+0.9%
0.99x(?)

ObjectAllocation
144
145
+0.7%
0.99x(?)

Dictionary3
482
487
+1.0%
0.99x

StrComplexWalk
2727
2745
+0.7%
0.99x(?)

ArrayOfRef
3320
3356
+1.1%
0.99x(?)

ObjectiveCBridgeFromNSSetAnyObjectToString
133513
134579
+0.8%
0.99x(?)

ArrayOfGenericRef
3388
3418
+0.9%
0.99x(?)

Phonebook
7083
7125
+0.6%
0.99x

StringHasPrefixUnicode
12932
13119
+1.4%
0.99x(?)

ObjectiveCBridgeStubNSDataAppend
2262
2290
+1.2%
0.99x(?)

RangeAssignment
266
272
+2.3%
0.98x(?)

PopFrontArrayGeneric
1028
1051
+2.2%
0.98x(?)

ObjectiveCBridgeStubDataAppend
2774
2825
+1.8%
0.98x(?)

SetExclusiveOr
2475
2519
+1.8%
0.98x(?)

NSStringConversion
754
770
+2.1%
0.98x

146
2835701
2885663
+1.8%
0.98x

Dictionary2OfObjects
3198
3248
+1.6%
0.98x(?)

ObjectiveCBridgeStubFromNSString
720
742
+3.1%
0.97x

StaticArray
2494
2580
+3.5%
0.97x(?)

Hanoi
3154
3246
+2.9%
0.97x(?)

ObjectiveCBridgeStubFromNSStringRef
123
128
+4.1%
0.96x

ArraySubscript
1359
1438
+5.8%
0.95x

**Unoptimized (Onone)**

Regression (5)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

ObjectiveCBridgeToNSDictionary
15532
59882
+285.5%
0.26x

ObjectiveCBridgeToNSSet
15132
38277
+152.9%
0.40x

ObjectiveCBridgeFromNSDictionaryAnyObjectForced
7261
8506
+17.1%
0.85x

ObjectiveCBridgeFromNSSetAnyObjectForced
7027
8171
+16.3%
0.86x

StringWalk
21010
22534
+7.2%
0.93x

Improvement (26)

TEST
OLD_MIN
NEW_MIN
DELTA (%)
SPEEDUP

StrComplexWalk
7623
7201
-5.5%
1.06x

BitCount
101
95
-5.9%
1.06x

Dictionary2OfObjects
5949
5602
-5.8%
1.06x

ObjectiveCBridgeFromNSDictionaryAnyObject
188296
175510
-6.8%
1.07x

DictionaryOfObjects
4628
4302
-7.0%
1.08x

ArrayOfPOD
2370
2195
-7.4%
1.08x

DictionarySwapOfObjects
19816
18127
-8.5%
1.09x

Dictionary2
4202
3824
-9.0%
1.10x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToString
208764
201588
-3.4%
1.04x(?)

ObjectiveCBridgeFromNSSetAnyObject
90201
86943
-3.6%
1.04x(?)

ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced
133694
128262
-4.1%
1.04x(?)

StackPromo
122844
119601
-2.6%
1.03x(?)

ArrayOfGenericPOD
3320
3237
-2.5%
1.03x

Prims
12839
12525
-2.5%
1.03x

ProtocolDispatch
5303
5163
-2.6%
1.03x

ObjectiveCBridgeFromNSSetAnyObjectToString
151224
146593
-3.1%
1.03x(?)

DictionaryRemove
16380
15944
-2.7%
1.03x

AnyHashableWithAClass
76448
74647
-2.4%
1.02x

PolymorphicCalls
1085
1065
-1.8%
1.02x(?)

ArrayAppendSequence
99720
97475
-2.2%
1.02x

ObjectiveCBridgeStubFromNSDate
3759
3671
-2.3%
1.02x

ObjectiveCBridgeFromNSArrayAnyObjectForced
9740
9686
-0.6%
1.01x(?)

ObjectiveCBridgeStubToNSDate
13345
13212
-1.0%
1.01x(?)

StringInterpolation
14896
14707
-1.3%
1.01x(?)

Join
1391
1379
-0.9%
1.01x(?)

ObjectiveCBridgeStubFromNSStringRef
155
153
-1.3%
1.01x(?)

ObjectAllocation
530
527
-0.6%
1.01x(?)

AngryPhonebook
2818
2802
-0.6%
1.01x(?)

ProtocolDispatch2
434
430
-0.9%
1.01x

CaptureProp
112002
111092
-0.8%
1.01x

DictionaryRemoveOfObjects
44195
43904
-0.7%
1.01x

ArrayAppendRepeatCol
200889
198826
-1.0%
1.01x

LinkedList
26276
25990
-1.1%
1.01x(?)

NSStringConversion
2861
2841
-0.7%
1.01x(?)

146
5677511
5612658
-1.1%
1.01x

DeadArray
113857
113164
-0.6%
1.01x(?)

ObjectiveCBridgeStubNSDataAppend
2676
2639
-1.4%
1.01x(?)

ObjectiveCBridgeStubFromArrayOfNSString
55808
55525
-0.5%
1.01x(?)

ArraySubscript
5289
5310
+0.4%
1.00x(?)

ObjectiveCBridgeToNSString
1041
1041
+0.0%
1.00x

MonteCarloPi
50597
50680
+0.2%
1.00x

PopFrontArray
23125
23075
-0.2%
1.00x(?)

RecursiveOwnedParameter
10282
10268
-0.1%
1.00x(?)

ObjectiveCBridgeStubToNSString
1259
1261
+0.2%
1.00x(?)

ClassArrayGetter
1194
1194
+0.0%
1.00x

Array2D
766665
767220
+0.1%
1.00x(?)

StringWithCString
144769
144278
-0.3%
1.00x

ObjectiveCBridgeFromNSStringForced
2893
2901
+0.3%
1.00x

SortLettersInPlace
2415
2410
-0.2%
1.00x(?)

ObjectiveCBridgeFromNSString
4821
4818
-0.1%
1.00x(?)

RangeAssignment
12484
12512
+0.2%
1.00x(?)

ByteSwap
9
9
+0.0%
1.00x

ArrayAppendGenericStructs
1185
1186
+0.1%
1.00x(?)

SuperChars
221688
220613
-0.5%
1.00x(?)

ArrayAppendLazyMap
230694
231390
+0.3%
1.00x

XorLoop
18865
18866
+0.0%
1.00x(?)

ObserverClosure
6565
6569
+0.1%
1.00x(?)

Integrate
347
347
+0.0%
1.00x

ArrayAppendStrings
11101
11106
+0.1%
1.00x(?)

StaticArray
33358
33380
+0.1%
1.00x(?)

HashTest
4942
4966
+0.5%
1.00x(?)

StringHasPrefix
1472
1465
-0.5%
1.00x

ArrayOfRef
8633
8613
-0.2%
1.00x(?)

ObserverUnappliedMethod
8207
8219
+0.1%
1.00x(?)

ObjectiveCBridgeStubURLAppendPathRef
225323
224787
-0.2%
1.00x(?)

ArrayAppendOptionals
1186
1184
-0.2%
1.00x(?)

ObjectiveCBridgeToNSArray
28856
28956
+0.3%
1.00x(?)

PopFrontUnsafePointer
228946
228837
-0.1%
1.00x(?)

StringEqualPointerComparison
9105
9087
-0.2%
1.00x

ObjectiveCBridgeStubToNSStringRef
147
147
+0.0%
1.00x

MapReduce
42502
42568
+0.2%
1.00x

Hanoi
18514
18600
+0.5%
1.00x(?)

ObjectiveCBridgeStubURLAppendPath
223920
223314
-0.3%
1.00x(?)

NopDeinit
54801
54824
+0.0%
1.00x(?)

ObjectiveCBridgeStubToArrayOfNSString
28261
28159
-0.4%
1.00x(?)

ObjectiveCBridgeFromNSArrayAnyObject
74787
74587
-0.3%
1.00x(?)

GlobalClass
0
0
+0.0%
1.00x

ObjectiveCBridgeStubNSDateRefAccess
1163
1159
-0.3%
1.00x

StrToInt
5573
5596
+0.4%
1.00x(?)

ArrayInClass
3736
3734
-0.1%
1.00x(?)

ArrayOfGenericRef
9476
9488
+0.1%
1.00x(?)

Phonebook
59737
60001
+0.4%
1.00x(?)

Sim2DArray
13937
13955
+0.1%
1.00x(?)

MonteCarloE
102661
102505
-0.1%
1.00x

StringHasSuffixUnicode
61016
61315
+0.5%
1.00x

Walsh
12572
12597
+0.2%
1.00x(?)

ArrayAppend
3351
3351
+0.0%
1.00x

ArrayAppendArrayOfInt
603
604
+0.2%
1.00x(?)

Chars
4730
4716
-0.3%
1.00x

ObserverForwarderStruct
4907
4908
+0.0%
1.00x(?)

ArrayLiteral
1179
1180
+0.1%
1.00x(?)

SevenBoom
1424
1429
+0.3%
1.00x(?)

ArrayValueProp4
2835
2838
+0.1%
1.00x(?)

ArrayValueProp
2487
2486
-0.0%
1.00x(?)

ObjectiveCBridgeStubNSDateMutationRef
13290
13354
+0.5%
1.00x(?)

RC4
8873
8856
-0.2%
1.00x

Memset
19778
19780
+0.0%
1.00x(?)

ArrayAppendReserved
3114
3116
+0.1%
1.00x

ArrayValueProp2
2967
2971
+0.1%
1.00x

ArrayValueProp3
2898
2897
-0.0%
1.00x(?)

ObserverPartiallyAppliedMethod
7867
7868
+0.0%
1.00x(?)

SortStrings
2584
2599
+0.6%
0.99x(?)

ErrorHandling
3562
3616
+1.5%
0.99x(?)

PopFrontArrayGeneric
9090
9184
+1.0%
0.99x

IterateData
9964
10031
+0.7%
0.99x

SortStringsUnicode
8694
8750
+0.6%
0.99x(?)

ObjectiveCBridgeStubDataAppend
3130
3177
+1.5%
0.99x(?)

StringHasSuffix
1486
1499
+0.9%
0.99x

StringBuilder
2555
2583
+1.1%
0.99x(?)

DictionaryBridge
3658
3745
+2.4%
0.98x(?)

ObjectiveCBridgeStubFromNSString
754
773
+2.5%
0.98x

NSError
639
650
+1.7%
0.98x(?)

ObjectiveCBridgeStubToNSDateRef
3130
3199
+2.2%
0.98x(?)

Calculator
928
948
+2.2%
0.98x

UTF8Decode
41060
41688
+1.5%
0.98x(?)

StringHasPrefixUnicode
14649
14940
+2.0%
0.98x

ObjectiveCBridgeStubDateAccess
1029
1062
+3.2%
0.97x

ObjectiveCBridgeStubFromNSDateRef
3795
3937
+3.7%
0.96x

OpenClose
397
415
+4.5%
0.96x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToString
112189
117499
+4.7%
0.95x(?)

TypeFlood
187
197
+5.3%
0.95x(?)

ObjectiveCBridgeFromNSArrayAnyObjectToStringForced
88507
92934
+5.0%
0.95x(?)

**Hardware Overview**
      Model Name: Mac mini
      Model Identifier: Macmini7,1
      Processor Name: Intel Core i7
      Processor Speed: 3 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache (per Core): 256 KB
      L3 Cache: 4 MB
      Memory: 16 GB

@swift-ci Please smoke test

Heck yeah, those are some perf numbers I can get behind! 😎

Oh god all tests passed I'm scared what do I do can I just push that big green button is this real oh god oh god oh god 😱

@bob-wilson here's my perf analysis:
The two biggest regressions are the result of removing the bridging cache that Dictionaries implicitly had. This means that:
for _ in 0..<100 {
  myDict as NSDictionary
}

creates 100 independent _SwiftDeferredNSDictionary with independent "bridged buffer" caches, where previously it would just return the same one over and over. If this is considered problematic, we can potentially add a weak pointer caching a _SwiftDeferredNSDictionary to _RawNativeDictionaryStorage (or maybe only  _HashableTypedNativeDictionaryStorage).
I haven't dug into the other regressions, but it's worth noting that this PR changed the representation of a lazy bridged dictionary (_VariantDictionaryStorage.cocoa) to be a class, where previously it was a struct to allow lazy var to be used. Reverting this might be the right solution; I didn't obsess over this since eager bridging may just delete all that code.

Congratulations @gankro and @austinzheng !

@Gankro Since you and Dave already discussed the performance tradeoff and concluded that this is the right thing to do, I'm not going to second guess that. If you don't end up deleting the code with eager bridging, can you come back and take another look at the performance later?

@Gankro @bob-wilson Actually I am unclear on why this should cause any regressions at all, so maybe we should discuss that.

This should cause a regression (at least in synthetic benchmarks) because:

It eliminates the repeated-bridging cache (possibly only a problem for micro benchmarks that bridge in a loop?). We can in principle add this back, at the cost of storing a weak or strong pointer (depending on how eagerly you want to free that cached allocation) in every _RawNative${Self}Storage.

It requires a _SwiftDeferredNSDictionary to be eagerly allocated to wrap the the two _Native${Self}Buffers. We can in principle eliminate this by making that hypothetical pointer into a strong pointer, and having the NSDictionary implementation branch on whether K/V is verbatim bridgeable for every operation.

The former is potentially desirable, the latter is probably a huge waste.
This is an unavoidable consequence of making Dictionary into a single-allocation data structure. A lot of optimizations were built around there being two allocations. In effect, we've taken the cost of allocating an extra class from every dictionary, and pushed it into every bridge. I consider that an acceptable trade-off.

Mental reworking: we can move the verbatim bridgeable check to Storage construction time, and just fork _HashableTypedNative${Self}Storage into two types. The one that exists now, and one that has the slot for a strong pointer to the bridged buffer. This means Dictionary<Int, Int> would store a potentially unused pointer, while Dictionary<MyClass, MyClass> wouldn't. Much better.

Followup from private conversation:
@dabrahams we definitely need/want to add a new Storage class so that every method doesn't have to be guarded by "am I verbatim bridgeable", unless I'm missing something.
Also I'm remembering now that we dicussed this design like a month ago; I believe we concluded that storing a strong pointer in the storage is unacceptable, because that is an easy source of memory leaks. However whatever we return to ObjC must store a strong pointer. Note that the solution implemented by this PR is the solution used by Array; see _SwiftDeferredNSArray (which I modelled this solution after).

on Thu Nov 10 2016, Alexis Beingessner <notifications-AT-github.com> wrote:

Followup from private conversation:
@dabrahams we definitely need/want to add a new Storage class so that
every method doesn't have to be guarded by "am I verbatim bridgeable",
unless I'm missing something.

That check gets compiled down to nothing any place where the static type
of the element is visible, so that cost is dramatically less than you
might assume.

Also I'm remembering now that we dicussed this design like a month
ago; I believe we concluded that storing a strong pointer in the
storage is unacceptable, because that is an easy source of memory
leaks. However whatever we return to ObjC must store a strong
pointer. Note that the solution implemented by this PR is the solution
used by Array; see _SwiftDeferredNSArray (which I modelled this
solution after).

Eh, I think I'll need an interactive refresher on that discussion.
--
-Dave