Fix mangler benchmarks and speed up the mangler #11347
Labels
A-minifier
Area - Minifier
C-performance
Category - Solution not expected to change functional behavior, only performance
E-Help Wanted
Experience level - For the experienced collaborators
Uh oh!
There was an error while loading. Please reload this page.
The mangler benchmarks are extremely noisy, often reporting +/- 15% perf differences on PRs which don't touch the mangler at all. The
mangler[cal.com.tsx]
benchmark is the worst offender, but other mangler benchmarks are also displaying a lot of variance.Presumably the source of this variance is unpredictable patterns of allocation.
The mangler already uses an
Allocator
internally for storing some temporary data. I suggest we try to put more of the temporaryVec
s andHashMap
s used in the mangler into this arena too. That should make the pattern of allocations more deterministic, and so reduce the variance in benchmarks. I would hope it may also be a performance gain, as it'll reduce allocations overall.One note: When storing data in an arena, it becomes much more important to accurately predict upfront how large a
Vec
/HashMap
is going to get, and reserve sufficient capacity when creating theVec
/HashMap
.Reserving sufficient capacity upfront is always a gain, because growing these structures is an expensive operation, especially if they're large. But when the
Vec
/HashMap
is stored in an arena, it becomes even more important. WhenVec
/HashMap
is stored on general heap, sometimes the OS can grow the allocation in place (very cheap), or resize it by altering the page table (somewhat cheap). But when theVec
/HashMap
is in an arena, neither of these is an option, and growth always results in creating a new allocation and copying all the data from the old allocation to the new one (very expensive).The text was updated successfully, but these errors were encountered: