Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tniessen opened this issue Apr 25, 2020 · 4 comments
Closed

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

tniessen opened this issue Apr 25, 2020 · 4 comments
Labels
libuv Issues and PRs related to the libuv dependency or the uv binding. linux Issues and PRs related to the Linux platform. os Issues and PRs related to the os subsystem.

Comments

@tniessen
Copy link
Member

tniessen commented Apr 25, 2020

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.

@tniessen tniessen added os Issues and PRs related to the os subsystem. linux Issues and PRs related to the Linux platform. labels Apr 25, 2020
@bnoordhuis
Copy link
Member

That was actually fixed just three days ago, see libuv/libuv@37a8aff. :-)

@tniessen
Copy link
Member Author

@bnoordhuis Oh, nice! That explains it :D Any idea when that patch might make it into a Node.js release?

@tniessen tniessen added the libuv Issues and PRs related to the libuv dependency or the uv binding. label Apr 25, 2020
@bnoordhuis
Copy link
Member

Probably sometime in May. The last libuv release was just last week.

@jasnell
Copy link
Member

jasnell commented Jun 19, 2020

I believe this has been resolved in master

@jasnell jasnell closed this as completed Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libuv Issues and PRs related to the libuv dependency or the uv binding. linux Issues and PRs related to the Linux platform. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants