Skip to content

fix(perf_hooks): globalThis.performance === the named import (#1327)#1443

Merged
proggeramlug merged 1 commit into
mainfrom
fix/perf-identity-1327
May 22, 2026
Merged

fix(perf_hooks): globalThis.performance === the named import (#1327)#1443
proggeramlug merged 1 commit into
mainfrom
fix/perf-identity-1327

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

Node guarantees globalThis.performance === require('perf_hooks').performance (node:perf_hooks gap #1327, umbrella #793). In Perry the named import resolved to a fresh perf_hooks namespace per read, and globalThis.performance was a separate (unpopulated) path — so identity never held and globalThis.performance.now was undefined.

Fix introduces a single source of truth:

  • runtime (perf_hooks.rs): a per-thread cached performance namespace singleton (performance_namespace()), GC-rooted in scan_perf_entries_roots_mut so identity survives evacuation.
  • named import (native_module.rs): perf_hooks.performance returns the singleton (constants stays a fresh namespace).
  • global (global_this.rs): populate_global_this_builtins binds globalThis.performance to the same singleton.
  • codegen (helpers.rs): performance joins is_global_this_builtin_name so globalThis.performance value-reads route to the global field, and the function-name exclusion keeps typeof === "object".

Test

Flips test-parity/node-suite/perf_hooks/global/performance-identity to PASS:

same object: true
global now is fn: function

Regression sweep (all clean / pre-existing-only): perf_hooks node-suite (56 pass), global filter (3 pass), test_gap cross-section (36 pass; the 1 fail is the pre-existing tracked test_gap_class_advanced static-block gap). Every parity test prints via the global console, exercising global init.

Closes #1327.

…on) (#1327)

Node guarantees globalThis.performance === require('perf_hooks').performance.
Perry resolved the named import to a fresh perf_hooks namespace per read and
the global was a separate (empty) path, so identity never held and
globalThis.performance.now was undefined.

Add a per-thread cached performance namespace singleton (perf_hooks.rs,
GC-rooted via scan_perf_entries_roots_mut). The node:perf_hooks named import
returns it; populate_global_this_builtins binds globalThis.performance to the
same object; codegen routes globalThis.performance reads through the global
field (is_global_this_builtin_name) while keeping typeof === "object". Flips
node-suite/perf_hooks/global/performance-identity to PASS.
@proggeramlug proggeramlug merged commit e668137 into main May 22, 2026
23 of 25 checks passed
@proggeramlug proggeramlug deleted the fix/perf-identity-1327 branch May 22, 2026 23:53
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.

node:perf_hooks — globalThis.performance is not identical to the node:perf_hooks named import

1 participant