-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Large filesize (1MB of raw WASM) #269
Comments
Making this change -wasm-opt = ['-O4', '--dce']
+wasm-opt = ['-g'] takes the filesize from
I'm not familiar with these tools, but it looks like there's no giant blob of some dependency getting smashed in. Seems like this is just how much it takes. FWIW, matter.js seems to be ~120kB. |
I'm not too familiar with codesize optimizations, but that's a valuable topic for sure! I see a few serde items on the larger items, I'm curious how the filesize changes when the serialize feature is disabled 🤔. Also, from guidelines at https://rustwasm.github.io/book/reference/code-size.html#use-trait-objects-instead-of-generic-type-parameters ; heavy generic-based codebase tends to generate a lot of code (due to monomorphization), and rapier heavily uses those. It might be interesting to parse somehow the top dependencies rather than the top functions 🤔 |
I'm currently trying to implement Rapier on CloudFlare Workers, but they have a 1MB limit on code size and version |
https://github.com/Master-Hash/rapier.js/ I remove the control, serialize and debug render modules, use Oz instead of O3, turn on simd(which increase size), then the size is 676kb (224kb with zstd19). You can download the artifacts to use, if it turns out to be useful. |
@Master-Hash That's some impressive progress. I would like to know how you went about customizing the build. I'm a JavaScript guy. I don't know a lot about Rust. I'd like to remove the vehicle controller, the character controller, anything concerning joints and I don't believe I need serialization either. However, I still use the debug render in development mode. Poking around in the build files I found ways to turn off a few things but I did not have success running a build. I wonder if there's anything more that could bring it down to a basic rigid body simulator. |
See commits:
The basic idea is, simply not to import the rust module, delete the corresponding module in ts, then delete the attributes and methods in World. |
Has any effort gone into filesize? Maybe there are some low hanging fruit?
@dimforge/rapier2d 0.12.0
, the filerapier_wasm2d_bg.wasm
is1.05MB
0.11.2
is1.05MB
0.11.0
is1.04MB
0.10.0
is1.04MB
0.9.0
is1.02MB
So there's no sudden jump, seems like it's always been very large.
The text was updated successfully, but these errors were encountered: