Prevent renderer hot functions being inlined by minifiers

perf: prevent renderer hot functions being inlined by minifiers
Prevent renderer hot functions being inlined by minifiersperfprevent renderer hot functions being inlined

Committed by yyx990803

commit message
perf: prevent renderer hot functions being inlined by minifiers

Terser will aggressively inline hot functions in renderer.ts in order
to reduce "function" declarations, but the inlining leads to performance
overhead (small, but noticeable in benchmarks).
 
Since we cannot control user's minifier options, we have to avoid the
deopt in the source code by using arrow functions in hot paths.

Editor assessment

The subject `perf: prevent renderer hot functions being inlined by minifiers` states the optimisation, and the body explains the why and the trade-off: Terser's aggressive inlining of hot functions in `renderer.ts` adds measurable benchmark overhead, and since user minifier settings cannot be controlled the source itself switches hot paths to arrow functions to avoid the deopt. There is no scope, acceptable for a cross-cutting performance change, and no breaking signal is needed. Style is clean and imperative. The reasoning about an uncontrollable external tool makes this a genuinely instructive, exemplar-level message.

Browse categories

More perf examples · Back to search