~/talk

A Fastify Tale of Shapes

Talkat OpenJS World 2022 · 2022-06-06..06-10· [javascript, nodejs]
slides:none on file

A bug in Fastify v3 makes request/reply objects become megamorphic because plugin encapsulation creates a new object.create prototype chain for every registration, producing different V8 shapes and forcing deoptimizations. Fixes: eagerly add decorator properties on construction and avoid creating new prototypes unless a decorator is actually used, so objects keep identical hidden classes. The change yields about 10% throughput improvement in Fastify v4 and is verifiable with V8 optimization flags.

AI-written summary · about

  1. 0:00Introduction
  2. 1:39Fastify Overview
  3. 2:35Request Lifecycle & Plugins
  4. 5:03V8 and the Event Loop
  5. 6:22Optimization Compilers
  6. 9:05Object Shapes and Hidden Classes
  7. 11:58The Bug and Debugging
  8. 13:46Initial Fix Attempt
  9. 17:08Encapsulation Issues
  10. 20:21The Final Fix
  11. 21:48Q&A and Best Practices
~/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.