#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::Crafting Interpreters::Ch 30 Optimization
#columns:Front	Back	Tags
Crafting Interpreters ch 30, Optimization: what does it cover?	Profiling and optimization: replacing modulo with bit masking in the hash table, then NaN boxing to pack every Lox value into 64 bits, with benchmarks showing the speedup.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::30 cracked.guide::kind::about
Crafting Interpreters ch 30, Optimization: why does it matter?	Measuring before optimizing is the most important performance habit. NaN boxing is used in real engines like LuaJIT and some JavaScript engines.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::30 cracked.guide::kind::why
Crafting Interpreters ch 30, Optimization: which part of the book is it in?	clox (bytecode VM, C)	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::30 cracked.guide::kind::part
NaN boxing: what is it?	NaN boxing is a value representation that stores non-number values such as pointers, booleans and nil inside the spare bits of IEEE 754 double-precision NaN values, so that every value fits in 64 bits.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::30 cracked.guide::kind::definition
NaN boxing: Is NaN boxing portable?	Mostly, on 64-bit systems where pointers use 48 bits or so. It assumes IEEE 754 doubles and a pointer layout that fits, so it is a deliberate trade of portability for speed.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::30 cracked.guide::kind::definition
Crafting Interpreters ch 30: what traps should you watch for?	<ul><li>NaN boxing assumes 64-bit pointers fit in 48 bits; this is true on mainstream platforms today.</li><li>Optimizing without benchmarks.</li></ul>	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::30 cracked.guide::kind::traps
Crafting Interpreters ch 30: which end-of-chapter challenges are worth your time?	Challenge 1 (find and fix another hotspot with a profiler) is the most valuable. Challenge 2 (small string optimization) is a nice C exercise. Challenge 3 asks you to reflect on the book; actually write it down.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::30 cracked.guide::kind::challenges
Crafting Interpreters ch 30, Optimization: how should you work through it?	Use a real profiler (perf, Instruments or VTune) on the benchmarks. Keep NaN boxing behind the compile-time flag the book uses so you can switch back to debug.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::30 cracked.guide::kind::approach
