Parallelize CodeSplitter's not-exclusive CFA computation - #10396
Open
rhuanhianc wants to merge 1 commit into
Open
Parallelize CodeSplitter's not-exclusive CFA computation#10396rhuanhianc wants to merge 1 commit into
rhuanhianc wants to merge 1 commit into
Conversation
computeNotExclusiveCfaForFragments traverses the run-asyncs of every other fragment for each fragment, so it is quadratic in fragment count. The iterations are independent, so run them on a thread pool. The serial loop is kept for when a dependency recorder is installed, since recording is order sensitive. JProgram.getTypeArray is now synchronized, being the only shared state the traversals create on demand. CodeSplitter goes from 181.4s to 71.5s on an application with 231 split points, with byte-identical output.
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.
computeNotExclusiveCfaForFragmentsis quadratic in the number of exclusive fragments: for each fragment it traverses the run-asyncs of every other fragment. Applications with many split points pay heavily — with 231 split points this loop alone is 25.6% of the permutation's CPU, and CodeSplitter overall is 181s of an 11-minute compile.The iterations are independent.
ControlFlowAnalyzer's copy constructor deep-copies every mutable set, each traversal writes only to its own analyzer, andControlFlowAnalyzeris purely analytical — it contains no setters on AST nodes. This runs them on a fixed thread pool.Two constraints are respected:
-compileReportthe original serial loop runs unchanged.-
JProgram.getTypeArraylazily creates array types in a plain HashMap and is reachable from the traversal, so it is nowsynchronized. It is the only shared mutable state on this path;getAllArrayTypes, which already sorts to avoid nondeterminism, is not reachable fromtraverseFromRunAsync.Happy to derive the pool size from
-localWorkersinstead ofavailableProcessors()if you'd prefer to avoid oversubscription when permutations are already compiled in parallel.CodeSplitter drops from 38.4s to 17.0s with 122 split points and from 181.4s to 71.5s with 231. Generated JavaScript is byte-for-byte identical across 874 output files from four applications. ant -Dtarget=test dev passes: 1936 tests, 0 failures.
Fixes #10395