Skip to content

[5.4] In DI, cache whether a memory object is a box. #37484

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

Merged
merged 1 commit into from
May 19, 2021

Conversation

rjmccall
Copy link
Contributor

Boxes tend to have a small number of uses, so frequently finding the unique projection isn't too bad. Non-boxes, however, can have a large number of uses: for example, a class instance has expected uses proportionate to the number of stored properties. So if we do a linear scan of the uses on a non-box instruction, we'll scale quadratically.

Fixes SR-14532. 5.4 version of #37328.

Explanation: Avoid a quadratic slowdown in DI in class initializers when a class reference has many uses. This is typical when a class has a large number of properties.
Scope: The change is to Swift’s definitive initialization pass, which is run on all functions
Risk: Low
Testing: Manual; no straightforward way to test future regressions here
Issue: rdar://77217125
Reviewer: Erik Eckstein (on original PR)

Boxes tend to have a small number of uses, so frequently finding the
unique projection isn't too bad.  Non-boxes, however, can have a large
number of uses: for example, a class instance has expected uses
proportionate to the number of stored properties.  So if we do a linear
scan of the uses on a non-box instruction, we'll scale quadratically.

Fixes SR-14532.
@rjmccall
Copy link
Contributor Author

@swift-ci Please test

@rjmccall
Copy link
Contributor Author

@swift-ci Please nominate

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - c82eea2

@DougGregor
Copy link
Member

@swift-ci please test macOS

@rjmccall rjmccall merged commit d3d998f into swiftlang:release/5.4 May 19, 2021
@rjmccall rjmccall deleted the di-box-scaling-5.4 branch May 19, 2021 01:53
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.

3 participants