Performance regression in v12 caused by primordials
I have heard about performance regressions caused by transition to primordials in v12, but couldn't find a tracking issue for the regression, so opening this to make sure we are tracking it and can work with the upstream to get this handled, on way or another (feel free to close this if there is already an issue opened here).
The regressions seem to come from two types of code patterns:
- Calling functions through
Function.prototype.{call, apply}instead of just calling them directly. There is an issue opened in the upstream by @bmeck
https://bugs.chromium.org/p/v8/issues/detail?id=9702 - Looking up properties from fronzen objects - objects from our
primordialsnamespace are frozen so lookups likeconst { Reflect } = primordials; Reflect.apply(...);is slower than justReflect.applywhenReflectcomes from the global object. This can be mitigated by caching the lookup results upfront, e.g. event: improve performance of EventEmitter.emit #29633 by @mcollina There is also a fairly odd tracking issue for this in the upstream: https://bugs.chromium.org/p/v8/issues/detail?id=6831
cc @MylesBorins (https://twitter.com/MylesBorins/status/1173390304742785024)