Live data from Hacker News

Wasmtime 1.0: A Look at Performance

bytecodealliance.org

11–20 of 23 posts

Re: Wasmtime 1.0: A Look at Performance

#11
It is very disappointing there are no embeddable, performant wasm runtimes. The language is perfect for embedded systems, it's a near asm level sandbox. But there's no good no_std or limited dependency runtimes! If wasm is to grow, it should work on this use case.

I should be able to provide platform APIs to allocate memory, maybe do some floating point math, and then that's about it. Additional features would just be giving some additional API implementations the runtime needs to interact with the host machine.

Context: this was a huge barrier for me on my project https://github.com/mandiant/STrace/blob/16859a811e4af7c68259...

Re: Wasmtime 1.0: A Look at Performance

#12

It is very disappointing there are no embeddable, performant wasm runtimes. The language is perfect for embedded systems, it's a near asm level sandbox. But there's no good no_std or limited dependency runtimes! If wasm is to grow, it should work on this use case. I should be able to provide platform APIs to allocate memory, maybe do some floating point math, and then that's about it. Additional features would just b…

Have you looked at WebAssembly Micro Runtime (WAMR)?

https://github.com/bytecodealliance/wasm-micro-runtime

Re: Wasmtime 1.0: A Look at Performance

#13
post #5

Earlier quoted context omitted.

> what's the point of taking machine code capable software, compiling it into WASM, and then compiling that back into machine code? If I understand your question correctly, the point is that wasm becomes the agreed-upon target, so you only need language -> wasm compilation and you can then distribute that artifact everywhere. Then you can either JIT it or recompile it into machine code at the endpoint, as an optimiza…

why would any language besides javascript want to be that maximalist, when they already have either a much better direct native compiler, or their own, purpose-built, mechanically-sympathetic, fully featured interpreter with first-class support and a controllable destiny? We didn't do this with Java back in the day when it was possible -- essentially all but a small handful of JVM languages died on the vine -- so wha…

We didn't do it with Java because JVM bytecode is very narrowly tailored to Java. For example, it doesn't have the notion of pointer arithmetic, for example, so you can forget about anything like C (one can emulate heap as a Java array and build the rest on top of that, of course - but only if performance doesn't matter).

On the other hand, wasm is low-level enough to handle C.

.NET / CLR was the previous attempt to do something like this, and it did have compilers for many different languages targeting it. But the downside there was that the runtime itself wasn't meaningfully portable for a very long time. If it were open and cross-platform from the get go, who knows, perhaps wasm would have been a CIL subset.

Re: Wasmtime 1.0: A Look at Performance

#14

It is very disappointing there are no embeddable, performant wasm runtimes. The language is perfect for embedded systems, it's a near asm level sandbox. But there's no good no_std or limited dependency runtimes! If wasm is to grow, it should work on this use case. I should be able to provide platform APIs to allocate memory, maybe do some floating point math, and then that's about it. Additional features would just b…

are you talking about something similar to micropython for micro controller?

Re: Wasmtime 1.0: A Look at Performance

#15

It is very disappointing there are no embeddable, performant wasm runtimes. The language is perfect for embedded systems, it's a near asm level sandbox. But there's no good no_std or limited dependency runtimes! If wasm is to grow, it should work on this use case. I should be able to provide platform APIs to allocate memory, maybe do some floating point math, and then that's about it. Additional features would just b…

wasm3 is super small and easy to embed.

Re: Wasmtime 1.0: A Look at Performance

#16
post #7
post #3

How do bytecode compilers like Cranelift compare to native images generated out of bytecode that's easier to optimize for pure machine code execution (Java, dotnet)? Perhaps more relevant: what's the point of taking machine code capable software, compiling it into WASM, and then compiling that back into machine code? A reinvention of FFI perhaps?

Ignoring security for a moment: Say you want to write a web application in Rust. You want to ship your web application to your users. You don't want your users to have to wait for the whole application to compile and download all dependencies; you want to ship some precompiled stuff. What do you ship? We could have some web standard where we ship native code to the user, which the user's machine then executes directl…

> The alternative is that we have some specification for intermediate code which is low level enough to be a universal compile target but abstract enough to be possible to compile to essentially any CPU architecture. That's what WASM is.

Isn't that exactly what Java did years ago? And what Microsoft's .NET bytecode did when they had to remove the Microsoft JVM?

Standard WASM is stack based, unlike every real computer out there. It also explicitly supports unaligned memory which is terrible for native execution performance. It was designed for the limitations of the browser sandbox as an evolution on a backwards compatible Javascript library.

I don't know why you'd need tk shop different versions for different instruction sets, that's exactly the problem Java, and to a lesser extent dotnet, solves. The runtime is platform dependent, the binary isn't. You can build a JAR and run it on anything from old MIPS server to a Windows 11 machine or an M2 Mac if your code targets a runtime old enough. You don't need to compile separate versions for each platform at all.

Building platform independent executables has already been solved by Java and very few people actually use it. I'm not against an alternative to Java, or anything else tainted by Oracle for that matter, I just don't see the use cases outside the browser for platforms precompiling WASM.

Re: Wasmtime 1.0: A Look at Performance

#17
post #8

Earlier quoted context omitted.

why would any language besides javascript want to be that maximalist, when they already have either a much better direct native compiler, or their own, purpose-built, mechanically-sympathetic, fully featured interpreter with first-class support and a controllable destiny? We didn't do this with Java back in the day when it was possible -- essentially all but a small handful of JVM languages died on the vine -- so wha…

JVM bytecode is, to my understanding, basically just a serialized, desugared Java. It has a concept of classes with constructors and it has objects and references and inheritance and basically all of Java's semantics encoded in it. Languages which aren't "java-like" have a hard time compiling to it. WASM, on the other hand, is more like machine code, so languages which are used to compiling to machine code have a fai…

Indeed, not to mention the GC, which isn't one size fits all (not even within Java itself).

And wasm could run in ring 0 if you want, the runtime is that hardened.

Re: Wasmtime 1.0: A Look at Performance

#18
post #7

Earlier quoted context omitted.

Ignoring security for a moment: Say you want to write a web application in Rust. You want to ship your web application to your users. You don't want your users to have to wait for the whole application to compile and download all dependencies; you want to ship some precompiled stuff. What do you ship? We could have some web standard where we ship native code to the user, which the user's machine then executes directl…

> The alternative is that we have some specification for intermediate code which is low level enough to be a universal compile target but abstract enough to be possible to compile to essentially any CPU architecture. That's what WASM is. Isn't that exactly what Java did years ago? And what Microsoft's .NET bytecode did when they had to remove the Microsoft JVM? Standard WASM is stack based, unlike every real computer…

Both Java and .NET use garbage collection with all the upsides and downsides of it. They also have heavy runtimes with slow startup times. WASM is different is these aspects.

Re: Wasmtime 1.0: A Look at Performance

#19
Happy to see they finally reduced the instantiation time to a few microseconds. I have had 1 micro in prod for another emulator, so I was wondering what the holdup was. Also see they are using madvise for CoW - it is fairly slow and I ended up not using it. That is, pagetable changes on Linux are just absolutely unusably slow on a larger scale, in production.

Re: Wasmtime 1.0: A Look at Performance

#20
post #4
post #3

How do bytecode compilers like Cranelift compare to native images generated out of bytecode that's easier to optimize for pure machine code execution (Java, dotnet)? Perhaps more relevant: what's the point of taking machine code capable software, compiling it into WASM, and then compiling that back into machine code? A reinvention of FFI perhaps?

> Perhaps more relevant: what's the point of taking machine code capable software, compiling it into WASM, and then compiling that back into machine code? A reinvention of FFI perhaps? Firefox has some parts which are compiled to WebAssembly, and Mozilla wrote an article about it [0]. They seem to use WebAssembly to sandbox the code and improve security. [0]: https://hacks.mozilla.org/2020/02/securing-firefox-with-we…

Firefox is weird. The compile to wasm and then aot-compile that to native code. It's purely to get C/C++ boundschecking and stuff like that everywhere
Post reply on HN