13 ms·
Show HN: Life – A secure, blazing-fast, cross-platform WebAssembly VM in Go
- nine_k 8y agoIn short: a reasonably compliant, customizable VM without native dependencies, great for running code in cross-platform sandboxes. A JIT is planned but not yet implemented.
- sanxiyn 8y ago> A JIT is planned but not yet implemented. I see "Life (JIT)" in the benchmark plot. What is it?
- hiccuphippo 8y agoIs WebAssembly more secure than Javascript when it comes to escaping the sandbox? I see exploits every year in pwn2own for Javascript.
- jchw 8y agoThat question should be answered in future pwn2owns, probably :) but since it reuses JIT architecture in existing JS engines, my guess is that it will mostly benefit from previous security and sandboxing advances.
- Brometheus 8y agoHow fast is this compared to browser javascript vm "implementations" of WebAssembly?
- monocasa 8y agoAt least an order of magnitude slower, probably two. It doesn't even implement a JIT yet.
- nine_k 8y agoAFAICT WebAssembly VM is implemented in native code in the major browsers (Firefox, Chrome, Safari, Edge). It's pretty fast, and has a pretty limited interface to JS or DOM.
- monocasa 8y agoNative code or not shouldn't matter that much for a JIT. I've heard Cliff Click say in a talk that if he were to write another VM, it'd probably be in something like Java. The memory management of fairly arbitrary graphs like you get in a compiler really benefit from garbage collection, and it's nice to run the compiler sort of through itself to get dynamic profiling for optimization.
- nine_k 8y agoI mean, implementing a WebAssembly VM inside e.g. JVM is both possible and practical, but it's a very different approach from implementing it in native code, let alone any JIT approaches.
- monocasa 8y agoI mean, implementing a JIT is orthogonal to implementing it in another VM. See JITing meta circular evaluators like Jikes or Graal.
- jhoechtl 8y agoI understand the basics behind WASM. What does WebAssembly VM in Go mean? Can I write Golang code and see it executed through Life? Or will it execute my WASM binaries, compiled through whatever? If the later, how is Life VM meant to be integrated into a web browser (if this is a goal)?
- nine_k 8y agoYes, WASM binaries from anything. The VM configures the available imports.
- stcredzero 8y agoCan I write Golang code and see it executed through Life? Is there a Life target for the Go compiler?
- kzkfkkf 8y agoWhat are you even asking? Nobody suggested life is a target.
- xmlflfkf 8y ago> I understand the basics behind WASM. What does WebAssembly VM in Go mean? A VM is a virtual machine, in this case capable of running wasm outside of your wasm-enabled browser. You could also have learnt this by following the link you are commenting on and RTFM.
- dang 8y agoPlease don't be rude here.
- sbinet 8y ago- the VM is written in Go and can execute wasm binaries - the next version of the Go toolchain (Go-1.11) will have a wasm target
- kodablah 8y agoSaw this on /r/golang and made some comments there. Good work! Always happy to see more non-web uses of WASM. Here's to hoping some of those higher-level features come to WASM soon so that we can really start sharing code instead of in the primitive constructs we have to use now.
- AYBABTME 8y agoCan CPU and memory limits be enforced? If so, how is it done?
- humblebee 8y agoIt supports both a `DefaultMemoryPages` size, as well as a `MaxMemoryPages` in the vmconfig[0]. Only the `DefaultMemoryPages` is set when running through the cli (value of 128 pages, with a page size of 64KB), and there appear to be no flags to configure it at the moment. [0] https://github.com/perlin-network/life/blob/master/exec/vm.go#L56-L64 https://github.com/perlin-network/life/blob/master/exec/vm.g...
- AgentME 8y agoIt looks like this Life VM has a "RunWithGasLimit" function that can run WebAssembly for a limited number of steps. I'm not sure if it pauses or aborts the VM when the limit is reached. On a related note: you can enforce a CPU limit on WebAssembly in any engine by using wasm-metering[0]. Note that if the WebAssembly hits the limit, it is entirely aborted, not paused. So wasm-metering is good for limiting the CPU usage of a WebAssembly binary that has short functions called regularly, but not capable of time-slicing a long-running WebAssembly function. I think you'll need custom support from a WebAssembly VM (or a much more extensive preprocessor) for that. [0] https://github.com/ewasm/wasm-metering https://github.com/ewasm/wasm-metering
- skybrian 8y agoAt first glance, this looks like an ordinary interpreter loop [1] using a large switch statement. I didn't think this was all that fast in Go, compared to C. And yet the JIT version isn't hugely faster and can be slower. Are there performance tricks I'm missing? [1] https://github.com/perlin-network/life/blob/master/exec/vm.go#L340 https://github.com/perlin-network/life/blob/master/exec/vm.g...
- kzkfkkf 8y ago> I didn't think this was all that fast in Go, compared to C. Maybe it is time to re-evaluate your beliefs then?
- iainmerrick 8y agoDo you mean the JIT engine in this same codebase? It looks like it generates C code and compiles it on the fly. The generated code seems to do manual stack operations, rather than assigning values to variables, and it’s compiled with -O1 so it won’t be heavily optimized. It will be a bit faster than the interpreter because it avoids the opcode dispatch overhead, but if I understand the code right it’s not surprising that it isn’t a ton faster.
- skybrian 8y agoNote: benchmarks are comparing to other wasm interpreters (in Go and Rust), not browser implementations.
- seabrookmx 8y agoYeah this claim: > is faster than all other WebAssembly implementations tested is pretty meaningless once you realize this. I'd be really surprised if this outperformed V8 or SpiderMonkey, but I'd love to be proved wrong.
- iainmerrick 8y agoLooking at the benchmark results, it’s really not very fast. Over 3 seconds for fib(35)??
- eadmund 8y agoThis is off-topic, but I really wonder what happened to adverbs in English, and why. When I was a boy — not that long ago — it would have been 'blazingly fast.' The project itself looks pretty cool, though. It's neat to see WebAssembly starting to take off. I'm eager to begin programming browser applications in a decent language …
- buckminster 8y agoAmerican English abandoned them. They are still used in British English.
- ksec 8y agoAnd the internet has made English American, newer generation in EU are now writing more American English than ever.
- dragonwriter 8y agoWhat happened is that they became progressively less common in informal/spoken American English, and then only very recently in a fairly sudden transition most commercial writing abruptly lost the attention to grammar, spelling, word choice, etc., that had been previously the norm for formal writing because who has time for that?
- memonkey 8y agoIt's common to avoid adverbs in general when writing fiction IIRC.
- aplummer 8y agoNot by removing the ly though, but by choosing a more expressive verb.
- drb91 8y agoI was taught in (american) school adverbs are a lazy and informal form of expression. While I didn't agree at the time, I use them now only vanishingly rarely. ;)
- tambourine_man 8y ago>…faster than all other WebAssembly implementations tested (go-interpreter/wagon, paritytech/wasmi). Isn't Mozilla's implementation the fastest and most mature of them all? How does it fare against it?
- dingdingdang 8y agoCan't immediately see any mention of of how to accommodate file access on local system (or permanent storage within sandbox) - any pointers?
- AgentME 8y agoWebAssembly has no native filesystem APIs or any built-in APIs to the outside world. A WebAssembly binary may specify that it wants to import functions by certain names, and it's up to the user of the WebAssembly to implement and provide the functions that the WebAssembly wants to import. You could make a WebAssembly binary that imports a "readFile" function, and then you could load the WebAssembly in Go with this Life VM (or in Javascript with the native WebAssembly APIs) and specify your implementation of the "readFile" function in the host environment. Your implementation of "readFile" can then impose whatever restrictions it wants.
- humblebee 8y agoI believe Import Resolvers[0] solve this issue. [0] https://github.com/perlin-network/life#import-resolvers https://github.com/perlin-network/life#import-resolvers
- not_ca 8y agoThis is not about cellular automata? I feel misled. Can it be renamed to something more indicative of virtualization?
- incompatible 8y agoDoes the lack of OS dependencies mean that it can't present a graphical user interface? Isn't that the main intended usage of WebAssembly, providing a cross-platform user interface that usually runs in a browser?
- optician_owl 8y agoIt's secure if so was written in description.
- AtomicOrbital 8y agoThe point here is not speed (that will come), the hope is it will bring privacy to your computational needs along with cost reduction and a little reverse crowdfunding ... perlin is a new distributed computation platform to spread execution of your code across disparate VM running on non-traditional machines. Goal here is to compete with big boys who run cloud VPS hosting services such that folks with spare cycles rent their hardware so other folks can execute their code ... to quote : "Researchers, developers, startups and enterprises incur excessive costs to power up the cloud machines/instances they rent from centralized cloud computing providers. Perlin is creating a decentralized, trustless cloud computing marketplace which delivers massive computational throughput and power with the ability to attain high transaction volume and market activity, effectively reducing the cost of computing power." https://www.perlin.net/ https://www.perlin.net/ More to the point and I quote : "Decentralized cloud computing. Perlin’s compute layer is bootstrapped on top of it’s DAG-based ledger unlocking a plethora of underutilized compute resources from everyday devices, to form a decentralized cloud computing marketplace that combats the inflated pricing models set by the oligopolistic cloud computing market." "Perlin is the first practical, trustless and decentralized cloud computing marketplace that leverages underutilized compute power in everyday smart-devices to make supercomputing economically viable and accessible globally. This is achieved via a DAG-based distributed ledger using Avalanche consensus." https://www.reddit.com/r/perlin/comments/8vq0c1/the_perlin_network_allinone_thread/ https://www.reddit.com/r/perlin/comments/8vq0c1/the_perlin_n...