Skip to content

CPU time passes 10x faster than real time on a single core #33054

Closed
@tniessen

Description

@tniessen

What steps will reproduce the bug?

const { cpus } = require('os');
const measure = () => cpus().map(c => c.times.idle);
const diff = (first, second) => second.map((v, i) => v - first[i]);
setTimeout(((first) => () => console.log(diff(first, measure())))(measure()), 1000);

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

Within 1000ms, each core cannot spend more than (approximately) 1000ms idle.

What do you see instead?

[
  10200, 10200,
  10100, 10200,
  10000, 10000,
   9900, 10000
]

Additional information

I cannot reproduce the problem on Windows, so I assumed it's a problem in libuv, but the code in libuv seems correct to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    libuvIssues and PRs related to the libuv dependency or the uv binding.linuxIssues and PRs related to the Linux platform.osIssues and PRs related to the os subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions