Git Product home page Git Product logo

Comments (8)

ospencer avatar ospencer commented on May 23, 2024 1

I wouldn't say anything is up. Different languages include different amounts of the runtime in the final binary. Besides hand-written wasm, AssemblyScript will get you the tiniest binaries since the code you write is very similar to what gets emitted (it's not actually TypeScript, so there's no runtime it needs to ship other than malloc and a light GC). It's a similar problem with Swift—they include the entire standard library in the binaries.

Rust is definitely a premier language for WebAssembly, but it wasn't necessarily designed with WebAssembly in mind. It's getting better over time though.

wasm-opt is really smart, but there's a lot of situations that it can't understand how to optimize without some help from the compiler. I can go into a ton of detail on this :)

I can also say that a handful of languages don't need a wasm-opt pass (though it won't hurt). AssemblyScript and Grain, for example, already have wasm-opt run on the wasm as a part of their compilation process.

from subo.

samderlust avatar samderlust commented on May 23, 2024 1

@samderlust are you still working on this?

@denopink Hi, sorry no, I'm not working on this one right now. I remembered back then I read some documents that mentioned wasm file size was optimized by default or something (Couldn't find it now). So I stopped working on this. sorry for not updating

from subo.

samderlust avatar samderlust commented on May 23, 2024

hi,, I'm working on this

from subo.

denopink avatar denopink commented on May 23, 2024

@samderlust are you still working on this?

from subo.

danielledeleo avatar danielledeleo commented on May 23, 2024

A quick experiment with wasm-opt on one of our Rust Runnables from the Reactr repo got these results:

wasm-opt -o rust-get.O3.wasm -O3 rust-get.wasm
wasm-opt -o rust-get.Os.wasm -Os rust-get.wasm

-rw-r--r--  1 jagger  staff   1.5M 23 Nov 11:40 rust-get.O3.wasm
-rw-r--r--  1 jagger  staff   1.5M 23 Nov 11:40 rust-get.Os.wasm
-rw-r--r--  1 jagger  staff   1.8M 20 Nov 21:36 rust-get.wasm

Something is up with our Rust Runnables, because TinyGo spits out much smaller files for similar behaviour.

-rwxr-xr-x  1 jagger  staff    57K 20 Nov 21:36 tinygo-cache.wasm

And AssemblyScript is smaller still:

-rw-r--r--  1 jagger  staff   6.8K 20 Nov 16:54 as-get.wasm

from subo.

danielledeleo avatar danielledeleo commented on May 23, 2024

@ospencer any ideas?

from subo.

denopink avatar denopink commented on May 23, 2024

@ospencer that makes sense. Since it doesn't hurt to run wasm-opt, is there any downsides to running it as a default behavior for subo build [dir] and then provide a flag to disable it subo build [dir] --no-opt?

from subo.

ospencer avatar ospencer commented on May 23, 2024

We could maybe do something like that, yeah. The only thing I'm concerned about is when building with --native, I don't want to require having wasm-opt available on the host machine 🤔

from subo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.