LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-21-2017, 03:15 AM   #1
qmzpalqmzpal
LQ Newbie
 
Registered: Nov 2017
Posts: 3

Rep: Reputation: Disabled
Count CPU load average by yourself


Hello, is there any way I could count CPU load average? I don't want to use system load average from /proc/loadavg since it also contain uninterruptible processes, I just want to count average number of runnables.
 
Old 11-21-2017, 03:28 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Load average is an exponential moving average; how do you propose to achieve that ?. The code is of course in the source tree.
For the runnable count look at /proc/stat.
 
Old 11-21-2017, 09:33 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
"The presence of the experimenter will alter the experiment." Your process will be an excessively-busy, CPU-bound process according to your own measure.

Also, this statistic is basically meaningless. The pool of "runnable" processes changes from one microsecond to the next, and it is good(!) for that list to be as full as possible and for the CPU(s) to be as near to "100% utilization" as possible, anytime there is any work to do.
 
Old 11-21-2017, 12:10 PM   #4
qmzpalqmzpal
LQ Newbie
 
Registered: Nov 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
Load average is an exponential moving average; how do you propose to achieve that ?. The code is of course in the source tree.
For the runnable count look at /proc/stat.
No idea how I would achieve that... You can see instantaneous runnables value in /proc/stat but what is purpose of that? I mean if you don't average it than you might see 100 runnables in one second and 0 in second I don't know what you should make of it.


Quote:
"The presence of the experimenter will alter the experiment." Your process will be an excessively-busy, CPU-bound process according to your own measure.

Also, this statistic is basically meaningless. The pool of "runnable" processes changes from one microsecond to the next, and it is good(!) for that list to be as full as possible and for the CPU(s) to be as near to "100% utilization" as possible, anytime there is any work to do.
What if I want to start new heavy program on this machine, if it's already at 100% all the time I certainly don't want to run more programs here which will overload this machine.
 
Old 11-21-2017, 01:20 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
"100% CPU utilization" will not "overload the machine."

Also, observations made of the program when it is experiencing no competition for resources will over-state its actual resource requirements because Linux is designed to be "lazy."

Simply do runtime measurements, e.g. with the time command, under various surrounding load conditions.
 
Old 11-21-2017, 02:24 PM   #6
qmzpalqmzpal
LQ Newbie
 
Registered: Nov 2017
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sundialsvcs View Post
"100% CPU utilization" will not "overload the machine."

Also, observations made of the program when it is experiencing no competition for resources will over-state its actual resource requirements because Linux is designed to be "lazy."

Simply do runtime measurements, e.g. with the time command, under various surrounding load conditions.
By overload I mean that machine will take longer to do same job. e.g machine is working on 100% all the time, now if you add 100 more programs than cpu utilization will still be 100% however every program would spend much time waiting for other programs therefor everything will be slowed down. So when you have machine with 100% utilization everything might work fine but you don't want to add more and more job to that machine. Initially I wasn't talking about utilization, instead I was talking about average number of runnable programs, which means how many programs are in cpu queue which I believe is best measurement for how good cpu performs since if this number is always more than the number of you cpus you know that some programs spend time waiting for other programs to finish, therefor it works slower.
 
Old 11-22-2017, 02:03 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,649
Blog Entries: 4

Rep: Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934Reputation: 3934
Once again, the content of the run-list changes every microsecond. Its "average length" is not useful. It won't correlate to anything at all.

All running programs are in competition for the same basic resources: memory, CPU time, and I/O bandwidth. (Memory generates some amount of I/O traffic due to demand paging.)

The operating system is "lazy," never doing more than it has to. Thus, you must create some amount of "stress."

What you're really interested in is how long a particular activity takes to complete, under different realistic load conditions. The classic performance curve is elbow-shaped, gradually rising until it abruptly "hits the wall." (Splat!) I suggest that you, literally, conduct an experiment with different load mixes.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU Load Average devUnix Linux - Server 1 09-30-2013 04:28 AM
CPU load average alert linuxandtsm Linux - Newbie 6 05-10-2012 04:15 PM
Linux CPU load average kdelover Linux - Newbie 6 03-02-2011 12:40 PM
Get load average for cpu core chamila1986 Linux - General 6 05-19-2010 05:40 AM
How can I get the system's cpu Load Average by c. davyzhang Programming 12 08-03-2007 07:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration