FAQ

On Dec 7, 2014, at 11:37 PM, // ravi wrote:
On Dec 7, 2014, at 11:06 PM, // ravi wrote:


I am stumped by what must clearly be a misreading on my part. Node 0.10 docs say that each element of os.cpus() contains information about each CPU/core. This information includes "the number of milliseconds the CPU/core spent in: user, nice, sys, idle, and irq” (the docs do not say milliseconds of what, but I assume it means milliseconds since the system was last started). Note that this used to be, in v0.8 (and I assume before), reported in CPU ticks, but seems to have switched to milliseconds for v0.10.

Now for the puzzle: say I do this:

console.log(os.cpus()[0].times.idle);
setTimeout(function() { console.log(os.cpus()[0].times.idle); }, 2000);

The output I see is:

39035126800
39035144500

Assuming that ordering of CPUs/cores is consistent in the array returned by os.cpus(), it’s not clear how to square the above with the docs. The difference between the times reported is 17700ms i.e., CPU 0 was idle for 17 seconds in the 2 seconds between the two calls!

One thing to consider is if os.cpus() returns CPU usage information from /proc/stats. If so, two things could affect the above (more likely the second):

(1) the first line of /proc/stats in GNU/Linux reports the totals across CPUs.
(2) these numbers seem to be in “jiffies” or 1/100th of a second (USER_HZ).

Time to start digging into the ‘os’ module sources, I guess, though I think Ockham’s Razor continues to point at me.

Digging done :-). More info here: https://github.com/joyent/node/issues/8835. It’s possible this will need a fix in the ‘os’ module. I have suggested the outline of such a fix, if needed, in the Issue.

  —ravi


--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/90D54FAC-3753-4813-ABFA-DB17A3D6981E%40g8o.net.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 6 | next ›
Discussion Overview
groupnodejs @
categoriesnodejs
postedDec 8, '14 at 4:07a
activeDec 8, '14 at 3:50p
posts6
users2
websitenodejs.org
irc#node.js

2 users in discussion

// ravi: 5 posts Christopher Rust: 1 post

People

Translate

site design / logo © 2022 Grokbase