How I Made Immer Twice As Fast Performance Optimization In Practice - Mark Erikson
summary
Walks through concrete changes that make Immer measurably faster: reproducible Mitata benchmarks across versions, Node CPU profiles captured with pprof flame charts, Rollup-built production artifacts, and line-by-line hotspots that reveal wasted work. Small fixes (caching constructor checks, skipping Object.isFrozen on primitives) yield ~20% gains; an architectural cleanup and an optional array override plugin add further speedups; overall scenarios improve 5–79% (roughly ~40% average) and fixes ship as Immer 10.2, 11.0 and 11.1.
AI-written summary · about
chapters (20)
- 0:00Introduction and speaker background
- 1:07What is performance optimization
- 3:12What is Immer and why optimize it
- 5:39Starting the Immer optimization project
- 6:02Principles of debugging and performance
- 10:12Tools for debugging and profiling
- 12:43Setting up benchmarks for Immer
- 14:07Capturing CPU profiling data
- 16:10Understanding flame charts and graphs
- 19:04Initial findings and benchmark fixes
- 20:28Root causes of Immer's slowness
- 22:12Architectural changes to Immer
- 22:54Optimizing array access performance
- 24:19Final performance improvements
- 25:25Advanced optimizations and V8 insights
- 27:32Lessons learned from the project
- 28:55Performance degrades over time
- 29:18Replay's time-traveling debugger demo
- 30:41New React performance tools in Replay
- 31:01Summary and further resources
