7 ms·
Firefox really benefits from WebASM: the time per frame is ~90ms on my machine whereas the JS version is close to 400ms or so. On the other hand, on Chrome the
by Sharlin 9y ago
Firefox really benefits from WebASM: the time per frame is ~90ms on my machine whereas the JS version is close to 400ms or so.
On the other hand, on Chrome the WebASM performance is ~100ms and JS is just a tiny bit slower at around 120ms!
- malloryerik 9y agoFirefox Quantum?
- Sharlin 9y agoYep, v57.
- Tuna-Fish 9y agoThe first phase of Quantum made styling and layout faster than any browser. The next phase will make rendering faster than anything else. The JS engine is still the old one. (Maybe it's time will come third?)
- azdle 9y agoMozilla people have been working on SpiderMonkey performance already: https://jandemooij.nl/blog/2017/12/06/some-spidermonkey-optimizations-in-firefox-quantum/ https://jandemooij.nl/blog/2017/12/06/some-spidermonkey-opti..., it's just not some wholesale replacement, so it probably never makes the top of the list for what they shout about. It also sounds like it has been a steady progression rather than a big jump, so maybe not quite as noticeable.
- amelius 9y agoPerhaps it was written for Chrome specifically (?)
- Klathmon 9y agoThat's a really interesting observation on so many levels! Firefox (or rather SpiderMonkey) seems to really be focusing on WebASM performance, and it's easy to forget just how goddamn fast V8 has made JavaScript...
- jsheard 9y agoIt's worth noting that this isn't idiomatic Javascript though, the author is jumping through hoops to avoid ever triggering the garbage collector. Javascript can be very fast if you go down that route but the code gets extremely ugly.
- Klathmon 9y agoIsn't most "fast path" code in a GCd language written like this? I've jumped through similar hoops in Go, and even C++ to avoid allocation or GC. The fact that a dynamic language like JavaScript can compile and execute as fast as it does is nothing short of incredible! Even if it's not idiomatic, it's still far from "unreadable".
- pjmlp 9y agoNot if the language supports a mix of value types, off heap allocations or untraced references. There are a few like that.
- imtringued 9y agoCan you name them?
- pjmlp 9y agoYes, surely. - Eiffel - Oberon family (Oberon, Oberon-2, Active Oberon, Component Pascal, Oberon-07) - Mesa/Cedar - Modula-3 - D - Nim - C# (specially now with 7.2 improvements) - Go - Swift (RC is also a form of GC algorithm) These are just the most well known ones, there are others if you feel like having a dive into SIGPLAN papers. I can also provide examples, how to do it in any of them, if you wish.
- rcfox 9y agoWhat do you consider jumping through hoops? The code looked pretty normal to me.
- JepZ 9y agoBtw. similar numbers are available on the projects github page: https://github.com/sniklaus/experiment-raytracer https://github.com/sniklaus/experiment-raytracer
- BillinghamJ 9y agoGetting 60ms on Safari on macOS for WebASM. The other three don't seem to work though.
- clouddrover 9y agoThe Shader version doesn't work for me in Safari 11.0.1 but the other three did work. I found that I couldn't run any of the others after I had tried the Shader version. I reloaded the page and then I could select between the JavaScript, asm.js, and WebAssembly versions without issue.
- renchap 9y agoThe Shader version needs WebGL 2.0, and works with the latest Safari Technology Preview
- WhitneyLand 9y agoBut would adding antialiasing kill the performance? It’s a small thing, but it’s kind of like a movie where you can totally suspend disbelief and one bad actor or effect jolts you out it.
- Sharlin 9y agoWell, sure, but so would rendering at a more reasonable resolution, or a more realistic scene than five spheres on a plane. And it's not like 10fps is a useful frame rate in the first place. But it's the relative, not absolute, performance figures that are interesting here.
- bartread 9y ago> And it's not like 10fps is a useful frame rate in the first place. How times have changed. I remember running flight sims back in the 16-bit era (Amiga 500, for example) when 10fps would have been considered pretty good, especially if there was a lot going on. But yes, I think nowadays you're right: 60fps or bust. And this is really why ray-tracing isn't used that much in games - it's just so computationally expensive.
- benjamin-fl 9y agoFor ray tracing like this, going the supersampled antialiasing route is pretty much equivalent to rendering the scene at higher resolutions. For example, to get 4 samples per pixel, you need to render at double the resolution in both directions, or 4 times the number of pixels. Of course, techniques like FXAA which are commonly used in rasterization based realtime rendering are possible as well, and would have much lower performance impact. Another thing to think about is that in any monte carlo based rendering algorithm, such as what would be used to render modern movie graphics, antialiasing is basically free. These algorithms already work by running thousands upon thousands of samples per pixel, so distributing these samples inside each pixel has almost no performance impact.
- ajross 9y agoAlternatively, it's pretty amazing that a nearly pure FPU task with small data that should live well in cache is only about 5x slower when written in straightforward JavaScript. This is the kind of code that in previous generations would have expected to see a 20-100x penalty in perl or python.
- heavenlyblue 9y agoAs previous threads have already mentioned: that is not straightforward JavaScript. There’s nothing impressive about stripping down a scripting language by making it’s structure exactly the same as c in the end. What’s the point of JavaScript in the first place? What we had done is we took a microscope and then made sure it’s made of toughened glass and the strengthened steel so that we could nail a few nails with it.