performance.now() should jump after sleep/suspend/hibernation
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
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:
function timeDelta() {
// The delta should be approximately the same on each invocation (assuming the system time is unchanged).
return Date.now() - performance.now();
};
const ref = timeDelta();
const before = timeDelta();
Now suspend and resume the machine / VM through whatever means. Then continue in the same node session:
const after = timeDelta();
console.log('BEFORE:', ref - before, 'AFTER:', ref - after);
Observe that the after value is incorrectly missing a number of seconds that matches the time the system was suspended. Eg. from my run:
BEFORE: -0.410888671875
AFTER: -7346.271728515625
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 https://github.com/w3c/hr-time/issues/115.
The https://github.com/mdn/content/issues/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 https://github.com/libuv/libuv/issues/1674.
Additional information
The current performance.now() implementation is based on process.hrtime():
This issue also seems to contain a lot of relevant context around a concrete problem: https://github.com/open-telemetry/opentelemetry-js/issues/852.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con lib/internal/perf/utils.js y la implementación de perf_hooks, que actualmente basa performance.now() en process.hrtime(). Ejecuta la sesión interactiva de Node del informe alrededor de una suspensión o reanudación del sistema. Se considera terminado cuando performance.now() avanza en Linux en una cantidad equivalente al tiempo transcurrido durante la suspensión, manteniendo al mismo tiempo el comportamiento esperado de timeDelta.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, linux, node.js
- Área
- performance
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 52/100