-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wasm-opt wasm port performance #6338
Comments
(these numbers are all |
Actually after more careful measurements of a longer task, removing SINGLE_FILE, and reading |
Enabling There is a 0.5 second startup lag, however, related to the initial parse of the 6 MB wasm file I assume. Node.js doesn't cache compiled wasm atm AFAIK, but if it did do that (like browsers did) then that issue would mostly go away. |
This issue is about porting wasm-opt itself to wasm, and how fast it runs there.
The main blocker here was that it was 10x slower than a native build:
emscripten-core/emscripten#15727
That turned out to be an issue with multithreading, and is fixed by using Emscripten's recent
mimalloc
port (see last comments in that issue). Now instead of 10x slower it is 2x slower, which is not bad considering it is managing to saturate all CPU cores like a native build.Looking more into the remaining 2x, that factor remains even when pinning both builds to a single core, so multithreading is not related. Some quick profiling:
C++ symbols above 1% (linux perf)
Wasm symbols above 1% (node --prof)
In node there is some 5-10% overhead that is not compiled wasm code, and which seems to be V8 compiling the wasm as best I can tell, but that is minor compared to the 2x slowdown so we can ignore it. The compiled wasm breakdown looks like this:
LocalGraph
is high in both, as is malloc/free, which all makes sense. More suspicious is thatReFinalize
takes over 10% in wasm while in native C++ it is hardly noticeable:That might be related to inlining differences, if ReFinalize does lots of malloc/free which show up in C++ as malloc/free but are inlined in wasm and end up there as the calling function.
ReFinalize does not do that much work beyond a quick walk of the module, so this suggests all walks are slower in wasm...
The text was updated successfully, but these errors were encountered: