Skip to content

wasm-opt performance #4619

Open
Open
@arsnyder16

Description

@arsnyder16

I am working what would expect to be a rather large c++ code based and compiling for webassembly

One thing i have noticed during the process is the performance of wasm-opt across my .wasm file. I am wondering if there is anything i can do to help profile where the bottlenecks are in wasm-opt and if we can address them.

Here is breakdown of file size, and run time of wasm-opt
baseline perf.wasm -> 419.88MB
O0 38.6 MB
O1 33.6 MB
O2 29.3 MB
O3 30.7 MB
Os 28.7 MB <- Our current build optimization level
Oz 28.3 MB

I am using the following script
ls -l perf.wasm
for OPT in 0 1 2 3 s z
do
  time /root/emsdk/upstream/bin/wasm-opt -O$OPT --strip-dwarf --post-emscripten --low-memory-unused --zero-filled-memory --strip-debug --strip-producers \
    perf.wasm -o perfO$OPT.wasm --mvp-features --enable-threads --enable-mutable-globals --enable-bulk-memory --enable-sign-ext
  ls -l perfO$OPT.wasm
  sleep 15s
done

Here is the output

-rw-r--r-- 1 root root 440277504 Apr 27 08:52 perf.wasm

real    0m12.978s
user    0m17.046s
sys     0m1.136s
-rw-r--r-- 1 root root 40548421 Apr 27 09:21 perfO0.wasm

real    0m28.735s
user    1m47.963s
sys     0m1.555s
-rw-r--r-- 1 root root 35313836 Apr 27 09:22 perfO1.wasm

real    1m44.731s
user    7m1.825s
sys     0m1.861s
-rw-r--r-- 1 root root 30765732 Apr 27 09:24 perfO2.wasm

real    2m15.277s
user    11m46.021s
sys     0m1.842s
-rw-r--r-- 1 root root 32263192 Apr 27 09:26 perfO3.wasm

real    2m2.222s
user    9m3.411s
sys     0m1.860s
-rw-r--r-- 1 root root 30136226 Apr 27 09:29 perfOs.wasm

real    1m59.970s
user    9m23.343s
sys     0m2.571s
-rw-r--r-- 1 root root 29763508 Apr 27 09:31 perfOz.wasm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions