os.cpus().length performance on modern AMD CPUs inside containers
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
v24.14.0
Platform
- Bare metal machine
- Host: Linux Ubuntu 24
- Container Image: `node:alpine-24`
- CPU: `AMD EPYC 4584PX 16-Core Processor`
Subsystem
os
What steps will reproduce the bug?
Firstly, I'm not entirely sure if this is a bug, so apologies if this is known or in the wrong spot - it just feels like something that shouldn't be this slow vs other platforms. I couldn't find any other real references to this other than a discussion at https://github.com/nodejs/performance/issues/93 which mentions this being slow.
With a modern AMD CPU such as the one listed above, run the following with Docker:
docker run --rm node:24-alpine node -e "console.time('cpus'); os.cpus().length; console.timeEnd('cpus')"
I've also attached an strace output for reference. It seems to iterate over /sys/devices/system/cpu/cpuN/cpufreq/scaling_cur_freq, some of which can take 20ms to return.
How often does it reproduce? Is there a required condition?
This requires a modern AMD CPU, with Linux, and run within a container. Otherwise it seems to happen almost 100% of the time in our testing.
What is the expected behavior? Why is that the expected behavior?
I would expect it to return much more quickly as it does on Intel systems.
What do you see instead?
cpus: 649.982ms
regularly >500ms runtime on a machine with 32 cores.
Additional information
No response
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 reproduciendo el comando de Docker del issue en la configuración AMD/Linux indicada y revisa el strace.log adjunto. Sigue la ruta de os.cpus() que lee scaling_cur_freq y luego compara el comportamiento con sistemas Intel; se considera terminado cuando la llamada medida es sustancialmente más rápida sin cambiar su resultado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- docker, javascript, linux, node.js
- Área
- operating-systems, performance
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100