A Journey into Node.js Internals
summary
Node.js is not single threaded the event loop is single threaded while the platform uses a libuv worker thread pool implemented as a queue and several explicit event-loop phases. Synchronous crypto hashes cost about 4000 CPU ticks → 130 CPU ticks when converted to async. A heterogeneous array insertion shows 900ms vs 12ms compared with a homogeneous one, demonstrating JIT assumptions and deoptimization. Generational GC uses scavenge and mark sweep, GC pauses are real, and heap snapshots via --inspect reveal listener-driven memory leaks.
AI-written summary · about
chapters (28)
- 0:00Intro
- 1:02Tamar Twena-Stern
- 2:57Traditional Approach - Blocking 10
- 4:19Problems
- 5:43Node.js Architecture - High Level
- 10:21Is Worker Thread Pool Implemented With A Queue ?
- 11:15Event Loop Implemented With A Queue ?
- 12:32The Event Loop Thread Deep Dive
- 14:13Timers Phase
- 15:241/0 Callback Phase (Error)
- 16:08Poll Phase - Most Importent
- 17:41Check Phase And Close Phase
- 25:42V8 Engine
- 26:12V8 Architecture
- 27:14What Is Just-In-Time Compilation ?
- 27:55JIT Compiler In Java
- 29:01Ignition Interpreter
- 29:24Turbofan Compiler - JIT
- 29:35How To Help Turbofan Optimise Hot Code?
- 36:21Optimisation And De-optimisation
- 37:17V8 Memory Management
- 38:11V8 Memory Structure
- 38:40The Stack And The Heap
- 39:46The Heap Structure
- 40:24Object Life On The Heap
- 40:50Heap New Space - Scavenge Scan
- 41:51Heap Old Space - Mark Sweep Demonstration
- 42:17Mark Sweep - DFS
related talks
49mA Journey into Node.js Internals
35mNodeJS: from single thread to worker threads
41mDissecting NodeJS - How it works under the hood
28mBryan Hughes - SeattleJS Conference 2017
45mAsk the Maintainer: Nodejs
39mThe event loop fairytale
13mConcurrency vs Parallelism in Node.js: Understanding the Event Loop & Worker Threads
23mDecomposition of the Main Thread in Node.js to increase throughput
