Blog

Home / Blog

Wasmer 3.0 features a redesigned API and enhanced memory management

Billy Yann
Data Scientist
Deep learning and machine learning specialist, well-versed with experience in Cloud infrastructure, Block-chain technologies, and Big Data solutions.
December 19, 2022


Wasmer is one of several initiatives promoting WebAssembly on the desktop and supports multiple operating systems. The primary format for executing intelligent contracts is WebAssembly, and Wasmer is preferred for blockchain and cryptocurrency providers as the WebAssembly runtime. Wasmer 3.0, the newest feature release for this open-source program seeking to serve as a universal WebAssembly runtime for "running any code on any client," was formally published this weekend.

Wasmer 3.0 includes a new WASIX implementation with full networking functionality, a new context API, corrections to its Single-pass compiler, RISC-V compatibility, C API updates, and numerous other enhancements. Wasmer can now be compiled as native executables for Windows, Linux, and Mac with no runtime dependencies. The new release also includes the capability to operate WAPM (WebAssembly Package Manager) packages directly with "Wasmer run," a newly rebuilt Rust API, and foster more excellent for WASI (WebAssembly System Interface), which helps to add file I/O and other features to WebAssembly for running outside the browser, according to founder Syrus Akbary.

WebAssembly was initially intended to run code written in other languages, such as C/C++, within a web browser in a safe and near-native manner. JavaScript runtimes are now frequently utilized on the server, such as in Edge functions or Cloudflare workers, and Wasm fits in perfectly. Wasmer is an alternative to existing cross-platform runtimes, such as Java, for running Wasm outside of browser contexts.

Wasmer bills itself as "a fast and secure WebAssembly runtime that allows very lightweight containers to run anywhere: from the desktop to the cloud, edge, and IoT devices" on GitHub. According to Akbary's post from August this year, the create-exe Wasmer program combines Wasm with some glue code, and then "we use a C compiler/linker file to connect everything." The result is a standalone executable, a "fully sandboxed binary with low runtime overhead."

Languages such as Rust, Go, C/C++, and C#, which Akbary lists as suited for create-exe, can also be compiled to run on these same systems, possibly with superior performance. So, what advantage does Wasmer bring? According to Akbary, automatic support for new chipsets is advantageous since "we don't have to worry about recompiling our program when new processors and operating systems arise." He also mentioned the Wasmer sandbox as a benefit.

Despite these statements, others in the community are skeptical. One issue is performance versus native code. "In general, I've found it to be 2-3x slower, at least for my use cases," a developer commented on Hacker News. Others are more upbeat. The ability to call libraries built in one language from an application developed in another is appealing. "People frequently choose languages based on the availability of libraries published in those languages." "The purpose of non-browser WASM is to eliminate it and reduce the friction of inter-language communication," explained another developer.

The most appealing aspect is the ability of Wasm sandboxing to decrease the requirement for containers on the server. Containers are lighter than virtual computers, yet they still have a significant overhead.

Wasmer 3.0, released on November 23, includes a redesigned Rust API. Developers can safely store Wasm objects in the Store using this new API and memory management approach. Wasmer 3.0 also includes a new MemoryView and brings Wasmer-js, which uses Wasmer-Bingen to run Wasmer in the browser, up to feature parity with Wasmer-sys, which runs Wasmer natively. Any package uploaded to wapm.io can now be run straight from the Wasmer CLI owing to an improved wasmer run command.

Wasmer 3.0, released on November 23, includes a redesigned Rust API. Developers can safely store Wasm objects in the Store using this new API and memory management approach. Wasmer 3.0 also includes a new MemoryView and brings Wasmer-js, which uses Wasmer-Bingen to run Wasmer in the browser, up to feature parity with Wasmer-sys, which runs Wasmer natively. Any package uploaded to wapm.io can now be run straight from the Wasmer CLI owing to an improved wasmer run command.

The project has provided migration instructions from Wasmer 2x to Wasmer 3.0. Wasmer 3.0 also includes the following changes:

1. Overall, the Wasmer API has been improved, safer, and more ergonomic.

2. Many Wasmer engines, such as dylib, universal, and others, have been combined to improve code reuse.

3. The subcommand create-exe has been updated. Wasmer can now convert a WebAssembly file into a native Windows, Linux, or macOS executable. This allows users to receive executables without having to install Wasmer themselves.

4. Using the rykv framework for zero-copy deserialization of build artifacts has improved startup performance.

