[NFC] Improve SimplifyLocals compile-time performance#8604
Open
Changqing-JING wants to merge 1 commit intoWebAssembly:mainfrom
Open
[NFC] Improve SimplifyLocals compile-time performance#8604Changqing-JING wants to merge 1 commit intoWebAssembly:mainfrom
Changqing-JING wants to merge 1 commit intoWebAssembly:mainfrom
Conversation
900a03f to
4f5f920
Compare
4f5f920 to
d673f1b
Compare
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
checkInvalidationsfunction in SimplifyLocals had O(N × S) complexity, iterating all sinkables for every visited expression. This PR adds reverse indices (localReadBySinkable_,localWrittenBySinkable_,heavySinkables_) so thatcheckInvalidationsonly examines sinkables whose effects actually conflict with the current expression. TheSinkablesmap andlocalsRead/localsWrittensets are also changed from ordered to unordered containers for faster lookups. A newhasNonLocalOrderingEffects()helper is added toEffectAnalyzer(composing existing helpers likewritesGlobalState()andreadsMutableGlobalState()) so the classification stays in sync automatically when new effect types are added.Benchmark data
Use the wasm file in
#7319 (comment)
Note: don't run benchmark with
-Oz, use--simplify-localscan save time.Before this PR
time ./build/bin/wasm-opt --simplify-locals --enable-bulk-memory --enable-multivalue --enable-reference-types --enable-gc --enable-tail-call --enable-exception-handling -o /dev/null ./test3.wasm real 0m42.423s user 9m45.063s sys 0m44.099sIn this PR
time ./build/bin/wasm-opt --simplify-locals --enable- bulk-memory --enable-multivalue --enable-reference-types --enable-gc --enable-tail-call --enable-e xception-handling -o /dev/null ./test3.wasm real 0m29.725s user 6m25.124s sys 0m30.590s