Practical Optimization for V8
summary
Explains V8’s two-stage compilation (fast full codegen then Crankshaft optimizing) and gives concrete, measured fixes: initializing a loop counter cuts a 100M-iteration loop from ~7s to 3.6s; creating objects with a constructor is ~10x faster than adding properties afterward; closures were ~10x slower on old V8 (0.86s vs ~0.086s) but are inlined in modern V8/Node 11+. Recommends initialize variables, use constructors and set properties in them, and favor monomorphic functions to avoid deopt and slow inline caches.
AI-written summary · about
chapters (10)
- 0:00Introduction and setup
- 2:14Goals of optimization
- 5:00V8 compilation process
- 10:44Hidden classes in V8
- 15:18Allocation and reallocation costs
- 17:03Uninitialized variables impact
- 18:29Object initialization best practices
- 20:40Key optimization principles
- 21:26Function inlining in V8
- 24:52Understanding compiler optimizations
related talks
33mJavaScript: The V8 Engine optimization tips (...)
24mDemystifying V8 and JavaScript Performance
22mHigh Performance JS in V8
23mJoin the super secret V8 club & become a JavaScriptbender
28mPerformance Profiling for V8
17mV8 engine, JS Code Interpretation, and Execution
39mAlgorithms in the Front End: from V8 to VDOM
29mJavaScript Engines: How Do They Even?
