17 ms·
Google Sheets ported its calculation worker from JavaScript to WasmGC
- royjacobs 2y agoIt's great to see Java Web Start finally being used in anger 24 years after its initial release.
- xnx 2y agoI'm familiar with applets, but hadn't heard of Java Web Start. Could Java Web Start interact with the DOM?
- p_l 2y agoNot really, Java Web Start essentially provided a way to download a fully-capable Java application running on normal JVM, from a click on website. It's been used in place of applets a lot, but mostly because you could provide a complex application that opened in a new window with a click (assuming you dealt with the CA shenanigans). It couldn't interact with DOM unless it accessed a browser over something like COM.
- jtotheh 2y agoI worked on an app that was using Java Web Start still, as of January 2023. It was a problem, because JWS was not included in the parts of Java that were open-sourced, and was not available as part of recent OpenJDK versions of Java. Some open source JWS implementations exist, when I left that job though, the situation had still not been resolved in terms of finding a JWS replacement. It was imperative that we get off Oracle Java because of their expensive upcoming licensing changes. I wonder what ever happened..........
- yuri91 2y agoIt's now possible to run Java Web Start applications fully in the browser without any plugins: https://cheerpj.com/cheerpj-jnlp-runner/ https://cheerpj.com/cheerpj-jnlp-runner/ It's based on CheerpJ, a JVM that runs in the browser (using JS and Wasm).
- deleted 2y ago[deleted]
- hankman86 2y agoJava Web Start always seemed like a lazy approach to bring legacy desktop apps into the web. Something you would associate with enterprise software, where end user experience apparently does not matter. I remember lengthy downloads of jar files, where eventually, some desktop window using very 1990s-looking Swing widgets would pop out. Not to mention that you needed to download a JRE (don’t remember if this was automatic on first launch). Even in the heydays of Java, desktop applications were never all that great. I remember how painfully slow Eclipse ran. And when I tried the WebStorm IDE a few years back, all the same problems still existed re memory management and some pronounced latency pressing a key and having the character appear on screen. WebStorm was also infamous for its code indexing runs, which pretty much froze my computer for a number of minutes. Not sure if that’s a Java problem though. People criticise Electron, but honestly: applications like Slack, Spotify and VS Code run much better than the Java-based desktop apps that I got to use.
- AshleysBrain 2y agoThis is a bit of a tangent but it always annoys me when content has no published date next to it. There's a tiny "last updated" date at the bottom. But how do we know if this is a new article or one from a few years back? With technology moving so fast it can significantly change the context in which you read an article.
- phatfish 2y agoYes this does seems to be more common. What are basically blog posts with no date to be found at all, at least this has a "last updated". I can only assume "old" pages are down-ranked more by Google than those with no date at all. Maybe the content date is in a metadata tag somewhere, I've not bothered to check yet. But if it is why not make it visible on the page as well?
- ComputerGuru 2y agoYes, we had to remove the publication date from our archives because Google was heavily down ranking it. We left an “updated” date but are probably going to remove that as well. I fought hard against this until it became clear there really was no other option.
- Evidlo 2y agoGenerate the date dynamically client side so it can't be parsed. Or use an image/svg
- ComputerGuru 2y agoClient side JS is absolutely no impediment to Google’s web crawler but using an image or svg might work!
- Evidlo 2y agoRelated: https://spencermortensen.com/articles/email-obfuscation/#text-display https://spencermortensen.com/articles/email-obfuscation/#tex...
- sirjaz 2y agoMaybe they can finally make Google Sheets, etc... off-line stand alone app.
- tantalor 2y agoWork on Google Docs, Sheets, & Slides offline https://support.google.com/docs/answer/6388102?hl=en https://support.google.com/docs/answer/6388102?hl=en
- deleted 2y ago[deleted]
- makeitdouble 2y ago> You must use the Google Chrome or Microsoft Edge browser. Thanks Google. PS: I think it's basically ancient wisdom at this point to keep a Chrome instance around to best handle most Google properties, but I don't remember seeing it much spelled out in official documentation.
- sirjaz 2y agoI wish Google wouldn't force us to use chrome. Hell they have Google Play for games on Windows, they could just offer the complete app store this way and get a close to native app.
- IncreasePosts 2y agoHow much effort should Google put into supporting browsers that don't have the feature sets to support the use case?
- wing-_-nuts 2y agoDepends, are the serious about avoiding antitrust cases?
- sbarre 2y ago
- markdog12 2y agoMaybe I'm missing it, but it says it was originally twice as slow as JS, than it says they did optimizations, then no comparison on the final outcome?
- tjlav5 2y agoAh same thought exactly
- giovannibonetti 2y agoMaybe the numbers didn't look very good and they thought it was better to leave them out
- ksec 2y agoBut then what is the point telling us they are doing it with WASM now? Seems more like a KPI - Work Progress report. Edit: In a different blog post : https://workspace.google.com/blog/sheets/new-innovations-in-google-sheets https://workspace.google.com/blog/sheets/new-innovations-in-... "Building on improvements like smooth scrolling and expanded cell limits in Sheets, today we’re announcing that we’ve doubled the speed of calculation in Sheets on Google Chrome and Microsoft Edge browsers,"... I dont use Google Sheet but I wonder how far apart are their new implementation compared to Native Microsoft Excel.
- cm2187 2y agoI don't know if native excel should be the benchmark. It seems to me that it has been ever slower over excel versions.
- PaulHoule 2y agoOne trouble with Excel is that it does an awful lot of different things but doesn’t do them well. If you try do use it to do what Pandas does it is shocking how small of a data file will break it. The idea of incremental calculation of formulas that don’t need to be put in a particular order is still genius but the grid is so Apple ][. Maybe the world doesn’t know it because it spurned XBRL but accounting is fundamentally hyper dimensional (sales of items > $100 in the afternoon on the third week of February in stores in neighborhoods that have > 20% black people broken down but department…) not 2-d or 3-d. Having the wrong data structures is another form of “garbage in garbage out”. I have though many times about Excel-killers, trouble is they have to be something new, different and probably specialized, people know how to get answers with Excel even if they are wrong, plus Excel is bundled with the less offensive Word and Powerpoint so a lot of people are paying for it either way. Personally I want a spreadsheet that does decimal math even if there is no hardware support except on mainframes: I think a lot of people see 0.1 + 0.2 |= 0.3 and decide computers aren’t for them.
- Vt71fcAqt7 2y agoThey forgot to mention the final speedup: >The initial version of Sheets Wasm showed calculation performance roughly two times slower than JavaScript. >[...] >Implementing speculative inlining and devirtualization—two very common optimizations—sped up calculation time by roughly 40% in Chrome. So the only numbers we get are 2x slowdown and the 1.4x speedup, which makes it sound like it's still slower. I'm sure thats probably not the case but it is a strange way to write an article advertising wasm. Also, I'm a bit confused about which language this was actually written in before the wasm switch. Was it always written in Java and transpiled to JS? It doesn't seem that way from the article: >Removing JavaScript-specific coding patterns. >they had a core data structure in Sheets which was blurring the lines between arrays and maps. This is efficient in JavaScript which doesn't make sense if they were writing it in Java and transpiling to JS. Was it transpiled to JS only once in 2013 and then developed in JS from there? In which case why go back to Java?
- davexunit 2y agoMy understanding is that Sheets was and remains written in Java. I interpreted "JS-specific coding patterns" to mean that they were writing some of their Java code in a particular way to please the compiler so that it generated more efficient JS.
- Vt71fcAqt7 2y agoOk, That makes sense. Now that I think of it if they switched to JS they probably would have rewritten it by hand instead of using a tool like J2CL.
- tjlav5 2y agoIt’s perhaps telling that they had an initial prototype which was 2x slower, then talk about specific optimization strategies but never share the updated overall speed comparison.
- bluk 2y agoIn a different blog: https://workspace.google.com/blog/sheets/new-innovations-in-google-sheets https://workspace.google.com/blog/sheets/new-innovations-in-... "Building on improvements like smooth scrolling and expanded cell limits in Sheets, today we’re announcing that we’ve doubled the speed of calculation in Sheets on Google Chrome and Microsoft Edge browsers,"... I assume this is 2x the speed of their current JavaScript code.
- azakai 2y agoYes, that is correct. It began 2x slower than JS, and ended up 2x faster than JS.
- notRobot 2y agoI'm sorry I'm bad with translating numbers. This means originally the new version ran at half the speed of the JS version, but ended up running at double the speed? Pretty cool.
- azakai 2y agoYeah, exactly. The initial prototype turned out to be quite slow - a lot of optimizations are needed to be fast. The version as of now is 4x faster than that initial prototype, and 2x faster than the JS version. And we are working to make it even faster. The good news is that most of those optimizations weren't specific to Java, like work in V8 (that helps any Chromium-based-browser running WasmGC) and work in Binaryen (that helps any Binaryen-using toolchain, like Kotlin and Dart).
- azakai 2y ago(The post has since been updated to clarify that. Yeah, it was a little confusing before.)
- davexunit 2y agoNice to hear from teams building with Wasm GC. They bring up the "shared everything" proposal [0] for enabling heap objects to be shared across the threads. In addition to this, I'd like to be able to share the contents of a packed array, such as a (ref (array i8)), with the host. Right now, only Wasm memory objects have ArrayBuffer access in JS. Providing the same shared access to packed GC arrays would unlock things like WebGL, WebGPU, and Web Audio for Wasm GC applications. I made a "hello triangle" WebGL program with Wasm GC awhile back, but there's no way that I know of to get acceptable throughput when working with GPU buffers because they have to be copied byte-by-byte at the Wasm/JS boundary. [0] https://github.com/WebAssembly/shared-everything-threads/blob/main/proposals/shared-everything-threads/Overview.md https://github.com/WebAssembly/shared-everything-threads/blo...
- hollowturtle 2y agoThey also mention that “there are cases where browser APIs are backed by optimized native implementations that are difficult to compete with using Wasm … the team saw nearly a 100 times speedup of regular expression operations when switching from re2j to the RegExp browser API in Chrome” if so how they call RegExp from WasmGC or viceversa? 100 times speedup for native web apis is not something you can ignore, that’s the important lesson here, not everything compiled to wasm will result in a speed again
- hollowturtle 2y agoperhaps we should have more optimized web apis to use? maybe for creating optimized data structures with strong typing? Not just the typed arrays types, but also typed maps
- 01HNNWZ0MV43FF 2y agoYou can call from wasm back into js, I believe some webgl games do that
- danielvaughn 2y agoYep it's a bi-directional communication layer. You can even have shared memory.
- hansvm 2y agoI'd be really curious to see the same benchmark applied to re2j on a native jvm, contrasted with those same optimized chrome internals. 100x is in the right ballpark for just a core algorithmic difference (e.g., worst-case linear instead of exponential but with a big constant factor), VM overhead (excessive boxing, virtual function calls for single-op workloads, ...), or questionable serialization choices masking the benchmarking (getting the data into and out of WASM).
- michaelothomas 2y agoThe difference is primarily algorithmic. Java on WasmGC is about 2x slower than Java on the JVM. The remaining 50x is just Chrome's regex impl being awesome.
- davidmurdoch 2y agoI still long for a world where we got ASM.js and SIMD directly in JavaScript.
- KeplerBoy 2y agoWhile we're at it, let's have CUDA.js and let me map CUDA objects to WebGL Texture and Vertex Buffers. So many cool visualization to be built.
- 01HNNWZ0MV43FF 2y agoIt's got Urbit energy
- __s 2y agoyou can still use ASM.js it's just a coding convention
- davidmurdoch 2y agoNo it's not just a convention. It was also an optimization compiler.
- hankman86 2y agoSome JavaScript engines used to (or maybe still do) detect asm.js compliant code and then AOT-compiled it into machine instructions. You could theoretically write asm.js code by hand. But that would have been error prone and laborious. For all intents and purposes, one would transpile a native code base into asm.js using the likes of Emscripten. There used to be a SIMD.js proposal, which was AFAIK abandoned in favor of WebAssembly SIMD. Google’s proprietary Native Client also added limited SIMD support as its last hooray. I personally think the way to go is to improve the interoperability between JavaScript and WebAssembly instead of continuing to pursue low-level pattern like asm.js and SIMD in JavaScript. And let’s face it. For any larger code base, JavaScript is a mere deployment format, not the language you code your project in. I am still hoping for a future version of Typescript that can compile into WebAssembly.
- 2y ago
- ZuLuuuuuu 2y agoAs somebody who is not familiar with how garbage collection is implemented at the low level, can somebody explain why WasmGC is needed on top of Wasm? For example, isn't CPython a C program and hence can just be compiled to Wasm, including its garbage collection part? Does garbage collection usually depend on OS specific calls, which are not part of C standard?
- fellowmartian 2y agoWasmGC allows you to reuse the native V8 garbage collector instead of having to bundle and run a virtualized garbage collector.
- seanw444 2y agoIs Wasm performance that far off of native that the difference between bundled GC and native GC is noticeable?
- davexunit 2y agoThere are several problems with bringing your own GC. Some that come to mind: * Significantly increased binary size * No easy way to trace heap objects shared amongst many modules * Efficient GC needs parallelism, currently limited in Wasm For a more thorough explanation, see https://wingolog.org/archives/2023/03/20/a-world-to-win-webassembly-for-the-rest-of-us https://wingolog.org/archives/2023/03/20/a-world-to-win-weba...
- mdhb 2y agoI think it’s also that the V8 garbage collector already has a stupidly high bar when it comes to optimizations that shipping your own even without any consideration to WASM performance would be a step backwards for most languages running on the web.
- sethaurus 2y agoPerformance is less of a concern than binary size. Without WasmGC, you need to ship a compiled garbage collector to the user along with every WASM module written in a GC'd language. That's a lot of wasted bandwidth to duplicate built-in functionality, so avoiding it is a big win! And performance will always be a bit better with a native GC, plus you can share its scheduling with the rest of the browser process.
- dgb23 2y agoI didn't know WasmGC was a thing yet! https://developer.chrome.com/blog/wasmgc/ https://developer.chrome.com/blog/wasmgc/ Some things that are at first glance surprising is that GC'ed languages might ship a smaller binary, because they don't need to include the code that manages memory. (The example here was Java.) When WasmGC is widely adopted, we might hopefully see some languages adopting it as a target instead of JS. I'm thinking of Clojure and Dart specifically but there are plenty of other languages that might benefit here. This could also have an impact on "edge computing" (isolates etc.) down the line.
- mdhb 2y agoAs someone who jumps back and forth between Dart and Typescript fairly regularly I can’t tell you how quickly and enthusiastically I’m planning on moving more and more of my stuff to Dart. It’s a huge quality of life improvement overnight.
- alexhutcheson 2y agoDo you use Flutter Web, or some other framework for web UI?
- davexunit 2y agoI work on a Scheme to Wasm GC compiler called Hoot. https://spritely.institute/hoot/ https://spritely.institute/hoot/ Languages like Kotlin, Scala, and OCaml also target Wasm GC now.
- dgb23 2y agoThis is an extremely cool project, thank you for sharing! Edit: I'm not familiar with scheme/guile (only dabbled with Racket and later Clojure). Are these real bytes that behave like actual bytes when you manipulate their bits (unlike Java etc.) and are stored as actual bytes? https://www.gnu.org/software/guile/manual/html_node/Bytevectors.html https://www.gnu.org/software/guile/manual/html_node/Bytevect...
- 2y ago
- londons_explore 2y agoAnyone here actually bothered by the speed of the core calculation engine of Google sheets? I'm bothered by the sluggishness of the UI, but I've never typed '=A1+A2' in a box and found it takes too long to get an answer. Even if it did, I'd kinda like million row X million column sheets to somehow be server side and my machine simply views a local window, and calculations happen locally if feasible with locally available data, or server side otherwise.
- victorbojica 2y agoProbably not bothered because it's fast thanks to this work. I'd probably be bothered if it was slow.
- dartos 2y agoWould you pay for that?
- londons_explore 2y agoNo - all web apps should be designed with the idea that the client only has a little CPU, ram and storage, and if the user tries to do something outside those capabilities, the server should do the work. Nobody expects a Google search to involve the client crawling the whole web and picking out your search keywords...
- dylan604 2y agoHow is that an answer to the question? Your explanation shows how the service is pretty much doing everything which seems to justify why a paid service would be acceptable. If they provided free code but your had to pay the expense of running it locally would be more of a justifiable reason for not finding a need for paying.
- Closi 2y agoI don't have experience with Google Sheets, but it's definitely an issue in Excel with complex sheets. It's more of an issue when you have a few 100k lines and lots of layers of different lookups etc.
- shaky-carrousel 2y ago[flagged]
- CivBase 2y agoHas Firefox announced any intentions to not support WASM? From what I can tell there is a bug with the current implementation, but I have a hard time believing that had anything to do with Google's decision. If that's what they wanted, it'd be a lot easier to just check the user agent. Most people aren't savy enough to fake their user agent.
- capitainenemo 2y agoFirefox supports WASM. The GC spec though is very much a work in progress. https://bugzilla.mozilla.org/show_bug.cgi?id=1774825 https://bugzilla.mozilla.org/show_bug.cgi?id=1774825 Eyeballing that list it looks like they have a lot to do yet.
- azakai 2y agoWasmGC has recently been completed in Firefox, the feature tracking page says since Firefox 120: https://webassembly.org/features/ https://webassembly.org/features/ (hover over the cell for Firefox and Garbage collection). The Firefox people have also been very active in WasmGC's development.
- davexunit 2y agoWasm GC works great in Firefox. It's Safari/WebKit that need to catch up! It's been over 6 months since Chrome and Firefox enabled Wasm GC in stable releases and we're still waiting for Safari.
- capitainenemo 2y agoAh. My mistake. I saw a ton of open issues.
- tsujp 2y agoI'll need to look into this but if anyone knows: is this available (easily) as a standalone package somewhere; think using the engine from a CLI without needing or contacting Google Sheets at all.
- murkle 2y agoWhen will Safari have WasmGC?
- filleokus 2y agoAFAIK I think Igalia is/was working on WasmGC support for Webkit/Javascript Core [0]. Not sure about the status though, it's tracked here I think [1]. It says it's updated earlier this month, but don't know of the progress made. [0]: https://docs.webkit.org/Other/Contributor%20Meetings/Slides2023/wasm-gc-webkit-contrib-meeting.pdf https://docs.webkit.org/Other/Contributor%20Meetings/Slides2... [1]: https://bugs.webkit.org/show_bug.cgi?id=247394 https://bugs.webkit.org/show_bug.cgi?id=247394
- murkle 2y agoOh, https://bugs.webkit.org/show_bug.cgi?id=272004 https://bugs.webkit.org/show_bug.cgi?id=272004 looks promising "All Wasm GC features are implemented, and the feature can be enabled once typed funcrefs (https://bugs.webkit.org/show_bug.cgi?id=272003 https://bugs.webkit.org/show_bug.cgi?id=272003) are enabled"
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- macspoofing 2y agoGoogle finally got NaCL/Pepper into the browser.
- hankman86 2y agoIt’s in maintenance mode. They may still support it for legacy Chrome apps (Chrome OS) and manifest-2 browser extensions. For the “drive by” open web, they had an origin trial for a while that you could register for and which would throw your PNaCl apps a “lifeline”. But for all intents and purposes, WebAssembly is now on par (and beyond) what Portable Native Client supported. Some things were easier in PNaCl - threading support comes to mind.
- whoomp12342 2y agoWhy is javascript slower than java? uhhhh I don't think there is actually a real answer in that paragraph that compares PERFORMANCE of JS to JAVA. that explanation is completely unhinged?
- michaelothomas 2y agoI mean, I thought it was a pretty good explanation. JavaScript plays fast and loose with types. Which means that when JIT compilers generate code for it, they have to make all sorts of conservative decisions. This makes generated code more complex and, in turn, slower. Does that make sense?
- boutell 2y agoWith infinite effort, a company with infinite resources made something that is already objectively fast enough twice as fast! They are right though that wasmgc might have a bigger impact than wasm alone. Lots of attention is deservedly paid to Rust but people use garbage collected languages more.
- adrianmonk 2y agoFrom the article, it seems like the big picture is that Google wants to move WasmGC forward. They got the Workspace/Sheets and Chrome/V8 teams together to start with Sheets "as an ideal testbed". Presumably they think this investment will pay off in various ways like ensuring Chrome has a good implementation of WasmGC and building expertise and tools for using WasmGC in other Google products.
- paulddraper 2y ago> objectively fast enough I would not mind a perf boost.
- pjmlp 2y agoI love how we are slowly back to Applets and related plugins. WebGL | WebGPU + WasmGC => Flash!
- bongwater_OS 2y agois this why all my gsheets scripts started failing out of nowhere today
- hankman86 2y agoIt is not entirely clear from the article, but apparently, they still use Java for their calculation engine. And then transpile it into JavaScript. Which makes me wonder whether instead of porting this code base to WasmGC, a partial rewrite would have helped the project’s maintain ability in the long run. Rust seems like a potentially good candidate due to its existing WebAssembly backend. WasmGC is useful for many other projects of course. But I wonder how painful it is to maintain a Java code base, which is not a great choice for client-side web apps to begin with. I remember using GWT back in the days - and that never felt like a good fit. GWT supported a whitelisted subset of the Java standard library. But the emitted Javascript code was nigh on impossible read. I don’t remember if Chrome’s developer tools already had source map support back in those days. But I doubt it. Other core Java concepts like class loaders are equally unsuited for JavaScript. Not to mention that primitive data types are different in Java and JavaScript. The same is true for collections, where many popular Java classes do not have direct counterparts in JavaScript.
- jsiepkes 2y agoThe code wasn't really ported to WasmGC. They now compile the same code base to WasmGC with J2CL where before they used J2CL to transpile it to JavaScript.
- szundi 2y agoSomehow Java is the ultimate always the best stuff to do something even transpiled. Java is easy to build upon on the long run and can save itself and the codebase to new times.
- azakai 2y agoRewriting a large codebase with many years of work behind it to a totally new language is a pretty big task, and often ends up introducing new bugs. But I do agree Java has downsides. A more practical conversion would be to Kotlin. That's a much closer language to Java, and it can interop, which means you can rewrite it incrementally, like adopting TypeScript in a JavaScript project. Also, Kotlin uses WasmGC, which avoids the downsides of linear memory - it can use the browser's memory management instead of shipping its own, etc., which is an improvement over C++ and Rust.
- bahmboo 2y agoThis is the kind of cool cutting edge web development that google excels at. Hopefully there are some down stream effects that help more tools move to the web. Good work!
- owenpalmer 2y agohaha, "excels"
- zengid 2y agoWasmGC: Revenge of the JVM
- zengid 2y agoThis is really cool, I wonder what .NET to wasmGC would be like.
- sixothree 2y agoDo you mean in relation to Blazor? C#, F#, and VB already compile to wasm. They have their own GC.
- bbor 2y agoSlightly off topic, but since the GenAI push google has started investing heavily into its devtools again, namely Sheets and Colab. Either that or these teams are just that good! If you haven't checked out the recent "Tables" update to Sheets, I highly recommend it -- probably the most meaningful improvement in years.
- khana 2y ago[dead]
- devit 2y agoHow about writing it properly in an efficient language that doesn't use a GC? (i.e. Rust or something equivalent)
- surajrmal 2y agoOther comments mentioned this wasn't a rewrite. This was legacy java code which simply changed toolchains from compiling to JavaScript to wasmgc instead.
- bhl 2y agoIt seems this is not a full rewrite of the calculation engine, so it’s hard to compare the performance of JavaScript against WASM. Has anyone rewritten a performant calculation in that way from JavaScript to WASM? I’m curious to what the performant gap is, and whether browser optimizations are closing or widening that gap.
- cxr 2y ago> they had a core data structure in Sheets which was blurring the lines between arrays and maps. This is efficient in JavaScript, which automatically models sparse arrays as maps, but slow on other platforms. So they had to rewrite the code in a more platform-agnostic way. This is another thing the team like about WebAssembly: it makes it easier for multiplatform applications to get good performance on the web. You don't have to bend your whole application to the idiosyncrasies of JavaScript. Uh, that's a terrible example. It's not an example of anyone forced to "bend their whole application to the idiosyncrasies of JS" at all. It's almost the opposite Someone wrote the code they wanted to write, whether in good taste or not, and the JS runtimes that the product was tested on handled it efficiently (to their credit!); i.e., the authors of those JS runtimes had to bend their implementations to accommodate the idiosyncrasies of people who were/are writing code like that.