8 ms·
Wasmer 2.0
- methyl 5y ago> If you're new to the Wasmer community, you'll be delighted with the incredible performance that you can achieve with Wasmer 2.0, bringing your Wasm programs and libraries very close to native speeds. Is there any set of benchmarks comparing Wasmer to native at a larger scale, real-life based examples?
- jedisct1 5y agohttps://00f.net/2021/02/22/webassembly-runtimes-benchmarks/ https://00f.net/2021/02/22/webassembly-runtimes-benchmarks/ A new round will be made soon.
- the_duke 5y agoSuggestion: add Deno for the next round. [1] It would also be great to have a benchmark in there that measures host <-> guest interaction with lots of guest -> host and host -> guest calls. [1] https://deno.land/manual/getting_started/webassembly https://deno.land/manual/getting_started/webassembly
- jedisct1 5y agoThat’s a good idea, thanks! Deno is using the V8 engine, so is the performance expected to differ from Node? Probably not but there’s one way to find out
- the_duke 5y agoProbably not, no. It would just be interesting to see if the wrapper code makes a difference. I actually started working on a benchmark suite for various runtimes a while ago. I didn't get too far in, maybe you'd like to collaborate? As wasm grows it would be great to have a comprehensive set of benchmarks to refer to. Especially also for things that are unique to Webassembly, like reference types, cross calls, module instantiation time, ...
- dlojudice 5y agoI didn't know SIMD was supported in WASM spec. Is it custom binary or they've improved WASM?
- Lev1a 5y agoYou can see "Standardized features" and "In-progress proposals" in this table here: https://webassembly.org/roadmap/ https://webassembly.org/roadmap/
- espadrine 5y agoThe SIMD proposal is in stage 4. It is released in V8, and behind a flag in Firefox. https://v8.dev/features/simd https://v8.dev/features/simd
- CryZe 5y agoIt is also released in Firefox (x86 only, ARM is in the next release iirc)
- devwastaken 5y agoIt's a spec in addition to the initial we assembly spec. It's supported by clang/llvm, V8, firefox, and some standalone runtimes like wasmer. SIMD for wasm is all 128bit operations. I've been working with it and so far it works pretty fast, but there's missing support for some operations. Namely lack of support for saturation/truncation operations.
- deleted 5y ago[deleted]
- xstefen 5y agoThis entire thing reads like a UltronBrowser commercial
- mattgreenrocks 5y agoCongrats to the team, looks like some more fun things to play with! > [floating point math is faster] thanks to optimal management of NaNs Curious what's involved here if someone from the team can chime in.
- syrusakbary 5y agoHandling NaNs (Not a Number, usually referring to operations that trigger non arithmetic numbers, such as 0/0) was not optimally handled by Wasmer LLVM compiler. We had a custom NaN "canonicalizer" that was always canonicalizing NaNs (that means: making sure the NaN bits were always the same in any chipset) regardless of use case and need. We took a look on how other runtimes were doing it more optimally and realized we could use LLVM intrinsic calls for math operations so LLVM would handle it directly. If you are curious about the tech details, here's the PR! https://github.com/wasmerio/wasmer/pull/2161 https://github.com/wasmerio/wasmer/pull/2161
- tgb 5y ago> NaNs (Not a Number, usually referring to positive/negative Infinite values in floats and integers) Huh? This sounds totally incorrect to me.
- syrusakbary 5y agoSorry about that! I was trying to explain it so people with little understanding could see how NaNs are handled/generated in a Wasm context (for example: 0/0 will trigger a NaN), but it's true that Infinite and NaNs are not the same. I'll correct my comment :)
- mattgreenrocks 5y agoMakes sense. NaNs are super weird: quiet/signaling variants, as well as they're technically a set of values, WRT to which bits indicate them.
- simooooo 5y agoRead the site, still don’t know what it is
- mamcx 5y agoASIDE: Any suggestion for ways to generate programatically with Rust? https://www.reddit.com/r/rust/comments/nvxh12/for_building_a_languageinterpreter_wasmer_or/ https://www.reddit.com/r/rust/comments/nvxh12/for_building_a...
- hardwaregeek 5y agoWalrus is great although because it was intended for editing existing WASM binaries and not being a WASM compiler backend, it has some limitations. For instance it can't easily generate recursive functions cause you need the function id before generating the function body and that's not easy in Walrus.
- gpm 5y agoFor what it's worth, I spent a bit of time setting up assemblyscript (basically typescript) compilation driven by a rust program (with the actual compilation happening in a js vm) not too long ago for an (unpublished) side project. If that's something you'd be interested in I could see about reviving it and refactoring it out, or you could probably do the same from scratch, but it is a bit janky, and it sounds like you really want a backend for a homegrown compiler not an entire compiler. I also think you might be able to use cranelift as the sort of backend you are looking for, but I haven't tried.
- hardwaregeek 5y agoI'm very curious why Wasmer 2.0 can't deserialize modules that are serialized by Wasmer 1.0. Are they serializing to a non-spec complaint format? Are there extra custom sections that Wasmer 2.0 expects? This seems like a relatively small problem but I'm curious why it's there.
- syrusakbary 5y agoWe use a custom serializer for serializing the metadata related to the WebAssembly module and other compilation information. We changed the serialization mechanism to speed up startup speed and with that the incompatibility came.
- lenkite 5y agoCan some one explain the difference between the Wasmer and Wasmtime projects ?
- arcatek 5y ago- Not the same bakers (wasmtime is supported by the Bytecode Alliance nonprofit, which is behind the wasm specs, whereas wasmer is a startup) - Not the same implementations, so not the same optimizations performances everywhere (you can see that a bit like clang vs GCC). So which one to use depends on your tradeoffs. For me personally, I saw firsthand what an ecosystem tool could become once owned by a startup, and I would be very careful about this path. There are more technical comparisons here and there if you look a bit (for example in /r/rust).
- syrusakbary 5y agoI'll not enter on the technical comparisons but more on the philosophical view of your comment. Somehow you are not wary of an organization that is 90% directed by one entity. It might be useful to know that 95%+ of the code changes in wasmtime are by people working in Fastly. Google is the main pusher to Chrome, the fact that Google is a commercial entity doesn't make good or bad on how they move the ecosystem forward. It makes it more effective. I'm usually wary and careful when people advise for software and commercial value to be separated.
- arcatek 5y ago> Somehow you are not wary of an organization that is 90% directed by one entity. It might be useful to know that 95%+ of the code changes in wasmtime are by people working in Fastly. I'm not overly worried about some companies investing more in communities than others, that's true, as long as there's some level of oversight (those 5% you mention). I also suspect that a lot of those Fastly employees you mention came after the Mozilla layoffs we heard about a year ago, which I think invalidates a bit your point as the responsibilities were then shared before being unfortunately moved in to Fastly in short notice. It makes sense it would take time to address that perfectly, considering the context. > Google is the main pusher to Chrome, the fact that Google is a commercial entity doesn't make good or bad on how they move the ecosystem forward. It makes it more effective. That's not a great example - Chrome famously pushes changes without any oversight, which leads to useless APIs in the best cases to downright harm to their users in the worsts.
- kiliancs 5y agoCongrats on the release and thanks for the detailed post. I thought I'd share that, reading through it, I found that the 3D in the charts made them harder to read. You can still figure it out, but it's harder to understand at a glance.
- rad_gruchalski 5y agoLooks awesome. Any examples for calling host golang functions?
- syrusakbary 5y agoI'd recommend to check Wasmer Go integration [1]. More specifically, here's how you can call Go host functions: https://github.com/wasmerio/wasmer-go/blob/master/examples/example_early_exit_test.go#L67-L76 https://github.com/wasmerio/wasmer-go/blob/master/examples/e... [1] https://github.com/wasmerio/wasmer-go https://github.com/wasmerio/wasmer-go
- irq-1 5y agoNB: there's no passing strings to/from the wasm vm.
- rad_gruchalski 5y agoBut byte arrays would work?
- Hywan 5y agoWebAssembly only supports i32, i64, f32, and f64 for the moment. So you need to allocate the string manually inside the Wasm memory, then pass the pointer of that string to the Wasm function. I will add an example to showcase that, many people are asking this :-).
- irq-1 5y agoThanks for your work on wasmer-go. Would it be possible to make go functions that wrap string passing, and add them to the go api? Is freeing the memory manually inside the wasm vm something that can be delegated to the vm?
- rad_gruchalski 5y agoThis would be awesome! Thank you.
- matheuss-leonel 5y agoIts just me or it seems that Java is being reinvented again? With improvements, off course, but the whole thing looks like just another virtual machine, but this time directly connected to the web. Everything old, is new again...
- mden 5y agoEven if that's the case, it doesn't explain why that's bad? Generally that's how progress is made, exceedingly rare is the core of an idea original.
- matheuss-leonel 5y agoYes, I agree with you. Its not bad, its just "curious" how things evolve
- mbStavola 5y agoNot really. The JVM and JVM bytecode was written with Java in mind, whereas WASM wasn't designed for a single language.
- deleted 5y ago[deleted]
- cylon13 5y agoAwesome, I just upgraded our project! We're using wasmer in a browser-based multiplayer game in order to get cross-platform floating point determinism so we can send only input packets over the wire confidently without worrying about state drift. The client and server run the exact same wasm bundle instead of just being compiled from the same source, and the wasm spec guarantees that as long as you don't touch NaN and stick to one thread, you'll get the same results in any runtime [1]. [1] https://github.com/WebAssembly/design/blob/main/Nondeterminism.md https://github.com/WebAssembly/design/blob/main/Nondetermini...
- jacobolus 5y ago> as long as you don't touch NaN Note: this says NaNs one place will be NaNs everywhere, just the precise choice of NaN bit pattern is unspecified. So there is no issue “touching NaN”; the issue would be trying to pack some additional information into the fraction bits of the NaN, and expecting every implementation to treat it the same.
- cylon13 5y agoYeah, that's a good point actually.
- wiqar 5y agoHi, I'm Wiqar, product manager for Wasmer. We would love to hear more about your application and use case. Is the app in production?
- cylon13 5y agoThe game using Wasmer is currently fairly early in development, but we have a few games in production built using various technologies, with the most recent one that I worked on done entirely in typescript. Both this previous game and the upcoming game are fast-paced action games. As much as I enjoy typescript, there are lots of annoying things that crop up in game dev in particular with regards to memory management, such as needing to pool instances of small classes, etc, so I figured it's time to switch to rust+wasm since the ecosystem seems mature enough now for it and Rust is a joy to program in. The architecture of the games are such that the main game logic runs both on the client and the server. The server runs the logic to provide the authoritative game state and send it out to all the clients, and the clients run the logic to predict where they're going to be immediately after you press an input to compensate for the network latency. Since the client is predicting what will happen using the same code paths, the game logic need to be completely deterministic so that it desynchronizes from the server as little as possible. With the TS/JS game we essentially just hope that running the same JS bundle in node and any client browser produces the same results for all the collision/gameplay math, and it seems to luckily not cause us any problems. For the game in rust though, compiled and optimized native rust floating point math would drift from our client webassembly builds surprisingly quickly, so we decided to pack all the shared logic in to a wasm bundle that gets loaded on both the server and the client, and we're using Wasmer to do that :) The Wasmer API is super ergonomic and it's been a pleasure to work with. I think the only thing that would make our lives better that I can think of is being able to ignore imports and have them auto-bind to noop functions or functions that immediately return zero in the case of non-void imports. Since we're using the same wasm bundle for the client and server, there's a bunch of client-only rendering bindings that we just ignore and never call from the server-only and shared wasm code in the bundle, and currently we're using a hacky script that uses wasm-objdump to generate a rust module with a bunch of noops in imports!{}.
- zzyzxd 5y ago> Can't wait to try it? Go ahead! > curl https://get.wasmer.io https://get.wasmer.io -sSfL | sh No, thanks. I looked at the docs and running this shell script from internet is the only mentioned installation method. Then I took a look at the script, it only supports bash, zsh and fish and will try to inject stuff in my shell config, add a new executable directory, and download and run an executable without even verify file checksum
- syrusakbary 5y agoThere are also more ways to install Wasmer! You can use cargo (it will compile from source): cargo install wasmer-cli --features singlepass,cranelift Or a package manager: brew install wasmer You can check all available methods here. Hope this helps! https://github.com/wasmerio/wasmer-install#install-via-package-manager https://github.com/wasmerio/wasmer-install#install-via-packa...
- zzyzxd 5y agoI am sure there are many ways to install it securely. But why aren't any of them mentioned in the documentation? Besides searching the entire github organization, how can people discover these alternative installation methods?
- syrusakbary 5y agoWe showcase them already on the main repo (see other installation options): https://github.com/wasmerio/wasmer#install https://github.com/wasmerio/wasmer#install Do you think it will be useful to be showcased more prominently somewhere else?
- zzyzxd 5y agoAh, I did miss this section when I was browsing the main repo, it is kinda difficult to spot, especially since the section is collapsed by default. However, I was mainly talking about the documentation site, because documentation is always my first stop when exploring a new project. The README real estate on github is limited, but on the documentation site you have a whole page dedicated to describing how to install it, so I would love to see some installation methods there that are safer than blindly executing a random script from internet.
- puohufgh 5y agoQuick question about Wasmer and C programming: can I use Wasmer to compile a simple Hello World C program only once and then run this program on all supported architectures like I can use Cordova with Javascript to do the same? Quickly exploring the wasmer-c-api examples just now[1], this does not appear to be the case: I get the impression one must write a bunch of high-friction boilerplate code to load/unload/configure/run wasm in order to do a simple hello world program. I have recently converted from being a C programmer to a Javascript programmer because I just can't deal with complicated C build systems and cross-compiling anymore: CMake, Gradle, etc. I spend more time trying to get a dependency to compile and learning the CMake language than I do actually solving my problem. People say "Electron is cancer" but at least I can get Cordova quickly working to ship an app for Windows/Mac/Linux/Android/iOS. I'd love to go back to lightweight, fast C programs though if I had the option. I tried using SDL2 but many of the examples will run fine on one platform but then fail to run on a different platform (say iOS or Android) and as a lone indie dev I don't have the time to investigate such issues. (I tried and managed to fix a few broken builds, but grew frustrated and gave up.) Cordova with Javascript so far is the only thing I've tried that just works for universal cross-platform dev. [1] https://github.com/wasmerio/wasmer-c-api https://github.com/wasmerio/wasmer-c-api
- jedisct1 5y agoThe easiest way to compile C code to WebAssembly is by using Zig (https://ziglang.org https://ziglang.org): zig cc -target=wasm32-wasi and you’re done. Nothing else to install. It is equally easy to cross-compile to another platform, against without installing anything else.
- puohufgh 5y agoThanks! I see that Zig is much more than just a programming language then; it has its own C compiler that addresses much of the toil of cross compiling C code.
- Hywan 5y agoThe wasmer-c-api lands in https://github.com/wasmerio/wasmer/tree/master/lib/c-api https://github.com/wasmerio/wasmer/tree/master/lib/c-api, with the documentation being accessible at https://wasmerio.github.io/wasmer/crates/wasmer_c_api/index.html https://wasmerio.github.io/wasmer/crates/wasmer_c_api/index.... :-).