Named imports fix V8 inlining: OTel JS Tracer gets ~2x throughput

DanielLockyer · x · 2026-11-18

Daniel Lockyer's merged PR #7355 in open-telemetry-js: Tracer.ts used import as api, which in the CommonJS build compiles to a toESM helper wrapping every export in a getter backed by a bound function — V8 can't inline it, so every api.context.active() / api.trace.getSpan() call in startSpan was a real function call.

CPU profiling showed the toESM getter alone took 9.4% of samples in a bare tracer.startSpan('op').end() (require-loaded), with startSpan self time at 39.7%; loading the same build with import cut self time to 11.4% and roughly doubled throughput. Switching to named imports removes the overhead.

Original post →

More from Infra

Infra channel →