spike-js / spike

Blazingly Stable :zap:
MIT License
8 stars 1 forks source link

Spike compiler parallelization #29

Open chrisdmacrae opened 3 years ago

chrisdmacrae commented 3 years ago

Struggle/Problem

Javascript is single threaded. This means spike will be relatively slow compared to other tools. However, we all have multi-core computers that can do the same type of work in parallel if they're independent. Let's make use of this.

Solution

Once we complete #16, we can compute the dependencies for any node and walk the graph bottom up, doing independent operations in parallel.

This will, for some workflows, offer anywhere from a 2x-8x speed increase based on the devices number of CPU cores.

We'll do this using node workers. On smaller sites, this won't offer an advantage and may even slow things down, because sending information between workers has a cost and for smaller sites, may cancel out the benefits of parallelization.

What we'll need to do is benchmark the logic with workers and without workers to figure out what threshold workers start adding value at.

Risks and Rabbit Holes

Appetite

6-12 hours.

Note