[Runtime] Reduce the amount of stack space used in recursive protocol conformance checking.#90558
Open
mikeash wants to merge 1 commit into
Open
[Runtime] Reduce the amount of stack space used in recursive protocol conformance checking.#90558mikeash wants to merge 1 commit into
mikeash wants to merge 1 commit into
Conversation
… conformance checking. Deeply nested types can run out of stack space in protocol conformance checks. Apply a few strategies to reduce how much space each level of recursion needs, to allow for deeper types. * Use llvm::function_ref instead of std::function for some of the callbacks. * Reduce the descriptorPath SmallVector's inline size from 8 to 2. * Outline a swift_getTypeByMangledName call that requires building std::functions. * Change the conformance descriptor scan loop to keep less information live during the ConformanceLookupResult::fromConformance call. This call can recurse, and it's in the middle of a loop with a lot of state. We can instead gather the matching conformance descriptors, then extract the info from them afterwards. This allows us to collect the results in a SmallVector of pointers rather than a SmallDenseMap of larger types. It also simplifies the code a bit, as we can control whether we can use scanSectionsBackwards to decide to pick the first or last match, rather than pulling the scan loop into a lambda and hoping it optimizes well. rdar://181059210
Contributor
Author
|
@swift-ci please benchmark |
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
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.
Deeply nested types can run out of stack space in protocol conformance checks. Apply a few strategies to reduce how much space each level of recursion needs, to allow for deeper types.
Use llvm::function_ref instead of std::function for some of the callbacks.
Reduce the descriptorPath SmallVector's inline size from 8 to 2.
Outline a swift_getTypeByMangledName call that requires building std::functions.
Change the conformance descriptor scan loop to keep less information live during the ConformanceLookupResult::fromConformance call. This call can recurse, and it's in the middle of a loop with a lot of state. We can instead gather the matching conformance descriptors, then extract the info from them afterwards. This allows us to collect the results in a SmallVector of pointers rather than a SmallDenseMap of larger types. It also simplifies the code a bit, as we can control whether we can use scanSectionsBackwards to decide to pick the first or last match, rather than pulling the scan loop into a lambda and hoping it optimizes well.
rdar://181059210