Skip to content

instanceof per-value-kind receiver resolution costs +32.6% on constructor-shaped allocation (#10478/#10479 follow-up) #10602

Description

@proggeramlug

Follow-up to #10478 / #10479, fixed in PR #10592, which resolves an instanceof receiver per value kind
instead of assuming a heap pointer. That fixed real segfaults — instanceof crashed on 1-, 3- and 5-byte
inline strings (taking down ajv, and with it every fastify schema route) and Object.create(proto).constructor
returned a bogus value (crashing lodash's isEqual). The cost lands on constructor-shaped object allocation.

Measurement (from PR #10592, re-measured on a fresh host, not carried over from the pre-loss run)

fixture instructions
bench_ctor_o.ts +32.6%
bench_prim.ts −5.7%

The +32.6% closely matches the +32.5% the original (lost) run recorded, so it reproduces across two
independent measurements on different hosts.

Attribution — it is NOT the EventEmitter subclass work in the same PR

bench_ctor_o never calls instanceof and never touches EventEmitter. The subclass-delegation change
shipped in the same PR was measured separately: +1.8% on a direct-EventEmitter-instance check, and a
63.9% reduction on mixed direct+subclass traffic (a subclass instance no longer burns through every
fallback probe on a guaranteed miss). The +32.6% belongs to the per-value-kind receiver resolution.

Why there is no honest "before" to compare against

The pre-fix binary segfaults on the inputs this path now handles correctly. There is no same-work
baseline; the old speed came from a fast path that was wrong. Only fix-vs-Node is meaningful.

Where to look

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package-auditFound by the 2026 package audit: compiling real npm packages from source instead of native bindingsperformanceRuntime, compile-time, build-size, or memory performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions