-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Gate many CLI/Wasmtime features behind Cargo features #7282
Gate many CLI/Wasmtime features behind Cargo features #7282
Conversation
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.
Looks great to me, the new page in the guide looks great as well.
$ export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1 | ||
$ cargo build --release --no-default-features --features disable-logging | ||
$ ls -l ./target/release/wasmtime | ||
-rwxr-xr-x@ 1 root root 3.3M Oct 18 08:43 target/release/wasmtime |
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.
Stripping debuginfo using -Cstrip=debuginfo
should also help a fair bit, right?
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.
Oh excellent suggestion I forgot about that! Turns out the majority of the win from -Zbuild-std
was stripping debuginfo
pub enable_pcc: Option<bool>, | ||
pub pcc: Option<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.
I should highlight this as a drive-by change by me (cc @cfallin), but this'll rename -C enable-pcc
to -C pcc
(most other options omit the "enable" or "disable" to have everything be "if you specify it it's enabled unless you say =n
in which case you're asking to disable it")
Subscribe to Label Actioncc @peterhuene
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:c-api", "wasmtime:config", "wasmtime:docs"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
To modify this label's message, edit the To add new label messages or remove existing label messages, edit 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.
Nice work documenting the pruning! I've always sort of wondered what the minimum size would be.
Enable this Cargo feature by default, but enable building the CLI without the `explore` subcommand.
This was already conditional in crates such as `wasmtime` and this makes it an optional dependency of the CLI as well.
Additionally refactor `wasmtime-cli-flags` to not unconditionally pull in caching support by removing its `default` feature and appropriately enabling it from the CLI.
72176f7
to
d440ff2
Compare
This commit updates the binary artifacts produced by CI to include "min" builds where all default features are disabled. Additionally all the stops are pulled in terms of build flags, nightly versions, etc, to get a build that is as small as possible without actual source code changes. This effectively codifies the instructions in bytecodealliance#7282 into an easily downloadable artifact. No new tarballs are created for github releases but instead tarballs that previously had a `wasmtime` executable for example now have a `wasmtime-min` executable. Furthermore the C API which previously had `libwasmtime.so` for example now has `libwasmtime-min.so`. The intention is that the minimum-size artifacts are handy for determining a rough size of Wasmtime but they're not so important that it seems worthwhile to dedicate entire release entries for. CI is refactored to support these minimum builds with separate builders. This means that a single tarball produced as a final result is actually two separate tarballs merged together, one for the normal build we do today plus a new "min" tarball produced on the new "min" builders. Various scripts and CI organization has been adjusted accordingly. While here I went ahead and enabled `panic=abort` and debuginfo stripping in our current release artifacts. While this doesn't affect a whole lot it's less to upload to GitHub Actions all the time.
* riscv64: Extend distance trampolines can jump Use a PIC-friendly set of instructions to enable destination of the trampoline to be more than 4k away from the tail call site of the trampoline itself. * Build "min" artifacts on CI This commit updates the binary artifacts produced by CI to include "min" builds where all default features are disabled. Additionally all the stops are pulled in terms of build flags, nightly versions, etc, to get a build that is as small as possible without actual source code changes. This effectively codifies the instructions in #7282 into an easily downloadable artifact. No new tarballs are created for github releases but instead tarballs that previously had a `wasmtime` executable for example now have a `wasmtime-min` executable. Furthermore the C API which previously had `libwasmtime.so` for example now has `libwasmtime-min.so`. The intention is that the minimum-size artifacts are handy for determining a rough size of Wasmtime but they're not so important that it seems worthwhile to dedicate entire release entries for. CI is refactored to support these minimum builds with separate builders. This means that a single tarball produced as a final result is actually two separate tarballs merged together, one for the normal build we do today plus a new "min" tarball produced on the new "min" builders. Various scripts and CI organization has been adjusted accordingly. While here I went ahead and enabled `panic=abort` and debuginfo stripping in our current release artifacts. While this doesn't affect a whole lot it's less to upload to GitHub Actions all the time. * Fix Windows unzip
This merged While I'm not against the existence of a new |
Ah I merged those since they were both on-by-default and there didn't at the time appear to be much benefit to sharding further. Out of curiosity is this something where you're concerned about binary size of the ittapi dependency? Or is it otherwise not building for you for one reason or another? One reason I unified them was I also placed the guest profiler behind the same |
As someone who refers to an upstream which disables default features, then re-enables features as needed, this did introduce the ittapi dependency for me as I updated it in my downstream. To be clear, I agree with that policy. I don't personally care about ittapi's effect on binary size. I care about the fact I now have ittapi in scope and will have to, eventually, read through and audit ittapi to ensure it's non-malicious (or import the Bytecode Alliance's vet statement for it, which I can assume exists). While I can recognize the library is hosted and maintained by Intel, the actual publishers of the crate are three individuals, any of who could be compromised. TL;DR It increases my supply chain and complicates the package graph for no benefit to me, making this a downgrade in wasmtime's utility. Again. I don't mind the profiling feature. I just wish I could still access the original jitdump feature. Accordingly, I believe this can be implemented without hurting the performance/effects/code-gen of the profiling feature. |
That makes sense yeah, thanks for explaining! If it's ok with you I'd prefer to stay the current course, however. Wasmtime doesn't guarantee that we won't add new dependencies with new version of Wasmtime even with default features disabled. That being said we do guarantee that all dependencies used by Wasmtime have a vetted version by BA maintainers. Otherwise I'd personally prefer to avoid sharding the |
I fully understand dependencies may increase. That does not affect my commentary on needless dependencies having increased. As for staying the course, I can respect your preference of simplicity. If in the future, you change your mind and would accept a PR re-defining profiling as a superset of both features, please let me know. |
This PR is borne out of discussions from last week's CG meetings about the suitability of Wasmtime in embedded scenarios. One of the primary concerns that arose was the binary size of the Wasmtime engine being too large for these scenarios. In my experience binary size is one aspect of Rust where it doesn't come for free so this aligns with my expectations. That being said I've yet to see a case in Rust where a particular binary footprint couldn't be achieved, hence this PR.
One thing I've noticed is that many folks evaluating Wasmtime seem to look at the size of the
wasmtime
executable itself when performing size comparisons. While this likely doesn't reflect the true size of what a custom embedding would be it's nevertheless an easy comparison that can be made. To that effect I've added a number of Cargo features to thewasmtime-cli
crate to disable functionality up to and includingwasmtime compile
for example. This PR enables building awasmtime
exectuable that is stripped down to the bare bones - all it can do is run precompiled WebAssembly files. That being said it should still be a full-featured runtime at this time where only some optional features such as DWARF processing foraddr2line
are disabled.Additionally in this PR I've added a new chapter to the Wasmtime book about building a minimal build of Wasmtime. This explains not only the existence of the
--no-default-features
build flag but additionally the consequences in terms of functionality and binary size. Furthermore this section additionally directly expands on tips and tricks for building a minimal binary using various Rust compiler flags and nightly features. This section shows how thewasmtime
CLI is 130M in debug mode and the smallest build producable after this PR is 2.1M.The goal of this PR is to get the ball rolling on size-related optimizations, not necessarily be the end-all-be-all. Further optimizations to binary size will likely require more invasive changes about how we develop Wasmtime or similar. For example we may have to lose the relatively rich error information Wasmtime currently has to get the next level of significant win. That being said I'm at least personally lacking a bit in direction for where to go next to optimize. My hope is that by showcasing a much smaller
wasmtime
CLI executable it shows to folks that Wasmtime for these use cases is viable, even if it's not suitable just yet. For example the CLI uses crates such asclap
which won't be present in custom embeddings. Having an actual custom embedding to optimize for will be useful. In lieu of this I plan on continuing to poke to see what we can do.One option as a result of this PR is to build a
wasmtime-lite
executable on CI and upload it to GitHub Actions/Releases as well. I'm not totally convinced that'd be too useful so I haven't done that. Another option though is to add a CI builder which builds a minimal binary and verifies that it doesn't go above a particular threshold to catch regressions in binary size (e.g. if a new feature is added ensure that it can be disabled with--no-default-features
). I've left this for a future PR as well.I should also note that my hope is that when optimizing for binary size it would not hinder the development of Wasmtime anywhere else. In that sense it should ideally be easy for anyone to understand how the conditionally compiled code works and it shouldn't appear as a maze of cfgs to wade through to get things working. While it's definitely more
#[cfg]
than before, I'm particularly interested if folks feel this is too onerous to maintain or burdensome. If so I'd be interested in improving how this is all designed.