Live data from Hacker News

Epsilon: A WASM virtual machine written in Go

github.com

21–30 of 47 posts

Re: Epsilon: A WASM virtual machine written in Go

#21
post #15
post #6

Do you have any plans to add timeouts or some other mechanism for limiting the amount of CPU a webassembly call can use? I'm always interested in options for using WebAssembly as a sandbox to run untrusted code, but one of the things I need to protect against is an infinite loop. (I had Claude knock up an experimental Python binding to try Epsilon out, notes from that here: https://github.com/simonw/research/tree/mai…

I'm working on an embeddable mini VM (RISC-V rather than WASM) and am considering this. In my model, there's something akin to a hardware watchdog where the VM is considered hung if it executes too many instructions without calling a yield() function in the host, then there's the ability to set a maximum number of instructions to execute before returning to the caller. This lets it be handled asynchronously at the pa…

Lua has hooks, which are callbacks that can be registered for a variety of different events, including every N instructions, and every call can decide to terminate the whole thing with an error. This mechanism can be used for different purposes, including tracing, some kind of performance stats and, of course, cancellation. I always found it to be a nice general solution.

Re: Epsilon: A WASM virtual machine written in Go

#22
post #11

Earlier quoted context omitted.

Started as fun "what if" side project, but kept me interested for 3 years now. Turns out it's actually useful. It's pretty portable: with some caveats, it works pretty much everywhere Go does. Performance is bad outside amd64/arm64, but for most popular OS/platforms it's fine. See this for an overall picture (these are the platforms I test): https://github.com/ncruces/go-sqlite3/wiki/Support-matrix I bet you could do…

I love sqlite a lot but there is always this idea in my head that maybe some day I might out grow sqlite and require postgres which in my opinion can be just "enough" Starting out with postgres if done via pglite and similars with golang's sqlite-ish approach can be brilliant I guess and I had this what if idea sort of inspired by yours actually but I don't think I can do that project basically right now but yea Idk…

[dead]

Re: Epsilon: A WASM virtual machine written in Go

#23
post #6

Do you have any plans to add timeouts or some other mechanism for limiting the amount of CPU a webassembly call can use? I'm always interested in options for using WebAssembly as a sandbox to run untrusted code, but one of the things I need to protect against is an infinite loop. (I had Claude knock up an experimental Python binding to try Epsilon out, notes from that here: https://github.com/simonw/research/tree/mai…

Yes, I am considering using something like https://pkg.go.dev/context for this very purpose, though I need to read a bit more into it first.

Funny that you built a Python wrapper as I originally started this implementation in Python, which was...not a good idea. Claude hallucinated the acknowledgments section though :D

Re: Epsilon: A WASM virtual machine written in Go

#24

WASM seems to be rather poorly documented in general. I used to think it is only badly documented in Ruby (which it is), but I have been slowly reading "WebAssembly The Definitive Guide" and when comparing this to information on the internet, it seems WebAssembly is years behind e. g. HTML, CSS, or JavaScript in regards to documentation. Granted, it is not the same user base (more people will be interested in HTML an…

WASM is also like two decades younger than HTML and CSS and generally useful to a small fraction of the audience.

Re: Epsilon: A WASM virtual machine written in Go

#25
post #6

Do you have any plans to add timeouts or some other mechanism for limiting the amount of CPU a webassembly call can use? I'm always interested in options for using WebAssembly as a sandbox to run untrusted code, but one of the things I need to protect against is an infinite loop. (I had Claude knock up an experimental Python binding to try Epsilon out, notes from that here: https://github.com/simonw/research/tree/mai…

Limiting the CPU vs protecting against an infinite loop are two different problems. The former is usually solved by sandboxing and using the limiters exposed by it, while the latter can be easily solved by just adding a cancellation timeout, when the function call/process/API call/whatever takes longer than X seconds, cancel it and return an error.

Re: Epsilon: A WASM virtual machine written in Go

#27

WASM seems to be rather poorly documented in general. I used to think it is only badly documented in Ruby (which it is), but I have been slowly reading "WebAssembly The Definitive Guide" and when comparing this to information on the internet, it seems WebAssembly is years behind e. g. HTML, CSS, or JavaScript in regards to documentation. Granted, it is not the same user base (more people will be interested in HTML an…

WASM development is really for a "level lower" than HTML, CSS, and JavaScript development. I know this because, being curious about it myself, I tried a year ago to make use of a WASM runtime in Go to run a piece of WASM code (I think I wrote something in V and compiled it to WASM).

It becomes a huge pain in the bum as soon as you have to deal with moving anything more than trivial types around, because you have to manually allocate memory for the WASM runtime and move bytes around. The byte representation needs to be understandable by the source language for your WASM code (the v language in my case). This is why these WASM runtimes use ints in their README examples, it would look and be horrendously complex otherwise.

If one is looking to use WASM for something for plugin development in the backend, I would try and look for something that is not WASM generic, but works with the source language, and where the WASM aspect is an under-the-hood detail.

Re: Epsilon: A WASM virtual machine written in Go

#28

WASM seems to be rather poorly documented in general. I used to think it is only badly documented in Ruby (which it is), but I have been slowly reading "WebAssembly The Definitive Guide" and when comparing this to information on the internet, it seems WebAssembly is years behind e. g. HTML, CSS, or JavaScript in regards to documentation. Granted, it is not the same user base (more people will be interested in HTML an…

Interesting; I've been using WebAssembly as a compilation target for various projects for the past four years, and have been fairly happy with the state of documentation. I've never heard of that book you mentioned (I should check it out!), and instead I just read the spec directly: https://webassembly.github.io/spec/core/

Or occasionally I Google specific Wasm instructions and find .wat examples for them on MDN.

I'm sure you're right that the documentation is years behind that of HTML and CSS, but is there some specific aspect of Wasm documentation that you find lacking that isn't covered by the spec?

Re: Epsilon: A WASM virtual machine written in Go

#30

WASM seems to be rather poorly documented in general. I used to think it is only badly documented in Ruby (which it is), but I have been slowly reading "WebAssembly The Definitive Guide" and when comparing this to information on the internet, it seems WebAssembly is years behind e. g. HTML, CSS, or JavaScript in regards to documentation. Granted, it is not the same user base (more people will be interested in HTML an…

WASM development is really for a "level lower" than HTML, CSS, and JavaScript development. I know this because, being curious about it myself, I tried a year ago to make use of a WASM runtime in Go to run a piece of WASM code (I think I wrote something in V and compiled it to WASM). It becomes a huge pain in the bum as soon as you have to deal with moving anything more than trivial types around, because you have to m…

This is the same in any system where you have two different runtimes/programming languages. The source values need to be serialized to bytes and then deserialized by the target. You could use json for this or flatbuffers. WASI has its own serialization mechanism but I don't know what langugages it supports.
Post reply on HN