We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
md5: f676672cf7cc42fa043b21807d572193
Issue Description:
If you profile this code:
let x:NSArray = "Hello world! Hello world! Hello world!".withCString { [String(cString: $0), String(cString: $0), String(cString: $0), String(cString: $0), String(cString: $0)] } while true { _ = x as! [String] }
You'll see a decent chunk of time spent in
specialized _ArrayBuffer._getElementSlowPath(_:)
which definitely seems like it should be avoidable (that calls objectAtIndex🙂.
I also wonder if there's more we could do to take advantage of the fact that the "NSStrings" in the NSArray are all in fact Swift.__StringStorage.
If you change the example code to
let x = "Hello world! Hello world! Hello world!".withCString { [String(cString: $0), String(cString: $0), String(cString: $0), String(cString: $0), String(cString: $0)] } let y = x as NSArray while true { _ = y as! [String] }
The profile looks even stranger, because we still go down the _getElementSlowPath path, but now that calls back into Swift like this:
+ ! : | 590 specialized _arrayForceCast<A, B>(_:) (in libswiftFoundation.dylib) + 587 [0x7fff6539cd1b] + ! : | + 453 specialized _ArrayBuffer._getElementSlowPath(_:) (in libswiftFoundation.dylib) + 70 [0x7fff65401c16] + ! : | + ! 441 _CocoaArrayWrapper.subscript.getter (in libswiftCore.dylib) + 25 [0x7fff64ccc7c9] + ! : | + ! : 328 @objc __SwiftNativeNSArrayWithContiguousStorage.objectAtSubscript(_:) (in libswiftCore.dylib) + 76 [0x7fff64e4a95c] + ! : | + ! : | 231 __ContiguousArrayStorageBase.withUnsafeBufferOfObjects<A>(_:) (in libswiftCore.dylib) + 109 [0x7fff64d153dd] + ! : | + ! : | + 102 _ContiguousArrayStorage._withVerbatimBridgedUnsafeBuffer<A>(_:) (in libswiftCore.dylib) + 175 [0x7fff64d155bf] + ! : | + ! : | + ! 99 partial apply for thunk for @callee_guaranteed (@unowned UnsafeBufferPointer<Swift.AnyObject>) -> (@owned Swift.AnyObject, @error @owned Error) (in libswiftCore.dylib) + 9 [0x7fff64fa0349] + ! : | + ! : | + ! : 93 partial apply for thunk for @callee_guaranteed (@unowned UnsafeBufferPointer<Swift.AnyObject>) -> (@unowned Int, @error @owned Error) (in libswiftCore.dylib) + 20 [0x7fff64f95cd4] + ! : | + ! : | + ! : | 46 -[__NSCFString retain] (in CoreFoundation) + 14 [0x7fff2df8eb61] + ! : | + ! : | + ! : | + 42 _CFRetain (in CoreFoundation) + 68,17,... [0x7fff2e0819b5,0x7fff2e081982,...]
The text was updated successfully, but these errors were encountered:
@swift-ci create
Sorry, something went wrong.
No branches or pull requests
Additional Detail from JIRA
md5: f676672cf7cc42fa043b21807d572193
Issue Description:
If you profile this code:
You'll see a decent chunk of time spent in
which definitely seems like it should be avoidable (that calls objectAtIndex🙂.
I also wonder if there's more we could do to take advantage of the fact that the "NSStrings" in the NSArray are all in fact Swift.__StringStorage.
If you change the example code to
The profile looks even stranger, because we still go down the _getElementSlowPath path, but now that calls back into Swift like this:
The text was updated successfully, but these errors were encountered: