Skip to content
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 #15

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open

Wasm #15

wants to merge 39 commits into from

Conversation

charlieroberts
Copy link
Owner

No description provided.

@abramhindle
Copy link
Contributor

Hey Charlie, if you link in wabt.js (wat2wasm) you can generate wasm on the fly and assemble it, instead of just calling wasm functions. The overhead of popping in an out of wasm is often quite high.

@charlieroberts
Copy link
Owner Author

Hey Abram,

Hope all is well with you! There's only one call to wasm per callback block... I don't think it can get any lower than this :) The wat2wasm happens during the gulp build... which I just realized I haven't committed. Will do so now!

@charlieroberts
Copy link
Owner Author

here's the gulpfile (such as it is): https://github.com/charlieroberts/genish.js/blob/wasm/gulpfile.js

... and here's the relevant part of the audioworklet: https://github.com/charlieroberts/genish.js/blob/wasm/src/module.js#L70

It's gonna take me a bit to clean up this branch, I probably should have just used a new repo.

@charlieroberts
Copy link
Owner Author

last but not least I updated the README in the wasm branch to include a bit more description / motivation: https://github.com/charlieroberts/genish.js/blob/wasm/README.md

There's also a link to a wasm-enabled playground there if you want to try it out.

@charlieroberts
Copy link
Owner Author

I just found this fantastic essay on js > wasm (and vice-versa) in Firefox from a few years back... turns out it's not as slow as it was originally: https://hacks.mozilla.org/2018/10/calls-between-javascript-and-webassembly-are-finally-fast-🎉/

@abramhindle
Copy link
Contributor

That's a really interesting FF article about the performance of wasm. Yeah wasm is pretty close to the JIT'd code in FF. FF does wasm well. Last year when I tested Wasm versus JS, the gains or similar performance was mostly apparent when you stayed in wasm long enough or used floating point operations. https://github.com/abramhindle/impractical-wasm (video: https://www.youtube.com/watch?v=VkpBLEif6B8 ). I'm glad to see that you're having a lot of success porting it.

@charlieroberts
Copy link
Owner Author

oh nice, that's a much better guide to doing this than most of the ones I looked at when I was trying to figure out how this all worked. thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants