March 8, 2021. 4 minutes read. PDF
An experimental outbound HTTP library for the WebAssembly System Interface
Send HTTP requests from Rust and AssemblyScript Wasm modules running in Wasmtime
Send HTTP requests from Rust and AssemblyScript Wasm modules running in Wasmtime
Memory in WebAssembly is one of the topics that creates confusion for newcomers, particularly for those with experience in languages with memory management features like garbage collection, such as JavaScript, Go, or Java. In this article we explore using memory in WebAssembly in various scenarios - passing JavaScript arrays to Rust and AssemblyScript modules, checking for some basic memory leaks using Valgrind, or exchanging strings between runtimes and modules using Wasmtime.
An experimental JavaScript library that helps instantiating WebAssembly modules with imports by providing functionality to link JavaScript objects as imports, as well as automatically perform name based resolution for linking entire modules.
In this article, we experiment with building a Rust program that performs image classification using the MobileNet V2 TensorFlow model, compile it to WebAssembly, and instantiate the module using two WebAssembly runtimes that use the WebAssembly System Interface (WASI), the native NodeJS WASI runtime, and Wasmtime. A special interest is given to writing model and image data into the module’s linear memory, with implementations in both JavaScript and Rust. Finally, a simple prediction API is exemplified running on top of the Wasmtime runtime, and some limitations of this approach are discussed.
In this article we look at the current state of the networking API in WASI, and add a minimal implementation together with socket clients in AssemblyScript and Rust (with an upfront disclaimer that this should definitely not be used for anything other than experimentation).
© Radu Matei 2022