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

Introduces the new optimizing compiler (wazevo) in experimental pkg #1869

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

mathetake
Copy link
Member

@mathetake mathetake commented Dec 13, 2023

This finally closes #1496 which aims to introduce an optimizing compiler in wazero as
an alternative backend for the current single pass compiler.
Even though this is released under experimental, it already has been well-tested with
long-running fuzzing, Zig/TinyGo standard library tests etc.
It's only available yet on arm64, but we will soon start working on amd64 as well led by @evacchi.

The optimizing compiler is written entirely from scratch, and the initial result is pretty amazing.
The rough numbers on the performance aspect is like 2x faster on compilation and
3x faster on runtime compared to the existing single passs compiler when running
Zig's standard library tests which is a huge Wasm binary with all tests.
This is a huge win given that this new back end, even though it is "optimizing", but the implementation
is pretty naive currently, and there's huge room for improvements (we welcome contributions!).

Once amd64 is implemented and it's been adopted by communities, then this will be the default
compiler and we will delete the existing single pass is the plan for now.

You can enable the optimizing compiler by replacing wazero.NewRuntimeConfigCompiler() or wazero.NewRuntimeConfig() with the new API like

-       c := wazero.NewRuntimeConfigCompiler()
+       c := opt.NewRuntimeConfigOptimizingCompiler()
-       c := wazero.NewRuntimeConfig()
+       c := opt.NewRuntimeConfigOptimizingCompiler()

In CLI, you can use -optimizing-compiler flag to enable it:

wazero run -optimizing-compiler myapp.wasm

Thank you for all your support!

@mathetake mathetake marked this pull request as ready for review December 13, 2023 18:00
Copy link
Collaborator

@ncruces ncruces left a comment

Choose a reason for hiding this comment

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

Ran tests on QEMU and real hardware, all green!

@mathetake mathetake merged commit 87a48d8 into main Dec 14, 2023
52 checks passed
@mathetake mathetake deleted the expwazevo branch December 14, 2023 16:27
gaukas pushed a commit to refraction-networking/wazero that referenced this pull request Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement initial optimizing compiler backend: project wazevo
2 participants