Skip to content

wasmedge: add support for WasmEdge engine. #193

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

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

q82419
Copy link
Contributor

@q82419 q82419 commented Sep 7, 2021

Hi,

Here's the maintainer of the WasmEdge runtime.
This pull request implements the WasmEdge supporting for the proxy-wasm with the newest WasmEdge release version (0.8.2).
For this first version, we provides the interpreter mode of WASM runtime, and the AOT mode supporting for proxy-wasm is still work in progress.
Please feel free to review this pull request and give us some advices if there's issues, bugs, or incomplete implementations.
Thank you.

Resolves #97

@google-cla

This comment has been minimized.

@q82419

This comment has been minimized.

Copy link
Contributor

@mathetake mathetake left a comment

Choose a reason for hiding this comment

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

Thank you for submitting this!

@q82419
Copy link
Contributor Author

q82419 commented Sep 7, 2021

Please help to link with the issue 97, thanks.

@mathetake
Copy link
Contributor

Please help to link with the issue 97, thanks.

you can do that by putting the comment in the description like resolves #97:) (See https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)

@q82419 q82419 force-pushed the runtime/WasmEdge branch 2 times, most recently from a0cc723 to 05b0cf2 Compare September 14, 2021 05:36
@q82419 q82419 requested a review from PiotrSikora September 14, 2021 05:38
@PiotrSikora
Copy link
Member

@q82419 this is still failing to build.

@q82419
Copy link
Contributor Author

q82419 commented Sep 17, 2021

Hi @PiotrSikora ,
We've clear the boost issue, but still have trouble at handling the spdlog dependency.
Do you have suggestions for adding the spdlog dependency with bazel for the find_package in cmake?
How do I copy or symbolic link the whole spdlog dependency archive when building the wasmedge target?
Thanks.

@q82419
Copy link
Contributor Author

q82419 commented Sep 22, 2021

Hi @PiotrSikora ,

We choose to use our pre-built shared library instead. Thanks.

@PiotrSikora
Copy link
Member

Hi @PiotrSikora ,

We choose to use our pre-built shared library instead. Thanks.

Hi @q82419, unfortunately, this isn't acceptable solution. Proxy-Wasm C++ Host is used in products where supply chain security is a big concern, so we cannot rely on prebuilt artifacts from untrusted sources. We need to figure out a way to build Boost / WasmEdge from sources in Bazel.

@q82419
Copy link
Contributor Author

q82419 commented Oct 27, 2021

Hi @q82419, unfortunately, this isn't acceptable solution. Proxy-Wasm C++ Host is used in products where supply chain security is a big concern, so we cannot rely on prebuilt artifacts from untrusted sources. We need to figure out a way to build Boost / WasmEdge from sources in Bazel.

Hi @PiotrSikora ,

Thanks for the feedback.
We're now preparing for the 0.9.0 release now, and will update the PR to resolve this. Thanks.

@q82419 q82419 marked this pull request as draft December 27, 2021 09:41
@q82419 q82419 marked this pull request as ready for review January 3, 2022 23:07
@q82419
Copy link
Contributor Author

q82419 commented Jan 3, 2022

Hi @PiotrSikora ,

We've updated the WasmEdge runtime to 0.9.0 and resolved the mentioned issues.
For the cloneability and the compiled sections, we'll work for supporting in the future.
Please let us know if there's any issue. Thanks.

@PiotrSikora
Copy link
Member

For the cloneability and the compiled sections, we'll work for supporting in the future.

That's fine, thanks!

build_file = "@proxy_wasm_cpp_host//bazel/external:wasmedge.BUILD",
sha256 = "e7c86b397aa2d5e712cd06af9fe1ed5604fe7d1d6dedbc6d62c846dd0131953d",
strip_prefix = "WasmEdge-f34286ea920eefa9884ee31f7c509aa8bd99aec3",
url = "https://github.com/WasmEdge/WasmEdge/archive/f34286ea920eefa9884ee31f7c509aa8bd99aec3.tar.gz",
Copy link
Member

Choose a reason for hiding this comment

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

