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

Lower libwasmer headless size #3123

Merged
merged 3 commits into from
Aug 23, 2022
Merged

Lower libwasmer headless size #3123

merged 3 commits into from
Aug 23, 2022

Conversation

epilys
Copy link
Contributor

@epilys epilys commented Aug 21, 2022

Brought libwasmer-headless.a from 22MiB to 7.2MiB (on my machine)

By using lto optimization flags.

A qjs.wasm executable using the headless engine now weights 4.6MiB:

% du -sh qjs-he*.out
20M qjs-headfull.out
4.6M qjs-headless.out

epilys and others added 3 commits August 21, 2022 16:17
plotters 0.3.2 and pest 2.2.1 were yanked, issued `cargo update` to resolve.
3122: Update Cargo.lock dependencies r=epilys a=epilys

plotters 0.3.2 was yanked, issued `cargo update` to resolve.


Co-authored-by: Manos Pitsidianakis <manos@wasmer.io>
By using lto optimization flags.

A qjs.wasm executable using the headless engine now weights 4.6MiB:

% du -sh qjs-he*.out
 20M    qjs-headfull.out
4.6M    qjs-headless.out
@epilys epilys self-assigned this Aug 21, 2022
@epilys epilys added this to the v3.0 milestone Aug 21, 2022
Comment on lines -13 to -14
[lib]
crate-type = ["cdylib", "rlib"]
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is needed for wasm-bindgen / wasmer-js (wasi)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary for the lto though. Do you know what command/build fails for wasm-bindgen/wasmer-js if this is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can add the crate-type as a special case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Runtime tests - JS have passed by the way.

@syrusakbary
Copy link
Member

This relies in the LLVM LTO flags and using llvm bitcode to let LLVM optimize things. I believe there might be better ways to do it as wasmer-headless have proven, but I think this solution might be good enough for now

@syrusakbary syrusakbary merged commit 50756ba into master Aug 23, 2022
@bors bors bot deleted the lower-libheadless-size branch August 23, 2022 09:08
@epilys
Copy link
Contributor Author

epilys commented Aug 23, 2022

I believe there might be better ways to do it as wasmer-headless have proven, but I think this solution might be good enough for now

This is literally the same solution, except for using xargo to build a custom sysroot/std. Check out how wasmer-headless is built in .github/workflows/build.yml

@syrusakbary syrusakbary restored the lower-libheadless-size branch August 23, 2022 13:04
@syrusakbary
Copy link
Member

This is literally the same solution, except for using xargo to build a custom sysroot/std. Check out how wasmer-headless is built in .github/workflows/build.yml

Afaik the solution in this PR relies on LLVM bitcode and using LTO while the one for wasmer-headless doesn't (or at least, not directly). The one from xargo is also able to get wasmer-headless down to 2Mb, so perhaps there are also differences on the things included in each of the binaries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants