perf: use unordered_set for Name sets for better compile speed#8586
perf: use unordered_set for Name sets for better compile speed#8586Changqing-JING wants to merge 2 commits intoWebAssembly:mainfrom
Conversation
cd4d3c2 to
7b0e889
Compare
|
@Changqing-JING what workloads did you test on? I ran a test with a large Java testcase. Instruction counts, branches, and walltime were within noise. If you are seeing 35% on this code, perhaps there is something special in your testcase? In general, the number of globals and break targets is very small, so a normal set can do well (by saving the time it takes to do hashing). |
|
@kripken Thank you for review
time node ./bin/asc.js -O2 -o build/test.wasm ./test.ts
real 6m27.324s
user 6m19.690s
sys 0m11.712sFor better understanding of this problem, I created an example to emulate the assemblyscript case
|
wasm::Namehas an O(1) pointer-based hash butoperator<does O(n)memcmp, makingstd::set<Name>unnecessarily slow. On large workloads, ~35% ofwasm-optCPU time was spent in__memcmp_evex_movbeinsideEffectAnalyzer::walkcalled fromCodeFolding. Switching the fourstd::set<Name>fields inEffectAnalyzer,NameSetin branch-utils.h, and the local containers inCodeFoldingto their unordered equivalents eliminates the bottleneck.