It looks this is a custom branch that bundles boost and spdlog, which means that updating this runtime without your help might be tricky in the future. What's the plan for those commits? Do you intend to merge them into master branch or is the plan to keep them forever in a development branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll keep the branch, and merge the master into that branch for each official release.
For the 0.9.0 release, we pushed the proxy-wasm/0.9.0 tag and use the tag in this PR.

@q82419 q82419 requested a review from PiotrSikora January 17, 2022 05:38
Copy link
Member

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

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

Apologies for the delay, I had to cleanup our CI before accepting new engines, otherwise we'd be evicting cache on each PR run. We should be good to go now, so could you merge master and resolve the conflicts? Thanks!

Also, could you explain what's the advantage of WasmEdge over the existing engines that we support? Currently, we have V8 (fast JIT), Wasm Micro Runtime (fast interpreter), Wasmtime (Cranelift), WAVM (LLVM JIT/AOT), and it's unclear what use case does WasmEdge address, and why users should select WasmEdge over any of the existing eninges.

@q82419
Copy link
Contributor Author

q82419 commented Feb 17, 2022

Apologies for the delay, I had to cleanup our CI before accepting new engines, otherwise we'd be evicting cache on each PR run. We should be good to go now, so could you merge master and resolve the conflicts? Thanks!

Also, could you explain what's the advantage of WasmEdge over the existing engines that we support? Currently, we have V8 (fast JIT), Wasm Micro Runtime (fast interpreter), Wasmtime (Cranelift), WAVM (LLVM JIT/AOT), and it's unclear what use case does WasmEdge address, and why users should select WasmEdge over any of the existing eninges.

Hi @PiotrSikora ,

WasmEdge has the following advantages over all Wasm runtimes, including V8:

  1. WasmEdge supports some non-standard but necessary extensions for cloud-native environments. For example, it supports non-blocking network sockets, WasmEdge-bindgen for complex para passing, and Tensorflow / AI inference. They may not be important for a proxy embedded runtime right now, but they could expand the types of applications your developers might want to try.
  2. In a service mesh environment, the developer might want to use Wasm in both the proxy and the microservice. WasmEdge is the runtime that provides the best integration with various k8s distributions. In fact, WasmEdge is itself an OCI container that can be managed by container tools- neither node nor other wasm runtime is a container.
  3. Through the AOT compiler, WasmEdge is one of the fastest WebAssembly runtimes on the market.
  4. WasmEdge provides excellent support for JavaScript, including ES6 and NPM modules, async networking, the fetch API, React SSR, and even mixing Rust code with JS code.
  5. WasmEdge is written in C++, and hence has better (in our view) support for different OSes and language SDKs.
  6. It is often a good idea to support multiple runtimes because each project might have different roadmaps, adoption, and community. For example, WasmEdge is a CNCF project working with a lot of cloud-native projects. Other Wasm runtimes might be focused on the browser or IoT devices.

Copy link
Member

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

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

WasmEdge has the following advantages over all Wasm runtimes, including V8:

  1. WasmEdge supports some non-standard but necessary extensions for cloud-native environments. For example, it supports non-blocking network sockets, WasmEdge-bindgen for complex para passing, and Tensorflow / AI inference. They may not be important for a proxy embedded runtime right now, but they could expand the types of applications your developers might want to try.
  2. In a service mesh environment, the developer might want to use Wasm in both the proxy and the microservice. WasmEdge is the runtime that provides the best integration with various k8s distributions. In fact, WasmEdge is itself an OCI container that can be managed by container tools- neither node nor other wasm runtime is a container.
  3. WasmEdge provides excellent support for JavaScript, including ES6 and NPM modules, async networking, the fetch API, React SSR, and even mixing Rust code with JS code.

None of that matters when embedding WasmEdge's engine part (without extra runtime APIs) into Proxy-Wasm.

  1. Through the AOT compiler, WasmEdge is one of the fastest WebAssembly runtimes on the market.

Do you have any data behind this (compared to V8, WAMR, Wasmtime, WAVM, etc.)?

  1. WasmEdge is written in C++, and hence has better (in our view) support for different OSes and language SDKs.

