~/talk

NodeJS: from single thread to worker threads

Talkat Node.js Global Summit 2020 · on Saturday, 2020-05-30· [nodejs]
slides:none on file

Covers why CPU work blocks Node’s single-threaded event loop and compares hacks: breaking work with setImmediate, spawning processes with child_process/cluster, and true threads via worker_threads. Shows API details: worker_threads stable in Node 12, options like workerData/env/eval/resourceLimits, message ports vs cloning (cloning 10MB of nested objects can cost ~47ms in one benchmark), transferable ArrayBuffer and sharedArrayBuffer + Atomics for synchronized shared memory, and a concrete four-worker pool Sudoku solver that reuses threads and returns results to the main server.

AI-written summary · about

  1. 0:00Start
  2. 3:55Golden Rule Don't block the event loop
  3. 4:35Running CPU Intensive tasks
  4. 5:52Offloading Child Process Cluster
  5. 11:57What makes Worker Threads special
  6. 16:12MessageChannel async two-way communication channel between threads
  7. 31:13Recommendation • Use worker thread pools • Do not use them for parallelizing I/O
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.