Repository navigation
Fix exponential analysis slowdowns on deeply nested code - #7078
Merged
Merged
Conversation
The key-value and value-only item lists now share the node, so describing a value nested N shapes deep no longer costs 2^N. Amp-Thread-ID: https://ampcode.com/threads/T-01a1debc-f897-7034-af27-e4609439c823
VariableLivenessResolver remembers the last next set, context and head of each loop; an outer pass whose next set and context cover them starts the inner loop's iteration from that head instead of from scratch. Amp-Thread-ID: https://ampcode.com/threads/T-01a1debc-f897-7034-af27-e4609439c823
…ull narrowing VariableFlow::choice() of a sequence and its own first flow becomes a sequence of that flow and the optional rest, and the nullsafe property fetch and method call handlers ask once per link whether it did not short-circuit. Amp-Thread-ID: https://ampcode.com/threads/T-01a1debc-f897-7034-af27-e4609439c823
…lone The member-by-member check cannot come out yes unless the compound answer does, which replaced its result anyway; asking both walked nested members twice at every level. Amp-Thread-ID: https://ampcode.com/threads/T-01a1debc-f897-7034-af27-e4609439c823
…thmetic When the assigned expression is arithmetic, concatenation or bitwise operators over variables, literals and constants, conditions on variables it does not read are not assigned, and the derived type of a consequent without remaining conditions is computed once. Amp-Thread-ID: https://ampcode.com/threads/T-01a1debc-f897-7034-af27-e4609439c823
…e non-null narrowing Amp-Thread-ID: https://ampcode.com/threads/T-01a1debc-f897-7034-af27-e4609439c823
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.
Fixes for analysed code that made the analyser slow down exponentially, plus one cubic case. Each commit fixes one of them, mirrors the change in its
turbo-ext/srcC++ file, and adds a benchmark totests/bench/datawith the Tally header.Wall clock is measured without the extension and includes about 1s of startup. Tally counts are instructions.
closure-nested-shape-description.phpConstantArrayType::toPhpDocNode()built each nested value twice (2^depth)nested-loops-liveness.phpVariableLivenessResolverre-solved inner loops from scratch on every outer passnullsafe-chain-narrowing.php?->chains:VariableFlow::choice()and the nullsafe narrowing callbacks repeated work per linkgeneric-inheritance-chain.phpCrossCheckInterfacesHelperrevisited classes;ClassReflection::getParentClass()did not cache generic parentsnested-nullable-shape-accepts.phpUnionType::accepts()of another union walked nested shapes twice per levelloop-derived-assignments.phpAll of these produce the same analysis output as before, with and without the turbo extension. Verified with:
make phpstan