wasmi-labs / wasmi

WebAssembly (Wasm) interpreter.
https://wasmi-labs.github.io/wasmi/
Apache License 2.0
1.52k stars 274 forks source link

Add non-streaming Wasm module creation #1035

Closed Robbepop closed 1 month ago

Robbepop commented 1 month ago

So far Wasmi only supported streaming parsing, validation and compilation of Wasm modules via Module::new.

This PR renames both Module::new and Module::new_unchecked to new_streaming and new_streaming_unchecked respectively. Also it adds 2 new methods Module::new and Module::new_unchecked that take a wasm: &[u8] byte slice argument instead of a stream: impl Read argument. The idea behind this change is that if streaming compilation is not necessary we can optimize the process.

Benchmarks

The benchmarks locally show amazing performance wins across the board. For lazy and especially lazy-unchecked compilation I consistently saw improvements between 40-80% (5x speed-up).

image

image

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 81.86275% with 37 lines in your changes are missing coverage. Please review.

Project coverage is 80.86%. Comparing base (3880d86) to head (4c66abc). Report is 1 commits behind head on master.

Files Patch % Lines
crates/wasmi/src/module/parser/streaming.rs 84.15% 16 Missing :warning:
crates/wasmi/src/module/parser/buffered.rs 82.43% 13 Missing :warning:
crates/wasmi/src/module/mod.rs 40.00% 6 Missing :warning:
crates/cli/src/context.rs 0.00% 1 Missing :warning:
crates/wasmi/src/module/parser.rs 80.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1035 +/- ## ========================================== + Coverage 80.82% 80.86% +0.03% ========================================== Files 269 271 +2 Lines 24825 24896 +71 ========================================== + Hits 20065 20132 +67 - Misses 4760 4764 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.