Graphite icon indicating copy to clipboard operation
Graphite copied to clipboard

Restructure JS <-> Wasm communication flow and adopt parallelism

Open Keavon opened this issue 1 year ago • 3 comments

Right now, JS calls into Wasm, then that calls back into JS again, and that might call back into Wasm, and so on. It does that within the same call stack, so the call stack gets deeper and deeper ping-ponging between the two languages.

We want to flatten this out and build a queue system so either side can queue up tasks. One side processes its queue while building up a queue for the other side, then when done, it switches to the other side and works through its queue on that side, building up tasks for the other side to complete, then it switches again when the queue is done.

We also want to utilize web workers wherever possible to get everything but the DOM manipulations off the main thread, and also benefit where possible from parallelism.

Keavon avatar Apr 11 '23 22:04 Keavon

The backend rust code already queues up a list of FrontendMessages. With the javascript, it is not clear how to queue up a list of messages.

0HyperCube avatar Apr 14 '23 07:04 0HyperCube

I guess we could just queue them up in the wasm wrapper and send them to the backend running in a separate thread using a channel.

On 23/04/14 12:14, 0HyperCube wrote:

The backend rust code already queues up a list of FrontendMessages. With the javascript, it is not clear how to queue up a list of messages.

-- Reply to this email directly or view it on GitHub: https://github.com/GraphiteEditor/Graphite/issues/1113#issuecomment-1508038992 You are receiving this because you were assigned.

Message ID: @.***>

TrueDoctor avatar Apr 14 '23 08:04 TrueDoctor

I think the first part of this issue is basically implemented. The only thing left to do is to actually use multi threading on the web

TrueDoctor avatar Jan 11 '24 00:01 TrueDoctor