I'd argue that C, C++, and Rust all have pretty good support, so this isn't a differentiator.

  1. It is often a good idea to support multiple runtimes because each project might have different roadmaps, adoption, and community. For example, WasmEdge is a CNCF project working with a lot of cloud-native projects. Other Wasm runtimes might be focused on the browser or IoT devices.

That's definitely true, and I'm greateful for you working on adding WasmEdge to Proxy-Wasm.

However, I still don't know when I should recommend WasmEgde over V8/WAMR/Wasmtime/WAVM to Proxy-Wasm users? What's the benefit?

@juntao
Copy link

juntao commented Feb 25, 2022

Hi, This is Michael Yuan from WasmEdge. :)

For the points 1 and 2 below: I think the bigger picture is that people are increasingly using WebAssembly as a runtime for microservices themselves, in addition to the data plane. It simplifies development and deployment if the entire system uses the same WebAssembly runtime with the same extensions, SDKs, and toolings. On this front, WasmEdge with its support for async networking sockets, cryptography, and Kubernetes, is a compelling choice of WebAssembly across the proxies and the microservices.

For point 3, please see WasmEdge performance benchmarks: https://github.com/WasmEdge/WasmEdge/blob/master/README.md#performance

For point 4, wouldn't it be nice to program traffic rules using JavaScript? ;)

Cheers!
Michael

WasmEdge has the following advantages over all Wasm runtimes, including V8:

  1. WasmEdge supports some non-standard but necessary extensions for cloud-native environments. For example, it supports non-blocking network sockets, WasmEdge-bindgen for complex para passing, and Tensorflow / AI inference. They may not be important for a proxy embedded runtime right now, but they could expand the types of applications your developers might want to try.
  1. In a service mesh environment, the developer might want to use Wasm in both the proxy and the microservice. WasmEdge is the runtime that provides the best integration with various k8s distributions. In fact, WasmEdge is itself an OCI container that can be managed by container tools- neither node nor other wasm runtime is a container.
  1. WasmEdge provides excellent support for JavaScript, including ES6 and NPM modules, async networking, the fetch API, React SSR, and even mixing Rust code with JS code.

None of that matters when embedding WasmEdge's engine part (without extra runtime APIs) into Proxy-Wasm.

  1. Through the AOT compiler, WasmEdge is one of the fastest WebAssembly runtimes on the market.

Do you have any data behind this (compared to V8, WAMR, Wasmtime, WAVM, etc.)?

  1. WasmEdge is written in C++, and hence has better (in our view) support for different OSes and language SDKs.

I'd argue that C, C++, and Rust all have pretty good support, so this isn't a differentiator.

  1. It is often a good idea to support multiple runtimes because each project might have different roadmaps, adoption, and community. For example, WasmEdge is a CNCF project working with a lot of cloud-native projects. Other Wasm runtimes might be focused on the browser or IoT devices.

That's definitely true, and I'm greateful for you working on adding WasmEdge to Proxy-Wasm.

However, I still don't know when I should recommend WasmEgde over V8/WAMR/Wasmtime/WAVM to Proxy-Wasm users? What's the benefit?

@q82419 q82419 force-pushed the runtime/WasmEdge branch from d7144f6 to 2e72747 Compare March 3, 2022 05:22
@q82419 q82419 force-pushed the runtime/WasmEdge branch from 2e72747 to 9bb9eef Compare March 16, 2022 05:36
Copy link
Member

@PiotrSikora PiotrSikora left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@PiotrSikora PiotrSikora changed the title Add the WasmEdge runtime supporting. wasmedge: add support for WasmEdge engine. Apr 7, 2022
@PiotrSikora PiotrSikora merged commit eba773f into proxy-wasm:master Apr 7, 2022
@q82419 q82419 deleted the runtime/WasmEdge branch June 9, 2022 06:28
knm3000 pushed a commit to knm3000/proxy-wasm-cpp-host that referenced this pull request Aug 17, 2022
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.

Add WasmEdge runtime
4 participants