Repository navigation
Keep dataflow anomaly states in arrays instead of copied maps - #1479
Merged
Merged
Conversation
The analysis rebuilt its whole map of locals on every read and write, and a local's multimap of reads on every read of it, so a long body cost the square of its size. A state is now an array indexed by per-body ids of the locals, holding sorted arrays of write ids and of (write, read) pairs; an operation copies the array once, and a merge returns an input when that input already holds the union. The lattice and its equality are unchanged, so the fixpoint takes the same steps and reports the same diagnostics. The never-read warnings of a local now come in source order.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
The dataflow anomaly analysis (uninitialised reads, use after destroy, never-read assignments) rebuilt its whole map of locals on every read and write, and a local's multimap of reads on every read of it, so a long body with loops cost roughly the square of its size.
A state is now an array indexed by per-body ids of the locals; each local keeps sorted arrays of write ids and of (write, read) pairs. An operation copies the array once, and a merge returns one of its inputs when that input already holds the union. The lattice and its equality are unchanged, so the fixpoint takes the same steps and reports the same diagnostics.
Utils.mergeMaps,mergeMultiMaps,mergeSetsandFunction2had no other users and are removed.Measured
Old and new implementation side by side in one JVM, each body analysed by both, alternating which runs first (both totals include the attribute evaluation they share):
The slowest single body went from 184 ms to 8 ms. On map A the analysis was about 3% of a 35 s unoptimised build.
Verified
FlowAnalysisTests,ClosureTests,SimpleStatementTests,BugTests,NewFeatureTestsandClassesTests: identical number of transfer steps per body and identical diagnostics. The only difference was the order of one local's never-read warnings in two tests.UtilsTestpass locally (Windows). The change is in-memory only, with no file, path or process handling.Behaviour change
The never-read warnings of a body now come in the order of the locals' declarations and, per local, in source order. Before, the order followed the order in which branch states reached the end of the body.
FlowAnalysisTests.neverReadAssignmentWarningsComeInSourceOrderfails on master and passes here.