Skip to content

perf: reduce ESM wrapper allocations - #285

Draft
BridgeAR wants to merge 5 commits into
BridgeAR/2026-08-28-iitm-esml-v3-basefrom
BridgeAR/2026-08-27-iitm-esml-v3
Draft

perf: reduce ESM wrapper allocations#285
BridgeAR wants to merge 5 commits into
BridgeAR/2026-08-28-iitm-esml-v3-basefrom
BridgeAR/2026-08-27-iitm-esml-v3

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

String-based star setters forced the wrapper to build recursive namespace registries and eager deduplication state. Structured binding records allocate conflict state only when a second origin appears.

This also keeps repeated paths to one binding unambiguous and preserves explicit null or undefined module.exports values.

On Node 24.20.0 with V8 13.6.233.17-node.53, lazy target tracking took 9.31 to 9.38 ns/op in two fresh runs. Eager Set allocation took 27.97 to 30.12 ns/op on the same one-to-three-target workload.

The sync-hook suite found no reproducible end-to-end regression across small, large, TypeScript, star-reexport, and real dependency workloads.

String-based star setters forced the wrapper to build recursive namespace registries and eager deduplication state. Structured binding records allocate conflict state only when a second origin appears.

This also keeps repeated paths to one binding unambiguous and preserves explicit null or undefined module.exports values.

On Node 24.20.0 with V8 13.6.233.17-node.53, lazy target tracking took 9.31 to 9.38 ns/op in two fresh runs. Eager Set allocation took 27.97 to 30.12 ns/op on the same one-to-three-target workload.
On Node 24.20.0 / V8 13.6.233.17-node.53, a uniform 0/1/2/4/16-export workload improved from 91.86–93.87 to 79.07–80.98 ns/op.

Each fresh run used seven trials and dropped the fastest and slowest results.
Real timer scheduling made the retry assertion depend on CI timing instead of the retry state transition.
Application output stays correct when wrapper generation falls back, so output-only assertions could not detect skipped hooks.
@BridgeAR
BridgeAR force-pushed the BridgeAR/2026-08-27-iitm-esml-v3 branch from 607feb7 to 9cbf99e Compare September 7, 2026 11:40
On the 0/1/2/4/16-export workload, removing the copy improved
Node 22.23.1 from 142.69-144.52 ns/op to 92.76-96.27 ns/op.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants