Right now I’m working on a project that needs maximum performance. I am just doing pure computations over a tree, but doing it sequentially is hardly spiking my CPU. I’d like to process branches in parallel to speed things up. What is the recommended approach here?
If you mean specifically in a JavaScript-based runtime, there are no great answers. JavaScript’s execution model is fixed to a single thread. It only has logical process forking through isolated workers, which has serialization overhead. I wrote purescript-node-workerbees
to make this somewhat convenient on a node
backend, but it’s no longer particular convenient since switching to node modules due to limitations in how node handles ES modules. I think this might have changed in node nightly, however.
For shared memory multi-threading, maybe look at the chez scheme backend, but I don’t know if there is any ecosystem to help with that. I don’t know of any other maintained backend that supports shared memory multi-threading.
Wow, I didn’t realize JS’s support for this was so poor. I’ll check out the chez sheme backend, thanks.