-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Docs] Update OptimizationTips for 'id-as-Any' #3808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Now that value types may also be bridged to Objective-C classes, using an Array of value types is no longer sufficient to eliminate internal bridging-related calls.
It is still true that |
@gribozavr yes, but you still get bridging-related calls. Here are two instruments traces, Array vs ContiguousArray with T as a plain-swift struct: Array:
ContiguousArray:
I'm not 100% sure what to make of it from an optimisation standpoint though - CA takes longer to copy, but A has all of those bridging calls. Maybe that's just noise and a quirk of my particular situation. |
@karwa I don't see any bridging calls. |
OK, yes, sure - you're right. |
@karwa Please file performance regressions you find as bugs. We're actively fixing a few things in this area, and it's premature to write up any advice based on the current state of things. |
@jckarter After investigating some more (removing those big copies and bringing runtime down to 1.2s), it looks like there are still much bigger performance differences between Array and ContiguousArray than you would expect when T is a plain struct. Array is about twice as slow. Filed https://bugs.swift.org/browse/SR-2196 with actual Instruments trace files |
@karwa Thanks! |
What's in this pull request?
Now that value types may also be bridged to Objective-C classes, using an Array of value types is no longer sufficient to eliminate internal bridging-related calls.
Resolved bug number: (SR-)
Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
A smoke test on macOS does the following:
device standard libraries are not built.
version of these tests are not run.
A smoke test on Linux does the following:
tests are not run.
Validation Testing
Lint Testing
Note: Only members of the Apple organization can trigger swift-ci.
Now that value types may also be bridged to Objective-C classes, using an Array of value types is no longer sufficient to eliminate internal bridging-related calls.