5. Support for multi-value functions added support for exception handling frames, and speed improvements are among the single-pass compiler enhancements.

6. Several issues have been fixed in the Wasmer WASI (WebAssembly System Interface) implementation. Web assembly interfaces have rewritten the file system and inner types.

Overview of Wasmer

Wasmer code, the first server-side WebAssembly (Wasm) runtime capable of running Nginx server-side. Web assembly will be a critical component of program execution and containerization in the future (not only inside the browser but also outside).

Using Wasm for software containerization, you may construct universal binaries that work without change on any operating system, including Linux, macOS, Windows, and web browsers. Wasm sandboxes applications for secure execution by default, protecting the host environment from malicious code, defects, and vulnerabilities in the software it executes. Wasm also offers a lean execution environment, allowing Wasmer containers to function in locations where Docker containers would be too heavy.

Wasmer benefits

No JIT bombs

JIT-bombs cause innovative contract processes to slow down or stop owing to malicious or poorly written code. Wasmer's Single-pass compiler eliminates JIT bombs, providing blockchain suppliers with a high-quality-of-service framework for their apps.

Infrastructure Diversity

Wasmer's blockchain infrastructure assures that regardless of the underlying technology, the output of each brilliant contract execution yields the same result. (For example, x86 64, ARM, etc.)

Performance

The Wasmer compiler engines and runtime enable fast compilation and code execution with no miscompiles.

API is quite simple to use

Wasmer 1.0's primary purpose is to make APIs very convenient for developers with little knowledge of sophisticated WebAssembly ideas or the WebAssembly ecosystem. Wasmer 1.0 enhances our API by shaping it on the same structures as the standard Wasm-C-API, making it future-proof.

Wasm-C-API

The industry will appropriately promote uniting APIs that interface with WebAssembly as the ecosystem evolves. Because the Wasm-C-API was still in its early stages, they created an API resembling our internal structures. However, as the industry progresses toward a standard API, they chose to include it in Wasmer 1.0 and contribute to it so that everyone can benefit.

Error reporting and resolution

Wasmer 1.0 reimagines and delivers a new and better error-handling capability that allows developers to interface confidently with Wasmer. Improve the time it takes to create production-ready Wasm applications. For example, know where it originates once a mistake happens: is it the Virtual Machine? Is this because there aren't enough resources? Is it an expected error caused by some of your host functions? Wasmer 1.0 builds the groundwork for future mistake detection and reporting capabilities.

Apple silicon support

ARM has a promising future in server-side workloads, reinforcing the requirement for universal binaries across chipsets. Wasmer is the first non-interpreted server-side WebAssembly VM in Apple Silicon to support Wasm!

Wasmer 1.0 is currently being used and reviewed by companies and individual developers worldwide. Wasmer 1.0, as you've read, exemplifies the countless development cycles. Wasmer's current incarnation was only feasible with the efforts of firms such as Google, Mozilla, Cloudflare, and Fastly (to mention a few).

About Wasmer

Wasmer Inc., based in San Francisco, CA, is the business behind the popular open-source WebAssembly runtime Wasmer. Aside from the Wasmer runtime, the firm has invested heavily in WAPM, the WebAssembly Package Manager, and numerous other open-source projects in the WebAssembly ecosystem.

Performance benchmarks

Wasmer 1.0 performance benchmark necessitates a separate post. Wasmer will be thoroughly analyzed compared to other Wasm runtimes, allowing you to evaluate and choose what is ideal for your project!

Infrastructure with Pluggable Ports

One of the most significant characteristics of any infrastructure product is its extensibility. Support for numerous compilers is one of our most important capabilities. The option to choose and plug in the compiler that best matches the customer's needs is quite powerful. Wasmer 1.0 has built-in support for:

Single-pass: for breakneck compilation speeds that are not sensitive to JIT bombs (ideal for blockchains).

Crane lift: for quick compilation times with little optimizations required (ideal for development).

When top performance is required, use LLVM to build optimal machine code (ideal for production).

Wasmer 3.0 can now generate native executable files for any platform. The command "Wasmer create-exe" has been rebuilt to convert a WebAssembly intermediate code file into standalone executables for Linux, Windows, and macOS platforms that may run without requiring Wasmer to be installed.

Summing Up!

Wasmer is an industry leader in server-side WebAssembly support, and it eliminates all of the hurdles developers must overcome to implement FaaS as part of their application development strategy. It eliminates all of the issues developers face when deploying machine learning applications in and out of data center environments.