-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize binary with wasm-opt
in release mode
#206
Conversation
On my laptop on a simple game example, it currently takes 250s and reduces the file size by 34%. These numbers will probably change quite a bit with #199 though, so I wouldn't read into it too much at this stage. |
@@ -19,6 +19,12 @@ impl RunArgs { | |||
matches!(self.subcommand, Some(RunSubcommands::Web(_))) | |||
} | |||
|
|||
/// Whether to build with optimizations. | |||
#[cfg(feature = "wasm-opt")] | |||
pub(crate) fn is_release(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
How do I use this? I ran $ bevy build web --release
error: unexpected argument '--release' found
Usage: bevy build web
For more information, try '--help'. |
Cant test it right now but if i remember correctly it was 'bevy build -r web' |
That's right, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yup, bevy build --release web
did the trick! This looks good, merge it once you're happy with the state it's in. :)
Objective
Closes #196, unblocks TheBevyFlock/bevy_new_2d#312.
With
wasm-opt
, we can further increase the performance and reduce the file size of the Wasm binary we use for web builds.This speeds ups the app both in-game and the loading times.
Solution
As a simple first solution, we add a hard-coded size optimization pass in release mode.
In future PRs, we can make this more configurable.
To the user, we log the time the optimization took as well as the file size reduction as percentage.
This is behind the
wasm-opt
feature flag (currently disabled by default), to give the user a way to turn this off and because this increases compile times of the CLI quite a bit.