Lots of TODOs I'm going to wrap up in separate work and tickets, but as I'm about on parental leave with my 1yo, I'm just getting it all here to kick us off:
Work
Implementations:
sync: Synchronous code on main event loop
jest-worker: Uses jest-worker
Scenarios
react: Render random attributed react components in a tight loop for repeat number of times
Benchmark: benchmark runner with md results. I've provided a key, but I'm measuring both "time to complete the task" (W time) and "amount of progress in main event loop with 1ms timer" (M loops).
Results
Good news
Using jest-worker makes overall time less with the main event loop doing more using child_process
Medium news
The degree of speedup didn't seem linear for number of CPUs for jest-worker. I think we may need more analysis here.
Bad news
Node12 worker threads don't work yet, with this unfun error:
$ node benchmark/runner/index.js
.ERROR DataCloneError: (a, b) =>
a.slice(0, 10) === b.slice(0, 10) && a.length === b.length could not be cloned.
at Worker.postMessage (internal/worker.js:223:23)
at ExperimentalWorker.send (/Users/rye/scm/fmd/ssr-experiments/node_modules/jest-worker/build/workers/NodeThreadsWorker.js:265:18)
at WorkerPool.send (/Users/rye/scm/fmd/ssr-experiments/node_modules/jest-worker/build/WorkerPool.js:32:34)
at Farm._process (/Users/rye/scm/fmd/ssr-experiments/node_modules/jest-worker/build/Farm.js:129:10)
at Farm._enqueue (/Users/rye/scm/fmd/ssr-experiments/node_modules/jest-worker/build/Farm.js:152:10)
at Farm._push (/Users/rye/scm/fmd/ssr-experiments/node_modules/jest-worker/build/Farm.js:159:12)
at /Users/rye/scm/fmd/ssr-experiments/node_modules/jest-worker/build/Farm.js:90:14
at new Promise (<anonymous>)
at Farm.doWork (/Users/rye/scm/fmd/ssr-experiments/node_modules/jest-worker/build/Farm.js:56:12)
at JestWorker._callFunctionWithArgs (/Users/rye/scm/fmd/ssr-experiments/node_modules/jest-worker/build/index.js:162:23)
Lots of
TODO
s I'm going to wrap up in separate work and tickets, but as I'm about on parental leave with my 1yo, I'm just getting it all here to kick us off:Work
sync
: Synchronous code on main event loopjest-worker
: Usesjest-worker
react
: Render random attributed react components in a tight loop forrepeat
number of timesW time
) and "amount of progress in main event loop with 1ms timer" (M loops
).Results
Good news
jest-worker
makes overall time less with the main event loop doing more using child_processMedium news
Bad news
/cc @kevinmstephens