Skip to content

v1.0.2

Compare
Choose a tag to compare
@github-actions github-actions released this 18 Apr 20:46
· 774 commits to main since this release
ea33606

wazero 1.0.2 improves compiler performance, supports non-blocking stdin and adds a couple new experimental APIs.

Many people were involved in a lot of work in the last 3 weeks. Please reach out and thank them!

Improved compiler performance

wazero has a compile phase (CompileModule) which lowers WebAssembly bytecode into an intermediate representation (IR) and into machine code. This process is CPU and memory intensive and has been optimized significantly since 1.0.1.

We used SQLite wasm, to ensure the encouraging improvements were relevant to real-world use cases.

goos: linux
goarch: amd64
pkg: github.com/tetratelabs/wazero/internal/integration_test/bench
cpu: AMD Ryzen 9 3950X 16-Core Processor
                                       │  v1.0.1.txt   │              new.txt               │
                                       │    sec/op     │   sec/op     vs base               │
Compilation_sqlite3/compiler-32          1001.9m ±  2%   544.0m ± 2%  -45.70% (p=0.001 n=7)
Compilation_sqlite3/interpreter-32       208.57m ±  5%   83.81m ± 5%  -59.82% (p=0.001 n=7)

                                       │  v1.0.1.txt   │               new.txt               │
                                       │     B/op      │     B/op      vs base               │
Compilation_sqlite3/compiler-32          305.10Mi ± 0%   55.31Mi ± 0%  -81.87% (p=0.001 n=7)
Compilation_sqlite3/interpreter-32       142.24Mi ± 0%   51.77Mi ± 0%  -63.60% (p=0.001 n=7)

                                       │  v1.0.1.txt   │              new.txt               │
                                       │   allocs/op   │  allocs/op   vs base               │
Compilation_sqlite3/compiler-32           5217.0k ± 0%   343.2k ± 0%  -93.42% (p=0.001 n=7)
Compilation_sqlite3/interpreter-32       1770.43k ± 0%   14.00k ± 0%  -99.21% (p=0.001 n=7)

The changes to bring the above included a series of refactoring by @evacchi on union types, as well dozens of optimizations by @mathetake, and a couple by @ckaznocha.

All of this was easier due to frequent and thorough advice by @achille-roussel and our latest core maintainer @ncruces. Thanks to all involved for the epic improvement in less than 3 weeks!

Non-blocking stdin

container2wasm is an interesting project that converts containers such that they can run in a webassembly runtime, such as a browser or wazero.

One feature this relies on is non-blocking access to STDIN. Like some other runtimes, wazero didn't handle this properly.

Thanks to a lot of effort by @evacchi with advice from @achille-roussel and support from the container2wasm author @ktock, wazero now handles non-blocking STDIN properly (via the select syscall).

Experimental changes

Code in our "experimental" directory isn't under an API guarantee, so can change even in a patch version. Here are a couple new experiments since last release.

  • @pelletier added a StackIterator parameter to listeners, allowing inspection of the stack leading to a function call. Thanks to @Pryz for the initial design and background, as this is used for CPU profiling data.
  • @codefromthecrypt added emscripten.InstantiateForModule to dynamically build function imports given a CompiledModule. Thanks to @jerbob92 for the idea and testing with various PDF tools.

Fixes and behavior changes

1.0.2 includes some bug fixes..

It also includes a couple behavior changes..

  • @abraithwaite made it possible to use errors.Is for context-done related error cases.
  • @codefromthecrypt made host functions retain insertion order (instead of lexicographic).