bytecodealliance/jco

Investigate synchronous-worker

Closed this issue · 1 comments

There is another approach to worker threads we might be able to utilize in Node.js - https://github.com/addaleax/synchronous-worker, which is a node native binding for creating a separate event loop in the same process, which is able to be independently managed allowing two separate task queues.

It could be worth running some experiments to see if this is actually faster.

Ideally it would be nice to have support for other JS runtimes like Deno and Bun by using the worker threads library, then conditionally flip into the synchronous-worker mode with Node.js native bindings when supported for faster IO in Node.js itself.

I'm posting this here as an interesting direction to explore when performance efforts come up for this project. Effectively extending our worker handler to swap in the more efficient implementation as necessary, while still retaining compat might be a nice story, but it needs to be explored and prototyped to determine if this will be possible.

After further consideration, a dedicated IO thread is definitely what we want here in Node.js.