Replies: 1 comment 10 replies
-
This is some very interesting code you got here. Just to make sure, did you build in release mode? |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the Bug
I suspect I might just be missing a compiler optimization here.
Essentially, I'm seeing the same function calls being slower from within WASM than I am from JS to WASM. This is especially pronounced if I have a for loop, or nested for loops. If I create the for loops in JS and call into WASM, it's 2.5x faster than if I do the entire thing in WASM (for the exact same function), which is very counter-intuitive (as it's not needing to cross the JS-WASM boundary).
Perhaps there's some sort of loop or memory checking being done that I can turn off?
Steps to Reproduce
Compiling with:
Called like so:
(Have tried all the
wasm-opt
options, including turning it off, none make a noticeable difference. Also tried nightly, with no difference)Expected Behavior
Looping from within WASM should take roughly the same time as from JS, or even faster.
Actual Behavior
Observed on a Mac M1 Pro, Node.js v20.6.1
ie,
l2_loop
, which is doing the work entirely in WASM, and calling the same function, is 2.5x slower.Beta Was this translation helpful? Give feedback.
All reactions