chenhengqi / WasmEdge

WasmEdge Runtime is a high-performance, extensible, and hardware optimized WebAssembly Virtual Machine for automotive, cloud, AI, and blockchain applications.

Home Page:https://WasmEdge.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quick start guides

🤖 Build and contribute to WasmEdge
⌨️ Run a standalone Wasm program from CLI or Node.js or Golang
💭 Deploy a Wasm function as a web service (FaaS)
🛠 Embed a user-defined Wasm function in a SaaS platform
🔩 Embed a Wasm function in your Node.js web app
🔌 Embed a Wasm function in your Golang app
🔗 Deploy a Wasm function as a blockchain smart contract

build Total alerts Language grade: C/C++ codecov FOSSA Status

Introduction

WasmEdge (previously known as SSVM) is a high-performance WebAssembly (Wasm) VM optimized for Edge Computing, including Edge Clouds and Software Defined Vehicles. In its AOT mode, WasmEdge is the fastest Wasm VM on the market today.

WasmEdge is an official sandbox project hosted by CNCF (Cloud Native Computing Foundation).

The most important use case for WasmEdge is to safely execute user-defined or community-contributed code as plug-ins in a software product (e.g., a SaaS, a car OS, an edge node, or even a blockchain node). It enables third-party developers, vendors, suppliers, and community members to extend and customize the software product. With WasmEdge, a software product could become a host platform.

WasmEdge provides a well-defined execution sandbox for its contained Wasm bytecode program. The bytecode program cannot access operating system resources (e.g., file system, sockets, environment variables, processes) without explicit permissions from the VM's runner. The runner specifies the system resources the VM can access in the VM's configuration options upon starting up (a.k.a capability-based security model).

WasmEdge also provides memory protection for its contained bytecode program. If the program attempts to access memory outside of the region allocated to the VM, the VM will terminate with an error message.

WasmEdge and its contained wasm program can be started from the CLI as a new process, or from a existing process. If started from an existing process (e.g., from a running Node.js or Golang program), the VM will simply run inside the process as a function. It is also possible to start a WasmEdge VM instance as a thread. Currently, WasmEdge is not yet thread-safe, meaning that VM instances running in different threads in the same process will potentially be able to access each other's memory. In the future, we plan to make WasmEdge thread safe.

Embed WasmEdge into a host application

A major use case of WasmEdge is to start an VM instance from a host application. In general, you can use the WasmEdge C API to do so.

However, the Wasm spec, and the WasmEdge C API, only supports very limited data types as input parameters and return values for the contained Wasm bytecode functions. In order to pass complex data types, such as a string of an array, as call arguments into the contained function, you should use the bindgen solution provided by the rustwasmc toolchain.

We currently supports bindgen in the Node.js host environment. We are working on bindgen support in Golang and Rust-based host applications.

Call native host functions from WasmEdge

Sometimes, the Wasm bytecode alone could prove too limiting for some applications. WasmEdge provides a host function API that allows Wasm bytecode programs to load and call native library functions from the underlying host operating system.

The host functions break the Wasm sandbox. But the sandbox breaking is done with explicit permission from the system’s operator.

In fact, the extensions to WasmEdge are implemented using native host functions. For example, the Tensorflow extension allows Wasm bytecode to make calls to the native Tensorflow library functions.

Manage WasmEdge VM instances

With the WasmEdge C API, you can write a program to start, stop, and manage WasmEdge VM instances in your own applications. For example,

  • When WasmEdge functions are embedded in Node.js or in the Feishu messenger, the VM is launched by the application when there is an incoming request.
  • When WasmEdge functions are plugged into a data flow engine like YoMo, the VM is launched when a new data point flows through the system.

If you are interested in using Kubernetes to manage WasmEdge VMs, you can install our custom runw utilities. They could load Wasm bytecode program files as if they are Docker images, and then start, run, and stop the VM instances based on configured policies.

Support wasm standard extensions

WasmEdge supports optional WebAssembly features and proposals. Those proposals are likely to become official WebAssembly specifications in the future. WasmEdge supports the following proposals.

  • WASI (WebAssembly Systems Interface) spec. WasmEdge has supported the WASI spec for WebAssembly programs to interact with the host Linux operating system securely.
  • Reference Types. It allows WebAssembly programs to exchange data with host applications and operating systems.
  • Bulk memory operations. The WebAssembly program sees faster memory access and performs better with bulk memory operations.
  • SIMD (Single instruction, multiple data). For modern devices with multiple CPU cores, the SIMD allows data processing programs to take advantage of the CPUs fully. SIMD could significantly enhance the performance of data applications.

Meanwhile, the WasmEdge team is exploring the wasi-socket proposal to support network access in WebAssembly programs.

WasmEdge extensions

A key differentiator of WasmEdge from other WebAssembly VMs is its support for non-standard extensions. The WASI spec provides a mechanism for developers to extend WebAssembly VMs efficiently and securely. The WasmEdge team created the following WASI-like extensions based on real-world customer demands.

  • Tensorflow. Developers can write Tensorflow inference functions using a simple Rust API, and then run the function securely and at native speed inside WasmEdge.
  • Other AI frameworks. Besides Tensorflow, the Second State team is building WASI-like extensions for AI frameworks such as ONNX and Tengine for WasmEdge.
  • Storage. The WasmEdge storage interface allows WebAssembly programs to read and write a key value store.
  • Command interface. WasmEdge enables webassembly functions execute native commands in the host operating system. It supports passing arguments, environment variables, STDIN / STDOUT pipes, and security policies for host access.
  • Ethereum. The WasmEdge Ewasm extension supports Ethereum smart contracts compiled to WebAssembly. It is a leading implementation for Ethereum flavored WebAssembly (Ewasm).
  • Substrate. The Pallet allows WasmEdge to act as an Ethereum smart contract execution engine on any Substrate based blockchains.

Use cases

WasmEdge enables software products to be extended and customized by their users. With WasmEdge, any software product can build a developer ecosystem. Here are some specific use cases from our customers and partners.

Community

Contributing

If you would like to contribute to the WasmEdge project, please refer to our CONTRIBUTION document for details. If you are looking for ideas, checkout our wish list!

Contact

If you have any questions, feel free to open a GitHub issue on a related project or to join the following channels:

License

FOSSA Status

About

WasmEdge Runtime is a high-performance, extensible, and hardware optimized WebAssembly Virtual Machine for automotive, cloud, AI, and blockchain applications.

https://WasmEdge.org

License:Apache License 2.0


Languages

Language:C++ 70.1%Language:WebAssembly 27.2%Language:CMake 1.6%Language:Rust 0.6%Language:C 0.4%Language:Shell 0.1%