7 ms·
Show HN: TinyWasm – A tiny WebAssembly Runtime written in Rust
Show HN: TinyWasm - A tiny WebAssembly Runtime written in Rust
Hi HN! I'm excited to share TinyWasm (https://github.com/explodingcamera/tinywasm https://github.com/explodingcamera/tinywasm), a WebAssembly Interpreter I developed for my final university project.
The main goal of this project was to deepen my understanding of WebAssembly and interpreter design. TinyWasm successfully passes all the official WebAssembly 1.0 tests and also includes features from future proposals such as like bulk memory operations.
Initially more of a research project, TinyWasm focuses on simplicity and portability. It has minimal third-party dependencies, a small codebase, and is compatible with no_std environments. It's now available as a standalone library (https://crates.io/crates/tinywasm https://crates.io/crates/tinywasm), and I hope it can be useful for embedding into other projects and hacking on, especially because it's designed to be easy to understand and modify, while still being decently performant.
I'm looking forward to feedback, hope you find it useful!
- fermigier 3y agoGreat job. Some benchmarks would be interesting, but I can't contribute ATM.
- ledgerdev 3y agohttps://github.com/explodingcamera/tinywasm/blob/main/BENCHMARKS.md https://github.com/explodingcamera/tinywasm/blob/main/BENCHM...
- Sytten 3y agoIt would be interesting to have benchmarks in memory usage et performance versus the big projects like wasmtime and wasmer. There are quite a few interpreters in rust these days! Did you plan for possible spec extension like WASI?
- explodingcamera 3y agoWASI is one of the next things I want to explore. Right now, there sadly doesn't seem to be any self-contained implementations for the recently released WASI preview 2 out there, and TinyWasm also doesn't have support for the WebAssembly Component Model yet. For performance, I have some very preliminary benchmarks, but this is something I want to go into more as part of my upcoming bachelor's thesis.
- deleted 3y ago[deleted]
- ledgerdev 3y agoThis looks excellent. Since this is a university project, what future plans/hopes do you have for the project?
- abricq 3y agoLooks quite interesting ! Since this was done as a university project, did you have to write a report ? If you did and that it can be shared, I would love to go through it
- explodingcamera 3y agoHi! I have a short reflection essay, which should be mostly covered by the documentation in the repo. But I could share it if you shoot me an email.
- rrampage 3y agoSuper nice project! I also spent the last month writing a WASM interpreter ( https://github.com/rrampage/wart https://github.com/rrampage/wart ) using Java 21. I started it as an excuse to try out the pattern matching in switch / sealed classes in Java. It kind of snowballed in scope and can now run Doom and Waforth ( https://github.com/remko/waforth https://github.com/remko/waforth )! Have not yet tried compiling it to WASM and running it as a meta-circular interpreter.
- news_to_me 3y agoI’ve been working through the WebAssembly spec recently and it’s pretty interesting, there are many design aspects I wouldn’t have chosen. Was there anything about the spec that was surprising or frustrating to you?
- sestep 3y agoFlipping this around, could you elaborate on which specific design aspects you wouldn't have chosen?
- mleonhard 3y agoThanks for sharing your project! How does performance change when the `unsafe` feature is disabled? It looks like there is only one usage of `unsafe` outside of the no_std build: https://github.com/explodingcamera/tinywasm/blob/c50bae752f3e788faf66b376d065374cc4085931/crates/tinywasm/src/store/memory.rs#L192 https://github.com/explodingcamera/tinywasm/blob/c50bae752f3...
- explodingcamera 3y agoYeah, the only unsafe code right now is using this trait to prevent some duplicate bounds checking when reading/writing to memories that wasn't being optimized by the rust compiler. Shouldn't be too much of a performance difference for code that's not too heavy on memory access, made about a 5-10% difference for the selfhosted benchmark if I remember correctly though.
- deleted 3y ago[deleted]