5 ms·
Since JS is already quite fast nowadays, how much faster will WASM typically be? (Yes, I know, it depends. I'm just looking for a rough estimate.)
by amelius 10y ago
Since JS is already quite fast nowadays, how much faster will WASM typically be?
(Yes, I know, it depends. I'm just looking for a rough estimate.)
- Dangeranger 10y agoTo start Mozilla has stated it can be up to 10% faster, but compiler optimizations will improve on that over the next few years. One big benefit will be being able to compile from an array of languages down to WebAssembly and maintain performance.
- shakna 10y agoOne of the small things that may impact speed greatly, is that WASM has a real integer type, it isn't a float like JS has. Some benchmarking has been talked about before [0], the upshot being C->WASM has a slowdown around 16-25ms. That's a hell of a lot faster than JS in a lot of places. Unfortunately, as soon as you hook into the HTML APIs, like giving JS a result, you're back to JS speeds. [0] https://news.ycombinator.com/item?id=13604537 https://news.ycombinator.com/item?id=13604537
- vvanders 10y agoFor cache aware code anywhere from 10-50x if trends hold from what you see in native code.
- agumonkey 10y agoMaybe ram usage decrease and lower GC pressure ?
- sova 10y agoNative
- adrianN 10y agoDoes that mean Webscale? edit: /s
- gadders 10y agoLike MongoDB?
- sova 10y agoWebscale? I don't know, and I am really unclear as to why people are already writing about webASM, there is hardly an agreed-upon standard so far. In my professional opinion as a Computational Scientist, I believe a LISP-like graphically-enabled DSL for the Web that worked simply and easily with: Web Forms, Graph Query for endpoints, and had a sensible GUI layering would be perfect for the next 200 years of screen. I think that the issue comes in when people call it WebASM. ASM had different aims in 1960 than in 2017. In 1960 ASM was about minimizing register overlap and utilizing max CPU efficiency reels. Now, you have no idea what hardware your Web-whatever is going to run on, so how could you possibly optimize for CPU? The only real optimization would be optimizing software-engineer/developer attention+visualization and that would only come with an incredibly elegant breakdown of what screens need for a coder to be happy long into the future. If there were some easy way for manufacturers to add "component" definitions for hardware devices, perhaps WebASM could become something amazing. However, the name ASM is likely to throw off too many would-be devs. At any rate, it's not meant to be assembly for the web, it's meant to be skeletal scaffolding for your amazing, native apps. Why else even bother.
- sqeaky 10y agoI think you have a different framing of the problem most people excited about WASM have. It is not about talking directly to the hardware, just getting speed gain like you are. So this component idea seems to be coming from out of the blue and indicates to me you haven't paid webassembly much attention until now. Getting a bytecode that works more like common real machines will be a real performance boon. It doesn't need to match perfectly, it just needs to be similar enough, minimalistic and better than what we have now. The 'simple enough' part makes translation to native machine code easy enough and the minimal makes it easy for standards adoption. As for beating what we have now, you should read the article, because right now its javascript or nothing at all, and anything even vaguely more like a real machine can be optimized better than javascript. Also, currently Chrome and Firefox support it. Currently Edge and Safari both support it in preview versions of the browsers. I am not sure where you are coming when you say "there is hardly an agreed-upon standard so far" because the four largest browser manufacturers have agreed enough to have 4 different working products or demos. Perhaps you could expand on that to let me know what you or if your information might have been old.
- throwasehasdwi 10y agoThe generalish difference between JS and native code languages like C is about 10X. This varies from around 2X to 50X depending highly on what you're doing. WASM should run at native speeds minus some special CPU instructions like vector stuff. So about as fast as highly optimized bytecode languages like Java, maybe 20% slower than optimized C.
- sp332 10y agoAnd vector stuff (SIMD) is being planned. https://hacks.mozilla.org/2017/02/where-is-webassembly-now-and-whats-next/ https://hacks.mozilla.org/2017/02/where-is-webassembly-now-a... Edit: an even longer list of proposed features. http://webassembly.org/docs/future-features/ http://webassembly.org/docs/future-features/
- sehugg 10y agoAs an anecdote: I had been running a Z80 emulator on my website (http://8bitworkshop.com http://8bitworkshop.com) and I began to notice persistent 30-second delays on Firefox. It was difficult to track down, but I suspected the Z80 interpreter which had a gigantic switch statement. The optimizer must have been choking on it. After refactoring each opcode handler into separate functions, it now runs with several subsecond delays on startup (as the various code paths are discovered and optimized, I suppose) and with no delays after a minute or so. WebAssembly won't have this problem (neither does asm.js, but that's a different story...)
- deleted 10y ago[deleted]
- aardvark179 10y agoWell, possibly no faster than can currently be achieved by asm.js if the JIT likes you, but I think discussions of raw speed miss the point. 1. Parsing text based JS is much slower than parsing something like WASM. 2. Initialising data required for programs can take significant time in JS as that data is just a program that must be parsed and run. 3. Those first two points, along with better type support should help things get fast quicker, as the parser and JIT have less work to do. 4. In general JS comes with a lot of baggage that it's extremely hard to get rid of at this point, in many ways it's not really a great foundation to build other things on. Now, WASM seems to provide a pretty good basis for building many things low level things on, but less useful for higher level languages which might want garbage collection or other facilities. I hope we'll end up with a successor or an evolution of it being the primary thing browsers interact with and JS simply being a language supported on it.
- amelius 10y ago> WASM seems to provide a pretty good basis for building many things low level things on, but less useful for higher level languages which might want garbage collection Would it be possible to implement a garbage collector in WASM? And could it be a concurrent garbage collector, using advanced techniques such as memory barriers? It would be cool if we could run e.g. Haskell or Go in WASM. Or even C programs which rely on the Boehm collector.
- krallja 10y agoSure, why not implement a GC? There's a heap. You don't need much else.
- petters 10y agoI am running an integer programming solver in the browser with wasm: https://www.strandmark.net/wasm/glpk.html https://www.strandmark.net/wasm/glpk.html Its single-threaded performance is essentially native, but I don't have the numbers.