News for hackers. Stuff that matters.
Re:Rust: Enable WebAssembly backend by default by killercup on Sunday November 26, 2017 @10:26AM (#15781251)
This Rust code [1] heap allocates some things (e.g., a string with `String::from`), and results in this [2] WASM file, which is 65kB, or 25kB after `gzip -9`.

[1]: https://github.com/killercup/wasm-experiments/blob/bf3b30eed...

[2]: https://github.com/killercup/wasm-experiments/blob/bf3b30eed...

Re:Rust: Enable WebAssembly backend by default by josephg on Sunday November 26, 2017 @04:28PM (#15783096)
Thats much smaller than I expected, especially given how large rust native binaries usually are. What allocator does that use? Does that 65k include its own malloc implementation like we needed for asmjs, or does WASM expose a system malloc library or something?
Re:Rust: Enable WebAssembly backend by default by steveklabnik on Sunday November 26, 2017 @04:42PM (#15783174)
wasm exposes "memory sections", which the module states up-front how much it wants. It can also generally call a "grow memory" function that makes this space bigger. That's it, from the direct wasm perspective.

That said, this target uses https://github.com/alexcrichton/dlmalloc-rs

Re:Rust: Enable WebAssembly backend by default by azakai on Sunday November 26, 2017 @03:20PM (#15782766)
It should be possible to reduce that a bunch more, 65kB sounds high.

Running the binaryen optimizer on that wasm shrinks it by 6%. Probably more can be done on the Rust side.

Re:Rust: Enable WebAssembly backend by default by killercup on Sunday November 26, 2017 @03:42PM (#15782857)
Absolutely, yeah. Having a real linker will help with that as well. Until then, you can also compile with

    [profile.release]
    opt-level = "s"
(i.e., optimizing for size), to get it down to 23kB gzipped.