4 ms·
8MB seems high for Rust. Even the project I did [1] which was using D (with GC) ended up with an 8MB WASM. Rust's WASM target is much more exercised than D's, s
by speps 3y ago
8MB seems high for Rust. Even the project I did [1] which was using D (with GC) ended up with an 8MB WASM. Rust's WASM target is much more exercised than D's, so I think you might need to tweak some compile options.
[1] https://github.com/speps/tt https://github.com/speps/tt
- BD103 3y agoRust binaries seem to be larger than they should be, though. I believe Kobzol [1] has been making some work on that. [1]: https://kobzol.github.io/rust/cargo/2024/01/23/making-rust-binaries-smaller-by-default.html https://kobzol.github.io/rust/cargo/2024/01/23/making-rust-b...
- lesuorac 3y ago(Not op) I agree that 8MB seems high. I can generate a 6MB binary using `--debug` with `wasm-pack` so definitely for a more complex thing I could see 8MB. I think `--release`, `codegen-units = 1`, `opt-level = 3/z` are the three biggest things that affect binary size for me. I don't think 8MB is that big a deal for a web game though. Like how large are the images? If you're going to dynamically load in like 50+ MB of assets then having an initial game of 8 MB is the small pole in the tent. I have my stuff setup as a PWA so once everything has been downloaded it takes 0 MB on the wire to open a second time; you could set-up the game as 2 binaries; one super-small one that just basically handles an opening cinematic and a larger one that can actually play the game which is downloaded while the cinematic plays (or is cached in future opens).
- shzhdbi09gv8ioi 3y agoThat's possible. I did spend quite a bit of time tinkering with compiler flags and followed the recommendations, but there is many knobs. For what it's worth I don't think 3MB is extremely large anymore, as several popular websites already weight in 2-3 MB for a full page loads. Examples: * www.youtube.com = 3.3 MB * www.tiktok.com = 3.3 MB * www.instagram.com = 2.1 MB (according to https://www.supermonitoring.com/p/page-speed https://www.supermonitoring.com/p/page-speed) That said, I would love to shave off more size off my wasm binaries :-) Some notes I found just now seems to be in line with my results, though: https://github.com/bevyengine/bevy/issues/3978#issuecomment-1044333040 https://github.com/bevyengine/bevy/issues/3978#issuecomment-...
- shzhdbi09gv8ioi 3y agoFWIW, this is my relevant Cargo.toml settings: [profile.release] lto = "fat" codegen-units = 1 opt-level = 3 debug = false panic = "abort" strip = "debuginfo" [profile.wasm-release] inherits = "release" opt-level = "z"