LinuxQuestions.org
Review your favorite Linux distribution.
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-20-2005, 12:05 PM   #1
spaaarky21
Member
 
Registered: Jun 2004
Location: Omaha, NE
Distribution: Ubuntu 7, Fedora Core 4
Posts: 192

Rep: Reputation: 30
Could someone explain "nice time"?


I use my Linux laptop as somewhat of a desktop (mostly when doing web development with PHP) and noticed that when I turn the system on and it is presumably catching up on its regularly scheduled tasks, CPU monitors like GKrellm and System Monitor 2.7 (comes with Fedora) report 100% CPU usage but System Monitor only reports a couple processes that are actually using processor time and they are all under 5% - certainly not enough to exaplain 100% CPU usage. By playing around with GKrellm's options for what it does and doesn't display on its CPU usage graph, I have come to discover that most of the CPU usage I am seeing falls under the category of "nice time." But what is nice time?! I was under the impression that either user code is running in "user time" or system calls are running, therefore using "system time." Where does this third category come from?

-Brandon
 
Old 11-20-2005, 12:28 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
The "niceness" of a process is basically its priority (lower priority processes are "more nice", i.e. they cede the CPU more readily to higher priority process -- the kernel scheduling algorithm is a bit more complicated than that, but that's the jist of it). A process running at low priority (high nice) icrements the nice time in top and I suppose GrellKM too. The process of course is running in user space except when it traps into the kernel (i.e. for a syscall).
 
Old 11-20-2005, 12:57 PM   #3
spaaarky21
Member
 
Registered: Jun 2004
Location: Omaha, NE
Distribution: Ubuntu 7, Fedora Core 4
Posts: 192

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by btmiller
The "niceness" of a process is basically its priority (lower priority processes are "more nice", i.e. they cede the CPU more readily to higher priority process -- the kernel scheduling algorithm is a bit more complicated than that, but that's the jist of it). A process running at low priority (high nice) icrements the nice time in top and I suppose GrellKM too. The process of course is running in user space except when it traps into the kernel (i.e. for a syscall).
Thanks for the reply. That seems to clarify things pretty well but I do have one question. So, if a process is running in user space and increments the nice time, does that nice time "come out of," or get subtracted from, that process's user time? If not, I can't understand how the CPU could be running at 100% yet kernel time is only ~5% and user time is only ~25%. Since they don't add up, it seems like nice time would have to come out of the user time.
 
Old 11-20-2005, 02:19 PM   #4
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

Rep: Reputation: 115Reputation: 115
could it be something like the windows idle process? I shoot myself for comparing windows to linux.
 
Old 11-20-2005, 02:27 PM   #5
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
I believe there is an idle task that gets run when there's nothing else runnable.
 
Old 11-20-2005, 05:01 PM   #6
spaaarky21
Member
 
Registered: Jun 2004
Location: Omaha, NE
Distribution: Ubuntu 7, Fedora Core 4
Posts: 192

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by tuxdev
could it be something like the windows idle process? I shoot myself for comparing windows to linux.
Are you telling me politely or seriously asking? If you look at processor load in something like a Top, idle time is separate from everything else. Nice time appears to be time when the processor is actually processing data, not "processing time that isn't actually processing time" like Windows' idle process.
 
Old 11-20-2005, 05:27 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,653

Rep: Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453
I suspect a problem in GKrellm - never used it, so I can't check.

I believe uptime = (sys + user + nice +idle)
"nice time" is the time accumulatd for tasks running "nice" - i.e. with a positive nice value.
One could legitimately consider "nice" time a subset of "user" time, but I believe it is accumulated separately.
I'm happy to be corrected BTW ...

CPU busy calculations shouldn't include the idle time.

I'd believe "top" if there was conflict in the numbers reported for CPU%
 
Old 11-20-2005, 06:07 PM   #8
spaaarky21
Member
 
Registered: Jun 2004
Location: Omaha, NE
Distribution: Ubuntu 7, Fedora Core 4
Posts: 192

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by syg00
I suspect a problem in GKrellm - never used it, so I can't check.

I believe uptime = (sys + user + nice +idle)
"nice time" is the time accumulatd for tasks running "nice" - i.e. with a positive nice value.
One could legitimately consider "nice" time a subset of "user" time, but I believe it is accumulated separately.
I'm happy to be corrected BTW ...

CPU busy calculations shouldn't include the idle time.

I'd believe "top" if there was conflict in the numbers reported for CPU%
Now that makes sense. Thanks to everyone. But why do you suspect a bug in GKrellm?
 
Old 11-20-2005, 06:35 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,653

Rep: Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453
Quote:
Originally posted by spaaarky21
But why do you suspect a bug in GKrellm?
Have a look at your initial post.
"nice time" would (er, should ) be counted by the other monitors as well - if GKrellm is showing 100% and the others aren't, I'd be distrusting the "odd man out".
Without knowing, I'd say the monitored period was too short, or the idle time is being incorrectly counted.
"nice time" is generally a *very* small component of the total on my systems.
 
Old 11-21-2005, 01:01 AM   #10
spaaarky21
Member
 
Registered: Jun 2004
Location: Omaha, NE
Distribution: Ubuntu 7, Fedora Core 4
Posts: 192

Original Poster
Rep: Reputation: 30
Quote:
Originally posted by syg00
Have a look at your initial post.
"nice time" would (er, should ) be counted by the other monitors as well - if GKrellm is showing 100% and the others aren't, I'd be distrusting the "odd man out".
Without knowing, I'd say the monitored period was too short, or the idle time is being incorrectly counted.
"nice time" is generally a *very* small component of the total on my systems.
GKrellm, Top and System Monitor all show ~100% CPU usage overall. It's just that System Monitor didn't show any processes in the process list that were using any significant amount of user CPU time - which it shouldn't since, from the discussion here, it seem that nice time could be considered a subset of user time but is tallied up separately.
 
Old 11-21-2005, 03:25 AM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,653

Rep: Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453
Sorry missed that.

I'd try something like the following to get some hard data (presuming sorting on CPU%) that can be analysed later.
Code:
top -b -d 10 -n 5 >> top.saveit
 
Old 11-21-2005, 10:48 AM   #12
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,078
Blog Entries: 4

Rep: Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165Reputation: 3165
The documentation, man top, spake thusly:
Quote:
Shows the percentage of CPU time in user mode, system mode, niced tasks, iowait and idle. (Niced tasks are only those whose nice value is positive.) Time spent in niced tasks will also be counted in system and user time, so the total will be more than 100%.
As others have said, the purpose of the nice command is to "be nice to" other users on the system by voluntarily lowering the execution-priority of a particular process. Such programs can therefore be viewed as (probably) non-interactive, batch-style work, and this is why top separates this figure out.

It may seem counter-intuitive, but you can actually make many types of operations run faster by lowering their execution-priority using nice! These programs don't keep bouncing to the top of the execution-queue along with all the other interactive programs: when they are dispatched, which is less often, they tend to get longer blocks of time and have a better chance of completing a full time-slice if they need to. If the process is fundamentally "I/O-bound," but does not have to interact continuously with you, a slight reduction in execution priority (and the diversion of its output to a disk-file rather than to a screen) will speed it up. If the process is fundamentally "CPU-bound," such as an intensive number-crunching program, a larger reduction in execution priority will speed it up.

If you have a lot of intensive work to move through a computer, or even a large number of requests (as in a web-server), throttling the number of simultaneous active processes will enable the total workload to be completed in much less time. In other words, execute x jobs on the computer but permit only no more than y of them to be executing at any one time. Batch monitoring programs can be used to do this.
 
Old 11-22-2005, 01:14 AM   #13
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 16,653

Rep: Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453Reputation: 2453
Quote:
Originally posted by sundialsvcs
The documentation, man top, spake thusly:
Not on mine it doesn't - and yes I did look prior to posting initially.
Thus I plead innocent as well as ignorant ...

What is the date at the bottom of your manpage listing ???

Last edited by syg00; 11-22-2005 at 01:16 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Where to download precompiled bash binaries, such as "time" and "top"? elinuxqs Linux - Newbie 12 11-14-2005 08:36 PM
Please explain "386" vs. "686" versions vinoloco Linux - Newbie 4 04-05-2005 07:03 PM
Can you explain the difference between "Free Software (GNU)" and "Open Source"? vharishankar General 5 03-03-2005 09:40 AM
Kernel compiling: any links to explain all the "make xconfig" parameters? vharishankar Linux - General 5 02-21-2005 11:27 AM
Lost DHCP Lease when putting computer in "Standby" mode for a "long" time pnellesen Linux - Networking 1 01-06-2005 11:44 PM

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

All times are GMT -5. The time now is 06:51 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration