5 ms·
Sounds really exciting. Are comparisons to things like the JVM or native binaries already possible?
by k__ 8y ago
Sounds really exciting.
Are comparisons to things like the JVM or native binaries already possible?
- steveklabnik 8y agoI'm not 100% sure what you mean by that final sentence, could you maybe elaborate?
- k__ 8y agoSure. Does WASM have better performance than the JVM? If not, could it have better performance theoretically? Is it more secure? How much slower than a regular binary would it be? etc.
- steveklabnik 8y agoAh, cool. Performance is really difficult to properly measure, because each of these projects have different performance profiles, and new ones keep popping up, like Lucet did today! And if you write a benchmark, then something like https://hacks.mozilla.org/2018/10/calls-between-javascript-and-webassembly-are-finally-fast-%F0%9F%8E%89/ https://hacks.mozilla.org/2018/10/calls-between-javascript-a... happens, and all of a sudden the numbers are all different. So it's really hard to speak about wasm generally this way, it's better to talk about specific implementations and use-cases, IMHO. And to understand that benchmarks need to be updated in order to still be relevant. Security is an interesting axis; like the JVM (as far as I know), wasm is memory safe by design. But security is more holistic than that. One interesting thing about wasm is that you have to say up-front what things you want to call in the host, which provides the ability for the host to say "nope, you're not gonna be able to do that." And of course, logic bugs can lead to security vulnerabilities in all of these platforms.
- k__ 8y agoI see. Nice, sounds like the Android/Fuchsia approach security-wise :)
- ridiculous_fish 8y agoI think wasm's memory safety is weaker than JVM. wasm's checking occurs at control flow points and the linear memory boundary, but does not extend down to individual objects. For example arrays are not bound checked in wasm.
- steveklabnik 8y agoWasm doesn't really have "arrays", so I don't think wasm checking them would really make sense. I guess you could argue that this is a distinction without a difference. You still won't get memory unsafety, which in my mind, is the higher order bit. YMMV of course.
- pjmlp 8y agoIt is possible to corrupt data on the stack due to out of bounds.
- steveklabnik 8y agoYes, bugs can always exist.
- rixed 8y agoNot sure what you mean by that, but probably not that stack corruption is a necessary evil of any language.
- pjmlp 8y agoNot when you use a VM that actually cares about security at all layers, but anyway WASM is doing everything better. /s
- Rusky 8y agoUsing such a VM requires rewriting existing C code. Wasm's approach allows that to happen incrementally, where it matters, by using memory safe languages like Rust, instead of relying on the VM.
- phickey 8y agoLike Steve says, performance is a complicated thing to measure. For one view on it, Lucet ships with a suite of microbenchmarks that compare its execution of wasm with the same C code compiled natively. The `make bench` target runs these. The most alarming regressions are in simple functions that take string arguments - the arguments have to be copied into the sandbox, and then the results copied out, in order to run a very simple function. So, in those cases, we don't expect to match native, but things will get better when GC proposal lands in WASM, which gives support for operating on memory regions that are outside of WASM linear memory. But in most applications we've experimented with, we haven't found this overhead to be a showstopper.
- kodablah 8y ago> Does WASM have better performance than the JVM? If not, could it have better performance theoretically? Is it more secure? How much slower than a regular binary would it be? etc. Hard to answer as they're different domains. In theory, once optimized and JIT'd, the asm could be the same on non-GC'd sections. JVM bytecode is higher level which means it both benefits (i.e. can optimize more) and is hamstrung (i.e. GC). As for a "regular binary", the JVM knows no such thing and really neither does WASM. Also depends on what "regular" is (i.e. what does the code do) and which runtimes you use and how much is AOT'd vs JIT'd vs interpreted.
- dmitriid 8y agoWASM has a subset of a subset of a percentage of features that JVM provides. It's basically a runtime for C/C++-like feature set [1], JVM has support for many of the features that are still on WASM's roadmap [2] I would be very wary of any performance comparisons between WASM and ... pretty much anything else (except, possibly, bare C?). [1] https://webassembly.org/docs/high-level-goals/ https://webassembly.org/docs/high-level-goals/ [2] https://webassembly.org/docs/future-features/ https://webassembly.org/docs/future-features/
- k__ 8y agoIf I understood this correctly, that's what the Fastly people do. They compare it to bare C binaries and besides string-performance, it holds up good.