Proposed investigation: move filter calculation to WASM #104
KaliedaRik
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal
Currently, all SC calculation happens in the JS main thread, which has clear (and annoying) disadvantages and dangers for the web page hosting an SC canvas. Thus there is a clear need to move the most compute-intensive calculations out of the main thread.
This has been attempted before: prior to SC
v8.4.0
filter calculations were handled in a Web Worker. That approach however led to an Async Hell and a Cascade of Promises so, forv8.4.0
, the entire approach/functionality associated with filters in SC was rewritten from scratch - including the abandonment of the Web Worker (which ironically led to faster canvas execution).WebAssembly is a (relatively) new language which can run in the browser:
It makes sense to investigate whether we could port the SC filters code over to WebAssembly, with the aim of making the filter functionality and output significantly faster.
For this investigation, I propose we look at porting the code over to the Zig language, which supports building for WebAssembly out of the box.
Risks
There are no risks involved with this investigation. Anything that leads to moving high cost code off the JS main thread, without damaging the library's current speed, has to be a win!
Also, if Zig doesn't work out, there's other languages we can try.
Way forward
Beta Was this translation helpful? Give feedback.
All reactions