-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Cherry-pick compiler performance fixes [5.4] #35288
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
DougGregor
merged 19 commits into
swiftlang:release/5.4
from
slavapestov:perf-fixes-5.4
Jan 11, 2021
Merged
Cherry-pick compiler performance fixes [5.4] #35288
DougGregor
merged 19 commits into
swiftlang:release/5.4
from
slavapestov:perf-fixes-5.4
Jan 11, 2021
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… property wrappers
Let's avoid creating an ExportContext, which computes a bunch of irrelevant stuff. Also, delay the expensive call to overApproximateAvailabilityAtLocation() unless we know the declaration is conditionally unavailable.
This doesn't really fit the request evaluator model since the result of evaluating the request is the new insertion point, but we don't have a way to get the insertion point of an already-expanded scope. Instead, let's change the callers of the now-removed expandAndBeCurrentDetectingRecursion() to instead call expandAndBeCurrent(), while checking first if the scope was already expanded. Also, set the expanded flag before calling expandSpecifically() from inside expandAndBeCurrent(), to ensure that re-entrant calls to expandAndBeCurrent() are flagged by the existing assertion there. Finally, replace a couple of existing counters, and the now-gone request counter with a single ASTScopeExpansions counter to track expansions.
Combine the wasExpanded flag with the parent pointer, and remove the haveAddedCleanup flag since it's no longer necessary now that "re-expansion" is gone.
Other than simplifying some code, the big improvement here is that we 'freeze' the reference dependencies for a request down to a simple vector. We only use a DenseSet to store dependencies of active requests.
Also remove some unnecessary #includes from DependencyCollector.h, which necessitated adding #includes in various other files.
This becomes tricky with the new per-request cache representation. We can add it back later if we need it, but I feel like this code path isn't particularly useful right now anyway.
This is based on an earlier patch by @hamishknight. The idea is that instead of caching results in a single DenseMap that maps AnyRequest to AnyValue, we instead define a separate DenseMap for each request kind that directly uses the request as the key, and the request value as the value. This avoids type erasure and memory allocation overhead arising from the use of AnyRequest and AnyValue. There are no remaining usages of AnyValue, and the only usage of AnyRequest is now in the reference dependency tracking, which can be refactored to use a similar strategy of storing per-request maps as well.
... instead of passing around an ActiveRequest.
Just as with the result cache, instead of a single DenseMap with type-erased AnyRequest keys, we can use per-request maps for a nice performance improvement.
Part of <rdar://problem/72906325>.
@swift-ci Please test |
@swift-ci Please test source compatibility |
Build failed |
Build failed |
DougGregor
approved these changes
Jan 8, 2021
@swift-ci please test |
Build failed |
@swift-ci please test Linux |
Build failed |
@swift-ci Please test macOS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(Mostly, see below) fixes rdar://problem/72906325.
You can see there’s still a small regression in batch mode. This is due to two issues which need to be addressed separately: