Module 17 · Performance, Memory, Debugging and the Interview Output Puzzles
Under the Hood: V8's Compilers, Hidden Classes and the Garbage Collector
ProReading
Zara has a strange measurement. She times the same function twenty times in a row, and the first time is several times slower than the rest. Then she builds two lists of objects with the same data, and summing one is slower than summing the other. Nothing in her code explains either result.
Checking what this lesson needs for you…
What is inside Under the Hood: V8's Compilers, Hidden Classes and the Garbage Collector
- Four tiers: why code gets faster as it runs
- Optimised code rests on guesses
- Hidden classes: an object's shape
- Inline caches: one shape is fast
- Packed and holey arrays
- The garbage collector: what is reachable stays
- Young and old space
- A leak is a reference you forgot
- WeakMap and WeakRef
- The lab: what does a small object cost?