-
Notifications
You must be signed in to change notification settings - Fork 245
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
wasmparser
: Should we put 128-bit SIMD behind a crate feature?
#1899
Comments
One point perhaps worth clarifying is that the This is a bit different for core wasm proposals because everything is pervasively present throughout the wasm type system and structures exposed by this crate. For example the One possible option perhaps is something like: trait Visitor {
fn simd_visitor(&mut self) -> Option<&mut dyn SimdVisitor> { None }
}
trait SimdVisitor {
// ... all simd methods
} for the trait side of things and maybe Overall though I'd think the high-order bit here is the runtime performance. Compile time and binary size are nice but IMO runtime performance is the most important. Do you perhaps have a benchmark showing that if wasmparser (probably locally edited) removes simd support that it's measurably faster? If so that'd make this more urgent I think but I'd also naively think that removing simd wouldn't have much of a performance impact. The gc proposal is different in that it affects the type system, but I think we can improve perf there without going the route of compile time features perhaps. |
Another option perhaps is to more radically redesign things. Right now Brainstorming more yet-another possible option here could be controlling defaults for wasm features via Cargo features. Right now if you disable the |
@alexcrichton thank you for the fast response! To be honest, I am mostly interested in compilation and artifact size improvements since I too doubt that this would improve runtime performance significantly. But if runtime performance is the main motivator for this PR from the viewpoint of BytecodeAlliance maintainers a performance analysis should be done. I think that mostly the parsing and validation logic for all these numerous SIMD operators could be a huge relieve on the Rust compiler and for artifact sizes. You are right that this change is probably more intrusive than the The idea about the Outsourcing all SIMD operators into their own Maybe, if we combine the |
Ah ok makes sense! Sorry I don't mean to belittle compile-time or binary size improvements at all. I personally prioritize runtime which is why I originally focused on that, but I agree it's important to focus on the other bits too! Would you be interested in deleting all the simd bits and seeing if it has a measurable difference on compile-time or binary size? I think it could help in both situations but probably in the single-digit-percentage range would be my prediction. I do agree that |
Thank you for your understanding. Yes, I will remove all SIMD related code as a test and update you here about the changes in compile time, runtime and artifact size. Best outcome is if nothing changes, so there was nothing to do. :) |
@alexcrichton I conducted the experiment here: https://github.com/Robbepop/wasm-tools/tree/rf-remove-simd-related-code Feel free to check if I correctly stripped all the SIMD related code. Results (MacBook M2 Pro)Default Featurescargo clean && time cargo build -p wasmparser
Embedded Featurescargo clean && time cargo build -p wasmparser --no-default-features --features std,validate,features
ConclusionFewer improvements than I hoped, but still significant. Compile times decreased by roughly 10-15%. Profiles Used[profile.production]
inherits = "release"
lto = "fat"
codegen-units = 1
[profile.production-z]
inherits = "release"
opt-level = "z"
codegen-units = 1 |
Wow yeah that's a pretty hefty chunk and honestly pretty surprising to me. I'd expect a much smaller impact and those seem definitely worth it time/space-wise. That's compelling enough to me that I think it'd be worth exploring this more and seeing how it pans out, would you be interested in doing so? |
Okay this sounds motivating. Yes, I will work on this. |
With the recent movement to put some major Wasm proposals behind crate features, e.g.
component-model
andgc
, I was wondering if this was also practical or useful for the very large 128-bitsimd
(and thus alsorelaxed-simd
) proposal with its tons of op-codes. (simd
: 235,flexible-simd
: 19)I see plenty of Wasm runtimes not (yet) supporting
simd
and it isn't even clear to me whethersimd
is supposed to become an optional component of Wasm in the future due to its massive size and the outlook of the more elaborateflexbile-vectors
on the (far) horizont. For Wasmi I am starting to lean towards supporting Wasmsimd
proposal soonish but behind a crate feature that is disabled by default since it is just way too massive.The hope is that putting the
simd
andflexible-simd
feature behind a singlesimd
crate feature forwasmparser
would improve compile times, artifact sizes and maybe (or hopefully) also parse and validation performance since certain checks can be performed at compile time instead.Ideas, thoughts and discussion welcome. :)
The text was updated successfully, but these errors were encountered: