The code-size budget fits your processor, and code that has gone cold makes room for code that is hot now
Floati's code-size budget, new in the last release, used a fixed size for each kind of processor. It now reads your processor's cache sizes when it starts and sizes itself to them (the last-level cache shared by its cores), so a laptop with a small cache and a desktop with a large one each get their own budget. On the two machines we test on it chose exactly the sizes we had measured best by hand. Compiled code that has gone cold is now freed when the budget is full and warmer code needs the room, the way a long-lived web app moves from one screen to the next. A page whose hot set of functions changes in phases ran 514 -> 459 ms and 883 -> 801 ms, with half the compiled code kept in memory. A self-adjusting budget that grows and shrinks from measured time was tried as well and is not included: the timings it would steer by vary more than the gain it could find.
A budget that fits the machine, and keeps what is hot
The budget compiles a function only while its machine code would still be in the processor's cache when the function runs again. The right size depends on the cache, and caches differ: an Apple M-series performance cluster shares 16 MB between four cores, a laptop x86-64 chip often 8 MB. Floati reads the cache hierarchy from the operating system at startup (on macOS, Windows and Linux) and uses each core's share of the last-level cache, kept between 1 and 8 MB. When the budget is full, a function that keeps running can now claim the space of code that has not run for a long time, measured against how often the newcomer runs. Freed code is removed safely: a call already running it finishes first, and every compiled call that pointed at it is redirected. A function that comes back is compiled again, and two groups of functions cannot keep evicting each other back and forth. The design follows the published work on sizing code caches to a program's working set, and on how other engines flush cold compiled code.
What changed 3 changes
Try it in your browser
Each check runs live in the browser you are reading with. Nothing is sent anywhere.