Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eager string bridging #5489

Closed
wants to merge 4 commits into from
Closed

Eager string bridging #5489

wants to merge 4 commits into from

Conversation

Gankra
Copy link
Contributor

@Gankra Gankra commented Oct 26, 2016

This is my work on eager string bridging rebased and split out of the eager bridging PR so that other teams can analyze the perf impact of it in isolation (and without being blocked on Dictionary/Set work).

Someone for the compiler team should figure out what should happen to the xfail'd tests.

CC @bob-wilson for perf team stuff

let nulTerminatedASCII = _swift_stdlib_CFStringGetCStringPtr(
cfImmutableValue, kCFStringEncodingASCII)
_cocoaString, kCFStringEncodingASCII)
Copy link
Member

Choose a reason for hiding this comment

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

This should really be using the SPIs from Foundation instead of doing the CF call (which is slower).

@interface NSString (SPI)
- (nullable const char *)_fastCStringContents:(BOOL)nullTerminationRequired;
@end

That will return the underlying C string pointer if it can be pulled out of the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, I recall hearing about this difference but had to work on other stuff and forgot. Thanks for the precise tip!

// If we aren't ascii, ask the NSString to copy itself into our buffer
// FIXME(eager-bridging): is the range variant or the non-range variant
// more effecient, assuming we've already computed the length?
_swift_stdlib_CFStringGetCharacters(
Copy link
Member

Choose a reason for hiding this comment

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

Ideally this should be the NSString API (the CF version is slower)
But you could call the fast version before jumping to that:

@interface NSString (SPI)
- (nullable const unichar *)_fastCharacterContents;
@end

Then after calling that use -[NSString getCharacters:range:] since that is faster than the CF call

@Gankra
Copy link
Contributor Author

Gankra commented Oct 27, 2016

Whoops, forgot to run validation tests. Fixed.

@Gankra
Copy link
Contributor Author

Gankra commented Oct 27, 2016

@swift-ci Please smoke test

@Gankra
Copy link
Contributor Author

Gankra commented Oct 27, 2016

@swift-ci Please benchmark

@Gankra
Copy link
Contributor Author

Gankra commented Oct 27, 2016

(I found nothing interesting from enabling resilience via utils/build-script -R -T -- --swift-stdlib-enable-resilience=1)

@swift-ci
Copy link
Collaborator

Build comment file:

Build failed before running benchmark.


Copy link
Member

@phausler phausler left a comment

Choose a reason for hiding this comment

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

An interesting question: with this change what is the effect upon constants emitted as strongly typed string enumerations like NSNotificationName? by those being forced to a full copy they loose identity and that is a non zero performance hit in some cases (e.g. NSRunLoop or NSNotificationCenter)

_swift_stdlib_CFStringGetLength(ns) == _core.count {
return ns
}
_sanityCheck(_core.hasContiguousStorage)
return _NSContiguousString(_core)
Copy link
Member

Choose a reason for hiding this comment

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

it would be nice if we didn't have such a performance hit here; this will destroy all tagged pointer strings which is a decent memory savings to objc, and it destroys the fast-path accessors we have in Foundation as well.

it really needs to implement the _fastCStringContents: as well as fastestEncoding and smallestEncoding. Please reference rdar://problem/18525604

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the fact that we need to create an NsContiguousString is an old bug that needs to be fixed for sure, but if we fix that then Swift->Objc is free. The only impact is at the Objc -> Swift part.

It's an often stated claim that we want String to become a single pointer, with tagged pointer optimizations. It's possible we can pick up objc's tagged pointer opts if we go that way? But we need someone to take point on the design here. I know @dabrahams is working on a lot of string stuff, but idk if he's been looking at this aspect of it yet.

I'll look into filling in the fastpaths, thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I am looking into that aspect and intend to handle it.

@@ -12,7 +12,7 @@

/// The core implementation of a highly-optimizable String that
/// can store both ASCII and UTF-16, and can wrap native Swift
/// _StringBuffer or NSString instances.
/// _StringBuffer or immutable literals.
Copy link
Member

Choose a reason for hiding this comment

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

does that account for NSConstantString or NSTaggedPointerString as "immutable literals"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not at the moment; it refers to Swift string literals stored in rodata, but the only assumption here is that the pointer lives "forever" and its contents are immutable. So if we can get such a pointer from objc, native Swift strings can wrap them.

Copy link
Member

Choose a reason for hiding this comment

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

NSConstantString can be done as such since it is emitted by clang as static as well (however it is stored in a different section)

@Gankra
Copy link
Contributor Author

Gankra commented Oct 27, 2016

@phausler we've been looking for interesting workloads that tax the kind of things you're concerned about. Are you aware of any good ones?

@phausler
Copy link
Member

NSNotificationCenter would be a good one to test since it definitely has a pretty hefty cost when the non constant strings are used. I will bake one up and email you a sample project

@jrose-apple
Copy link
Contributor

IIRC the NS_STRING_ENUM types still store the underlying type as NSString. There's only a full copy if you actually ask for the raw value. @milseman, confirm/deny?

@milseman
Copy link
Contributor

That's correct, @jrose-apple. The intent is for these to be brought into Swift as layout-compatible with the C/ObjC declarations, so we do not pay any bridging either way. We do, however, provide a computed property to provide the rawValue in the Swift type, and if the user wants to construct their own in Swift, they will do so using Swift Strings. E.g.:

typedef NSString * IUONewtype __attribute((swift_newtype(struct)));

gets imported as

struct IUONewtype : RawRepresentable, _SwiftNewtypeWrapper, Equatable, Hashable, Comparable, _ObjectiveCBridgeable {
    init(_ rawValue: String)
    init(rawValue: String)
    var _rawValue: NSString
    var rawValue: String { get }
 }

@Gankra Gankra force-pushed the eager-string branch 2 times, most recently from d2a89f6 to cecdc88 Compare November 8, 2016 04:46
@Gankra
Copy link
Contributor Author

Gankra commented Nov 8, 2016

@swift-ci Please smoke test

@Gankra
Copy link
Contributor Author

Gankra commented Nov 8, 2016

@swift-ci Please benchmark

@Gankra
Copy link
Contributor Author

Gankra commented Nov 8, 2016

I've updated the bridging code to use the objc apis that were recommended, adding in relevant shadow protocols. There's one gross hack I added where I made a bool into a Uint8 because the compiler couldn't figure out how to bridge bool. If anyone knows the right type to use here, that would be greatly appreciated!

@dabrahams
Copy link
Collaborator

@gankro UInt8 is exactly the right thing to do. ObjCBool is only available through the ObjectiveC module, which is in the same category as Foundation; i.e., we can't import it into the stdlib. That's the whole reason for these shadow protocols, 'member? 😉

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 8, 2016

Build comment file:

Optimized (O)

Regression (9)

TEST OLD_MIN NEW_MIN DELTA (%) SPEEDUP
ObjectiveCBridgeStubFromNSString 735 1768 +140.5% 0.42x
NSStringConversion 754 1708 +126.5% 0.44x
ObjectiveCBridgeFromNSString 1722 2620 +52.1% 0.66x
ObjectiveCBridgeStubFromArrayOfNSString 54641 74726 +36.8% 0.73x
ObjectiveCBridgeFromNSStringForced 2516 3332 +32.4% 0.76x
ObjectiveCBridgeFromNSArrayAnyObjectForced 5922 7399 +24.9% 0.80x(?)
StringWalk 5563 6808 +22.4% 0.82x
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 85548 99650 +16.5% 0.86x
Calculator 32 35 +9.4% 0.91x

Improvement (7)

TEST OLD_MIN NEW_MIN DELTA (%) SPEEDUP
ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced 125241 117867 -5.9% 1.06x(?)
ObjectiveCBridgeFromNSSetAnyObjectToStringForced 96622 89172 -7.7% 1.08x(?)
CaptureProp 4312 3833 -11.1% 1.12x
ObjectiveCBridgeStubToNSString 1212 1073 -11.5% 1.13x
StringWithCString 145943 123780 -15.2% 1.18x
StrToInt 4786 3130 -34.6% 1.53x
OpenClose 51 2 -96.1% 25.49x

No Changes (131)

TEST OLD_MIN NEW_MIN DELTA (%) SPEEDUP
ObjectiveCBridgeFromNSDictionaryAnyObjectToString 191779 183351 -4.4% 1.05x(?)
DictionaryBridge 3506 3330 -5.0% 1.05x(?)
ObserverUnappliedMethod 2370 2266 -4.4% 1.05x(?)
ObjectiveCBridgeFromNSArrayAnyObjectToString 113414 109154 -3.8% 1.04x(?)
StrComplexWalk 2736 2638 -3.6% 1.04x(?)
AnyHashableWithAClass 59502 57484 -3.4% 1.04x(?)
NopDeinit 35829 34566 -3.5% 1.04x
Dictionary3OfObjects 823 801 -2.7% 1.03x(?)
StringInterpolation 10356 10092 -2.5% 1.03x(?)
Join 448 434 -3.1% 1.03x(?)
HashTest 1629 1585 -2.7% 1.03x
Dictionary3 492 478 -2.9% 1.03x
ObjectiveCBridgeStubURLAppendPath 224676 217374 -3.2% 1.03x(?)
ObjectiveCBridgeFromNSSetAnyObjectToString 130956 127379 -2.7% 1.03x(?)
TwoSum 1249 1213 -2.9% 1.03x(?)
PopFrontArray 1183 1155 -2.4% 1.02x
SuperChars 199525 196111 -1.7% 1.02x(?)
SortStringsUnicode 7839 7648 -2.4% 1.02x
ObjectiveCBridgeToNSDictionary 58667 57617 -1.8% 1.02x(?)
ObjectiveCBridgeStubFromNSDate 3328 3274 -1.6% 1.02x(?)
ObjectiveCBridgeFromNSDictionaryAnyObject 168917 167089 -1.1% 1.01x(?)
SortStrings 1721 1703 -1.1% 1.01x(?)
DictionarySwap 393 389 -1.0% 1.01x
ArrayLiteral 1117 1111 -0.5% 1.01x(?)
StringEqualPointerComparison 6928 6833 -1.4% 1.01x
Dictionary 688 681 -1.0% 1.01x
Phonebook 7082 6996 -1.2% 1.01x
Chars 594 588 -1.0% 1.01x
ObserverForwarderStruct 875 869 -0.7% 1.01x(?)
DeadArray 174 172 -1.1% 1.01x
ArraySubscript 1362 1358 -0.3% 1.00x(?)
DictionarySwapOfObjects 5916 5929 +0.2% 1.00x(?)
StackPromo 20370 20278 -0.5% 1.00x(?)
RecursiveOwnedParameter 1829 1825 -0.2% 1.00x(?)
Integrate 225 225 +0.0% 1.00x
ClassArrayGetter 12 12 +0.0% 1.00x
Array2D 1935 1943 +0.4% 1.00x(?)
ObjectiveCBridgeFromNSDictionaryAnyObjectForced 5152 5145 -0.1% 1.00x(?)
MonteCarloPi 42429 42609 +0.4% 1.00x
Prims 690 688 -0.3% 1.00x(?)
SortLettersInPlace 917 920 +0.3% 1.00x(?)
ByteSwap 0 0 +0.0% 1.00x
ArrayAppendGenericStructs 1141 1141 +0.0% 1.00x
ArrayAppendLazyMap 799 799 +0.0% 1.00x
ObjectiveCBridgeStubToNSDate 12477 12423 -0.4% 1.00x(?)
XorLoop 359 358 -0.3% 1.00x(?)
ArrayAppendReserved 506 506 +0.0% 1.00x
ObserverClosure 1866 1866 +0.0% 1.00x
ArrayAppendStrings 11361 11377 +0.1% 1.00x(?)
ProtocolDispatch 2868 2868 +0.0% 1.00x
TypeFlood 0 0 +0.0% 1.00x
ObjectiveCBridgeFromNSSetAnyObject 80618 80697 +0.1% 1.00x(?)
Dictionary2 1908 1900 -0.4% 1.00x(?)
SetIntersect_OfObjects 1370 1372 +0.1% 1.00x(?)
ArrayOfRef 3340 3342 +0.1% 1.00x(?)
ObjectiveCBridgeStubURLAppendPathRef 223042 222407 -0.3% 1.00x(?)
ArrayAppend 731 732 +0.1% 1.00x(?)
ObjectiveCBridgeStubDateMutation 258 258 +0.0% 1.00x
DictionaryOfObjects 2152 2150 -0.1% 1.00x(?)
PopFrontArrayGeneric 1156 1156 +0.0% 1.00x
PopFrontUnsafePointer 8634 8662 +0.3% 1.00x(?)
PolymorphicCalls 20 20 +0.0% 1.00x
RC4 156 156 +0.0% 1.00x
ObjectiveCBridgeStubToNSStringRef 110 110 +0.0% 1.00x
ArrayAppendOptionals 1141 1142 +0.1% 1.00x(?)
IterateData 2450 2458 +0.3% 1.00x(?)
DictionaryLiteral 1197 1194 -0.2% 1.00x(?)
Hanoi 3257 3268 +0.3% 1.00x(?)
ArrayOfGenericPOD 207 207 +0.0% 1.00x
DictionaryRemoveOfObjects 18265 18309 +0.2% 1.00x(?)
SetIsSubsetOf 236 236 +0.0% 1.00x
ObjectiveCBridgeStubToArrayOfNSString 27532 27594 +0.2% 1.00x(?)
ObjectiveCBridgeStubDataAppend 2779 2780 +0.0% 1.00x(?)
SetExclusiveOr 2728 2729 +0.0% 1.00x(?)
NSDictionaryCastToSwift 4680 4683 +0.1% 1.00x(?)
RGBHistogramOfObjects 20397 20443 +0.2% 1.00x(?)
ObjectiveCBridgeStubNSDateRefAccess 320 320 +0.0% 1.00x
ArrayInClass 59 59 +0.0% 1.00x
ArrayOfGenericRef 3401 3396 -0.1% 1.00x(?)
StringHasSuffix 755 755 +0.0% 1.00x
ObjectiveCBridgeStubDateAccess 172 172 +0.0% 1.00x
Sim2DArray 261 261 +0.0% 1.00x
ArrayAppendRepeatCol 607 607 +0.0% 1.00x
MonteCarloE 9969 10001 +0.3% 1.00x(?)
StringHasSuffixUnicode 59313 59383 +0.1% 1.00x(?)
SetIsSubsetOf_OfObjects 289 289 +0.0% 1.00x
ObjectiveCBridgeToNSSet 37817 37929 +0.3% 1.00x(?)
DictionaryRemove 2181 2187 +0.3% 1.00x(?)
LinkedList 6829 6832 +0.0% 1.00x(?)
MapReduce 322 323 +0.3% 1.00x(?)
ArrayAppendSequence 1003 1002 -0.1% 1.00x(?)
ArrayAppendArrayOfInt 565 565 +0.0% 1.00x
ArrayOfPOD 171 171 +0.0% 1.00x
ArrayValueProp2 5 5 +0.0% 1.00x
BitCount 1 1 +0.0% 1.00x
AngryPhonebook 2682 2688 +0.2% 1.00x(?)
SevenBoom 1287 1286 -0.1% 1.00x(?)
ArrayValueProp 5 5 +0.0% 1.00x
GlobalClass 0 0 +0.0% 1.00x
Memset 222 222 +0.0% 1.00x
Dictionary2OfObjects 3243 3229 -0.4% 1.00x(?)
ArrayValueProp4 5 5 +0.0% 1.00x
ArrayValueProp3 5 5 +0.0% 1.00x
ObserverPartiallyAppliedMethod 3263 3271 +0.2% 1.00x(?)
ObjectiveCBridgeToNSString 1007 1021 +1.4% 0.99x
Histogram 271 274 +1.1% 0.99x(?)
ObjectiveCBridgeStubFromNSStringRef 125 126 +0.8% 0.99x(?)
ProtocolDispatch2 149 150 +0.7% 0.99x(?)
ErrorHandling 2745 2764 +0.7% 0.99x(?)
ObjectiveCBridgeToNSArray 28217 28568 +1.2% 0.99x(?)
NSError 306 309 +1.0% 0.99x(?)
ObjectiveCBridgeStubToNSDateRef 3035 3073 +1.2% 0.99x(?)
UTF8Decode 272 274 +0.7% 0.99x
RGBHistogram 2137 2154 +0.8% 0.99x(?)
ObjectiveCBridgeFromNSSetAnyObjectForced 4479 4503 +0.5% 0.99x(?)
SetUnion 2287 2315 +1.2% 0.99x(?)
ObjectiveCBridgeStubNSDateMutationRef 11352 11501 +1.3% 0.99x(?)
ObjectiveCBridgeStubFromNSDateRef 3448 3521 +2.1% 0.98x(?)
RangeAssignment 272 277 +1.8% 0.98x(?)
StaticArray 2612 2655 +1.6% 0.98x(?)
ObjectiveCBridgeFromNSArrayAnyObject 71603 72938 +1.9% 0.98x(?)
StringBuilder 1253 1281 +2.2% 0.98x(?)
ObjectiveCBridgeStubNSDataAppend 2273 2323 +2.2% 0.98x(?)
ObjectAllocation 144 148 +2.8% 0.97x(?)
SetExclusiveOr_OfObjects 6882 7118 +3.4% 0.97x(?)
SetUnion_OfObjects 5799 5970 +3.0% 0.97x
StringHasPrefixUnicode 12962 13325 +2.8% 0.97x
146 2804147 2876225 +2.6% 0.97x
StringHasPrefix 685 712 +3.9% 0.96x
SetIntersect 334 349 +4.5% 0.96x(?)
Walsh 293 306 +4.4% 0.96x
**Unoptimized (Onone)**

Regression (18)

TEST OLD_MIN NEW_MIN DELTA (%) SPEEDUP
ObjectiveCBridgeStubFromNSString 780 1820 +133.3% 0.43x
Dictionary 1740 2453 +41.0% 0.71x
ObjectiveCBridgeStubFromArrayOfNSString 55754 75565 +35.5% 0.74x
ObjectiveCBridgeFromNSStringForced 2922 3726 +27.5% 0.78x
Dictionary3 1303 1630 +25.1% 0.80x
StringHasPrefix 1468 1832 +24.8% 0.80x
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 86601 108734 +25.6% 0.80x
Dictionary3OfObjects 1885 2313 +22.7% 0.81x
BitCount 91 113 +24.2% 0.81x
DictionaryOfObjects 4285 5252 +22.6% 0.82x
Dictionary2 3816 4561 +19.5% 0.84x
ObjectiveCBridgeFromNSArrayAnyObjectForced 10128 11735 +15.9% 0.86x
StringHasSuffix 1522 1769 +16.2% 0.86x
Calculator 872 1005 +15.2% 0.87x
Dictionary2OfObjects 5586 6424 +15.0% 0.87x
ObjectiveCBridgeFromNSString 4868 5509 +13.2% 0.88x(?)
ProtocolDispatch 5307 5776 +8.8% 0.92x
PopFrontUnsafePointer 228904 244586 +6.8% 0.94x

Improvement (14)

TEST OLD_MIN NEW_MIN DELTA (%) SPEEDUP
DictionaryBridge 3628 3434 -5.3% 1.06x
StrToInt 5464 5166 -5.5% 1.06x
OpenClose 426 398 -6.6% 1.07x
ArrayOfPOD 2371 2196 -7.4% 1.08x
TypeFlood 184 169 -8.2% 1.09x(?)
ObjectiveCBridgeFromNSDictionaryAnyObjectToString 207893 189665 -8.8% 1.10x
ArrayOfGenericPOD 3563 3238 -9.1% 1.10x
StrComplexWalk 7630 6933 -9.1% 1.10x
ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced 134788 122793 -8.9% 1.10x
ObjectiveCBridgeFromNSSetAnyObjectToString 148489 134127 -9.7% 1.11x
ObjectiveCBridgeFromNSSetAnyObjectToStringForced 109426 97638 -10.8% 1.12x
ObjectiveCBridgeStubToNSString 1261 1120 -11.2% 1.13x
StringWithCString 144506 123154 -14.8% 1.17x
NSStringConversion 2801 2348 -16.2% 1.19x

No Changes (115)

TEST OLD_MIN NEW_MIN DELTA (%) SPEEDUP
SortStrings 2550 2423 -5.0% 1.05x
ObjectiveCBridgeToNSDictionary 59522 57118 -4.0% 1.04x
StackPromo 122948 119395 -2.9% 1.03x(?)
SuperChars 220239 214763 -2.5% 1.03x
ObjectiveCBridgeFromNSArrayAnyObjectToString 113819 110773 -2.7% 1.03x(?)
ObjectiveCBridgeStubURLAppendPath 227953 221776 -2.7% 1.03x(?)
DeadArray 114177 110768 -3.0% 1.03x
ObjectiveCBridgeFromNSDictionaryAnyObjectForced 7432 7320 -1.5% 1.02x(?)
ObjectiveCBridgeStubFromNSStringRef 156 153 -1.9% 1.02x
ObjectiveCBridgeToNSSet 38422 37523 -2.3% 1.02x(?)
NSError 654 641 -2.0% 1.02x(?)
CaptureProp 111493 109254 -2.0% 1.02x
NSDictionaryCastToSwift 5940 5841 -1.7% 1.02x(?)
ArrayAppendRepeatCol 203070 198781 -2.1% 1.02x
ObjectiveCBridgeFromNSSetAnyObjectForced 7265 7147 -1.6% 1.02x(?)
Chars 4697 4621 -1.6% 1.02x
146 5708075 5583706 -2.2% 1.02x
AnyHashableWithAClass 73438 72779 -0.9% 1.01x(?)
DictionarySwap 5703 5628 -1.3% 1.01x
StringInterpolation 14827 14706 -0.8% 1.01x(?)
ErrorHandling 3609 3566 -1.2% 1.01x(?)
ProtocolDispatch2 420 417 -0.7% 1.01x
HashTest 4952 4919 -0.7% 1.01x
ObjectiveCBridgeStubURLAppendPathRef 225750 223071 -1.2% 1.01x(?)
PopFrontArrayGeneric 9217 9170 -0.5% 1.01x(?)
SortStringsUnicode 8747 8676 -0.8% 1.01x
ObjectiveCBridgeStubDataAppend 3168 3129 -1.2% 1.01x(?)
StringBuilder 2579 2566 -0.5% 1.01x(?)
StringHasPrefixUnicode 14601 14408 -1.3% 1.01x
MapReduce 43255 43000 -0.6% 1.01x(?)
ArrayValueProp3 2905 2879 -0.9% 1.01x(?)
ObjectiveCBridgeStubFromNSDate 3589 3567 -0.6% 1.01x
ArraySubscript 5324 5337 +0.2% 1.00x(?)
ObjectiveCBridgeToNSString 1047 1049 +0.2% 1.00x(?)
DictionarySwapOfObjects 18033 18116 +0.5% 1.00x(?)
PopFrontArray 23118 23030 -0.4% 1.00x(?)
RecursiveOwnedParameter 10266 10234 -0.3% 1.00x(?)
ClassArrayGetter 1195 1192 -0.2% 1.00x(?)
Array2D 768894 768574 -0.0% 1.00x(?)
Histogram 9506 9517 +0.1% 1.00x(?)
MonteCarloPi 50682 50807 +0.2% 1.00x(?)
Prims 12496 12529 +0.3% 1.00x(?)
SortLettersInPlace 2430 2424 -0.2% 1.00x(?)
RangeAssignment 12558 12557 -0.0% 1.00x(?)
ByteSwap 9 9 +0.0% 1.00x
ArrayAppendGenericStructs 1185 1188 +0.2% 1.00x
ArrayAppendLazyMap 231257 231226 -0.0% 1.00x(?)
XorLoop 18880 18877 -0.0% 1.00x(?)
ObserverClosure 6592 6591 -0.0% 1.00x(?)
ArrayAppendStrings 11114 11104 -0.1% 1.00x(?)
StaticArray 33422 33298 -0.4% 1.00x(?)
ObjectAllocation 522 522 +0.0% 1.00x
ArrayLiteral 1178 1178 +0.0% 1.00x
Join 1377 1383 +0.4% 1.00x(?)
ArrayOfRef 8614 8634 +0.2% 1.00x(?)
ObserverUnappliedMethod 8243 8209 -0.4% 1.00x(?)
ObjectiveCBridgeStubDateMutation 488 488 +0.0% 1.00x
ObjectiveCBridgeToNSArray 29066 29158 +0.3% 1.00x(?)
ArrayAppendReserved 3117 3117 +0.0% 1.00x
ObjectiveCBridgeStubToNSStringRef 147 147 +0.0% 1.00x
ArrayAppendOptionals 1186 1185 -0.1% 1.00x(?)
IterateData 10033 10047 +0.1% 1.00x(?)
DictionaryLiteral 14825 14790 -0.2% 1.00x(?)
UTF8Decode 41073 41123 +0.1% 1.00x(?)
NopDeinit 54870 54830 -0.1% 1.00x(?)
ObjectiveCBridgeStubToArrayOfNSString 28058 28098 +0.1% 1.00x(?)
SetIntersect 12389 12410 +0.2% 1.00x(?)
RGBHistogramOfObjects 84499 84407 -0.1% 1.00x(?)
GlobalClass 0 0 +0.0% 1.00x
ArrayInClass 3737 3734 -0.1% 1.00x
ArrayOfGenericRef 9466 9489 +0.2% 1.00x(?)
Sim2DArray 13955 13945 -0.1% 1.00x(?)
MonteCarloE 102628 102375 -0.2% 1.00x(?)
SetUnion_OfObjects 26564 26687 +0.5% 1.00x
StringHasSuffixUnicode 61608 61602 -0.0% 1.00x(?)
Walsh 12515 12532 +0.1% 1.00x(?)
SetIsSubsetOf_OfObjects 1801 1793 -0.4% 1.00x(?)
ArrayAppend 3356 3354 -0.1% 1.00x(?)
DictionaryRemove 15989 16057 +0.4% 1.00x
LinkedList 26001 25999 -0.0% 1.00x(?)
RGBHistogram 37967 37812 -0.4% 1.00x(?)
ArrayAppendArrayOfInt 604 605 +0.2% 1.00x(?)
SetUnion 11494 11450 -0.4% 1.00x(?)
ObserverForwarderStruct 4932 4948 +0.3% 1.00x(?)
ArrayValueProp 2482 2493 +0.4% 1.00x(?)
RC4 8862 8873 +0.1% 1.00x(?)
Memset 19791 19791 +0.0% 1.00x
ArrayValueProp4 2840 2836 -0.1% 1.00x
TwoSum 4661 4660 -0.0% 1.00x(?)
ArrayValueProp2 2973 2960 -0.4% 1.00x(?)
SevenBoom 1413 1415 +0.1% 1.00x(?)
ObserverPartiallyAppliedMethod 7872 7852 -0.2% 1.00x(?)
Integrate 345 348 +0.9% 0.99x
SetIntersect_OfObjects 11187 11246 +0.5% 0.99x
Hanoi 18452 18692 +1.3% 0.99x
DictionaryRemoveOfObjects 43803 44029 +0.5% 0.99x(?)
SetIsSubsetOf 1996 2023 +1.4% 0.99x(?)
SetExclusiveOr 22378 22528 +0.7% 0.99x
SetExclusiveOr_OfObjects 37766 38081 +0.8% 0.99x(?)
ObjectiveCBridgeStubNSDataAppend 2603 2636 +1.3% 0.99x(?)
AngryPhonebook 2818 2843 +0.9% 0.99x(?)
ObjectiveCBridgeStubFromNSDateRef 3832 3901 +1.8% 0.98x
ObjectiveCBridgeFromNSDictionaryAnyObject 173423 176113 +1.6% 0.98x(?)
ObjectiveCBridgeFromNSSetAnyObject 86143 88027 +2.2% 0.98x
ObjectiveCBridgeStubToNSDateRef 3103 3155 +1.7% 0.98x(?)
StringEqualPointerComparison 9084 9297 +2.3% 0.98x
PolymorphicCalls 1065 1084 +1.8% 0.98x
ObjectiveCBridgeFromNSArrayAnyObject 73313 74989 +2.3% 0.98x(?)
ObjectiveCBridgeStubNSDateRefAccess 1164 1185 +1.8% 0.98x
Phonebook 58905 59933 +1.8% 0.98x(?)
ArrayAppendSequence 100227 101855 +1.6% 0.98x
ObjectiveCBridgeStubNSDateMutationRef 13254 13680 +3.2% 0.97x(?)
ObjectiveCBridgeStubToNSDate 13101 13684 +4.5% 0.96x(?)
ObjectiveCBridgeStubDateAccess 1035 1077 +4.1% 0.96x
StringWalk 21027 22106 +5.1% 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

@Gankra
Copy link
Contributor Author

Gankra commented Nov 9, 2016

@swift-ci Please smoke test


// SPI APIs
// TODO: undo Uint8 being used as a proxy for bool
func _fastCStringContents(_ nullTerminationRequired: UInt8)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just so you know, this is not 100% correct. ObjCBool is only UInt8 on some platforms, and it's theoretically possible that UInt8 and Bool would have different calling conventions.

Internal Clang bug rdar://problem/21170440 may provide a solution we can use in SwiftShims.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Summarizing: this is a bad hack that probably works fine in practice for the time being. When https://reviews.llvm.org/D26234 is merged, we can use that to do the strictly correct thing and provide a #define in SwiftShims.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Further, _fastCStringContents may need to account for the system encoding. See also #3151

@Gankra
Copy link
Contributor Author

Gankra commented Nov 14, 2016

@swift-ci Please test

@Gankra
Copy link
Contributor Author

Gankra commented Nov 14, 2016

(updated reflection tests because String now has an extra inhabitant)

@swift-ci
Copy link
Collaborator

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - cecdc889f43ab3aabcf3a7fa380277cdb6b0f774
Test requested by - @gankro

@swift-ci
Copy link
Collaborator

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - cecdc889f43ab3aabcf3a7fa380277cdb6b0f774
Test requested by - @gankro

@Gankra
Copy link
Contributor Author

Gankra commented Nov 14, 2016

@swift-ci Please smoke test

@dabrahams
Copy link
Collaborator

@swift-ci Please test

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 8, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - f6371e6
Test requested by - @dabrahams

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 8, 2017

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - f6371e6
Test requested by - @dabrahams

@tkremenek
Copy link
Member

This PR is for work that has been later subsumed by other String work. Closing,

@tkremenek tkremenek closed this Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants