Skip to content
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

Optimise binaries with wasm-opt #423

Merged
merged 5 commits into from
Oct 17, 2023
Merged

Optimise binaries with wasm-opt #423

merged 5 commits into from
Oct 17, 2023

Conversation

RReverser
Copy link
Contributor

@RReverser RReverser commented Oct 12, 2023

Description of Changes

Now that our ABI checks can handle binaries produced by wasm-opt, we can use it (if installed) to optimise produced Wasm binaries.

For now it's added as an optional step until we figure out a decent deployment strategy to automatically get it for the user. (There are some wrappers on crates.io, but they tend to lag behind modern versions and take a while to compile, whereas Binaryen provides official prebuilt binaries on Github.)

This gives an easy 8-10% performance boost in iteration benchmarks, much more for an empty table but that's less interesting.

API and ABI

  • This is a breaking change to the module ABI
  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI
  • This is a breaking change to the SDK API

If the API is breaking, please state below what will break

Expected complexity level and risk

*How complicated do you think these changes are? Grade on a scale from 1 to 5,

1

This complexity rating applies not only to the complexity apparent in the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning ways.

@kulakowski
Copy link
Contributor

I'm really curious what optimizations are affecting our modules most.

@RReverser
Copy link
Contributor Author

I'm really curious what optimizations are affecting our modules most.

That would need to be much deeper investigation and likely out of scope of this PR.

Signed-off-by: Ingvar Stepanyan <me@rreverser.com>
Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I appreciate not depending on wasm-opt, but encouraging users to install it. Long-term I wonder if we can link against binaryen rather than invoking it as a subprocess, but this is good for now.

@RReverser
Copy link
Contributor Author

Long-term I wonder if we can link against binaryen rather than invoking it as a subprocess, but this is good for now.

Yeah I'd like that too. As I mentioned in the PR, there are some Rust wrappers that I was hoping to use, but they all tend to be outdated, and add non-trivial build time. It would be nice to figure out some cross-platform solution that doesn't involve rebuilds, but for now I don't see it.

@RReverser RReverser merged commit 4f901ab into master Oct 17, 2023
@RReverser RReverser deleted the wasm-opt branch October 17, 2023 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants