[Feat][CLI]: add w4 opt | wasm-opt integration#261
Conversation
|
✔️ Deploy Preview for wasm4 ready! 🔨 Explore the source changes: 5898224 🔍 Inspect the deploy log: https://app.netlify.com/sites/wasm4/deploys/61ccadb63811e500078c3a9a 😎 Browse the preview: https://deploy-preview-261--wasm4.netlify.app |
|
This happens automatically at compile time if someone has If that's too hard is there a reason not to make that easier - rather than making optimization a separate step? |
|
Is bundling native binaries of wasm-opt a possibility? The JS/wasm version of wasm-opt has a noticeably slow startup delay for me. |
|
Not all languages provide a way to opt the cart.wasm.
This is also one of the reasons why I opened #203 |
I'd like to have an opinionated version that works without much configuration or knowledge of the underlying tool. Note that you can already use wasm-opt even if you do not have it installed using npx: npx --package=binaryen -- wasm-opt --help
The slow startup is caused by
Yes but it is harder to maintain and you need to either:
Note that binaryen binaries are not tiny: https://github.com/WebAssembly/binaryen/releases/tag/version_104
👍 I think that we should also add readme files to every starting template: |
Description: integrates binaryen wasm-opt inside `w4`. - https://github.com/AssemblyScript/binaryen.js - https://github.com/WebAssembly/binaryen
Other changes: - display cart size - display size reduction
5898224 to
eb0ca0c
Compare
|
The startup delay I mentioned happens in the JS/wasm version even when invoking without npx: $ time node_modules/binaryen/bin/wasm-opt --version
wasm-opt version 104 (version_104)
node_modules/binaryen/bin/wasm-opt --version 10.18s user 0.20s system 349% cpu 2.969 total
$ time ./binaryen-version_104/bin/wasm-opt --version
wasm-opt version 104 (version_104)
./binaryen-version_104/bin/wasm-opt --version 0.00s user 0.00s system 83% cpu 0.004 total3 second delay for the JS version vs basically instant for the native version. |
That's quite a bit. time cli/node_modules/.bin/wasm-opt --version
wasm-opt version 104 (version_104)
real 0m1.566s
user 0m5.594s
sys 0m0.228sAlternatives to binaryen.jsIf we are not going to use
I'm not a big fan of this solution because downloading executables at postinstall is a bit sketchy and could not work if the users installs Note that there's already a package that uses this approach: https://www.npmjs.com/package/wasm-opt but I've not tried it.
I personally prefer solution 3. or 4. I believe that this feature is important and should be part of |
|
Could it be "both" is perhaps an option...? ...if it's much easier to package the I mean technically you'd want to/need to use this for release, not necessarily every single build, right? |
Description
This PR adds
w4 optthat is a simple opinionated integration ofwasm-optprovided by binaryen.js.Usage
wasm-opt flags
New Dependencies
This PR adds binaryen.js as
dependencyof "wasm4".Tested node versions
Feedback
Ideas and improvements are welcome.