-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
performance.now() should jump after sleep/suspend/hibernation #47724
Copy link
Copy link
Open
Labels
perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.Issues and PRs related to the perf_hooks module and performance measurement APIs.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
Activity
Metadata
Metadata
Assignees
Labels
perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.Issues and PRs related to the perf_hooks module and performance measurement APIs.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Version
v18.14.2
Platform
Linux qubit 5.15.108-0-lts #1-Alpine SMP Fri, 21 Apr 2023 05:55:14 +0000 x86_64 GNU/Linux
Subsystem
perf_hooks
What steps will reproduce the bug?
In an interactive node session run:
Now suspend and resume the machine / VM through whatever means. Then continue in the same node session:
Observe that the
aftervalue is incorrectly missing a number of seconds that matches the time the system was suspended. Eg. from my run:How often does it reproduce? Is there a required condition?
100% (on Linux)
What is the expected behavior? Why is that the expected behavior?
performance.now()is expected to jump with the realtime passed time while suspended according to the spec and w3c/hr-time#115.The mdn/content#4713 issue also goes into detail on how the "Ticking During Sleep" applies to various platforms.
What do you see instead?
No jump during sleep. Eg. by using more suitable clock reference, as proposed implemented in libuv/libuv#1674.
Additional information
The current
performance.now()implementation is based onprocess.hrtime():node/lib/internal/perf/utils.js
Lines 13 to 16 in 2ac5e98
This issue also seems to contain a lot of relevant context around a concrete problem: open-telemetry/opentelemetry-js#852.