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

Aggressive inlining options for wasm-opt #42

Merged
merged 14 commits into from
Sep 2, 2023
Merged

Conversation

kentosugama
Copy link
Contributor

@kentosugama kentosugama commented Aug 31, 2023

This PR is related to the new cost model.

@luc-blaeser found in some experiments that the new overhead pertaining to the cost of Call instructions can be mitigated down to ~4% with aggressive inlining options from wasm-opt. This has a large cost in terms of binary size (2.2x) but can serve as a temporary fix while we find better, Motoko specific inlining strategies.

The specific options are

-O4 -ifwl -aimfs 100

-ifwl stands for inline functions with loops
-aimfs stands for always inline max function size

The arguments to the optimize command has been restructured so adding further options in the future is easy.

@kentosugama kentosugama marked this pull request as ready for review August 31, 2023 19:52
@kentosugama kentosugama requested a review from a team as a code owner August 31, 2023 19:52
@kentosugama kentosugama self-assigned this Aug 31, 2023
src/bin/main.rs Outdated Show resolved Hide resolved
src/bin/main.rs Show resolved Hide resolved
src/bin/main.rs Show resolved Hide resolved
Copy link
Contributor

@chenyan-dfinity chenyan-dfinity left a comment

Choose a reason for hiding this comment

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

LGTM.

Minor point: since we have separate commands for shrink and optimize, we can also put them into separate modules.

Cargo.toml Show resolved Hide resolved
src/lib.rs Show resolved Hide resolved
src/optimize.rs Outdated Show resolved Hide resolved
@kentosugama kentosugama merged commit 0cc218f into main Sep 2, 2023
@kentosugama kentosugama deleted the aggressive-inlining branch September 2, 2023 13:58
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.

2 participants