Operating System - HP-UX
1752777 Members
5966 Online
108789 Solutions
New Discussion юеВ

application causes CPU to spend a lot of time in the NICE state.

 
SOLVED
Go to solution
james rowe
New Member

application causes CPU to spend a lot of time in the NICE state.

Hi,
i have an application which gives the following output from top.

Load averages: 1.25, 0.87, 0.41
285 processes: 164 sleeping, 57 running, 64 zombies
Cpu states:
CPU LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS
0 1.21 0.8% 54.7% 5.3% 39.2% 0.0% 0.0% 0.0% 0.0%
1 1.15 0.4% 55.6% 8.1% 35.9% 0.0% 0.0% 0.0% 0.0%
2 1.01 1.2% 54.7% 6.5% 37.6% 0.0% 0.0% 0.0% 0.0%
3 1.19 0.4% 60.3% 5.8% 33.5% 0.0% 0.0% 0.0% 0.0%
4 1.27 0.0% 60.5% 8.3% 31.2% 0.0% 0.0% 0.0% 0.0%
5 1.08 0.0% 56.8% 8.7% 34.5% 0.0% 0.0% 0.0% 0.0%
6 1.46 0.2% 59.2% 7.3% 33.3% 0.0% 0.0% 0.0% 0.0%
7 1.61 0.0% 59.2% 8.1% 32.7% 0.0% 0.0% 0.0% 0.0%
--- ---- ----- ----- ----- ----- ----- ----- ----- -----
avg 1.25 0.4% 57.7% 7.1% 34.7% 0.0% 0.0% 0.0% 0.0%

Memory: 1178288K (1112376K) real, 2946960K (2859364K) virtual, 14685596K free Page# 1/13

CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND
7 pty/ttyr0 1172 test 152 36 87096K 17092K run 49:59 58.17 58.07 myApplication
3 pty/ttyr1 1174 test 152 36 86420K 16816K run 49:49 57.46 57.36 myApplication
0 pty/ttyq8 1144 test 152 36 307M 62716K run 49:15 55.96 55.87 myApplication
4 pty/ttyq6 1140 test 152 36 305M 60616K run 48:39 55.08 54.98 myApplication
3 pty/ttyq9 1146 test 152 36 305M 61132K run 48:36 55.07 54.97 myApplication
5 pty/ttyqa 1148 test 152 36 305M 61464K run 48:20 54.86 54.77 myApplication
7 pty/ttyq7 1142 test 152 36 302M 58972K run 48:38 54.80 54.71 myApplication

...etc

This shows that there are multiple instances of myApplication running, each using approx 55% CPU. However under "Cpu states" it shows that the CPUs are actually spending most of their time in the "NICE" state. What does the NICE state indicate? I have not 'niced' any of the applications. They are all running at the default nice value. The application is a multithreaded c++ application which also loads a JVM.

Thanks for any help,
Jim.
6 REPLIES 6
harry d brown jr
Honored Contributor

Re: application causes CPU to spend a lot of time in the NICE state.

james rowe
New Member

Re: application causes CPU to spend a lot of time in the NICE state.

Thanks for the reply. I understand that the 'nice' command is used to assign a priority to a process (-20 to +20) but this does not tell me what the NICE cpu state is. If a processor is in the NICE state for 55% of the time, what does this mean? Is it spending 55% of its time prioritising processes?


Thanks,
Jim.
Bill Hassell
Honored Contributor

Re: application causes CPU to spend a lot of time in the NICE state.

NICE is not a CPU state, it is a priority level. If all the running processes are run via nice, then it has no effect at all. All that nice does is to reduce the importance of the nice'd processes relative to normal processes. This is commonly done for CPU-intensive applications that don't require immediate attention. An example of a process that needs immediate attention is a user's shell. Ideally, the user expects an immediate response to commands, so it is left at normal priority while a process that consumes 100% CPU for a few mimutes should be run via nice to avoid delaying the shell.

Now modern Unix systems are quite sophisticated and even a 100% CPU-intensive application won't suspend all other programs--that's what time slicing and context switching is all about. Every 100ms (default) the kernel checks to see if there are other processes ready to run. So all the processes running at a nice level are running as fast as they can. The nice state is a convenient way to report on processes that were started with a 'nicer' priority.


Bill Hassell, sysadmin
Steve Steel
Honored Contributor

Re: application causes CPU to spend a lot of time in the NICE state.

Hi

From man top

NI Nice value ranging from -20 to +20.

From man nice

All processes have an associated system nice value which is used to
compute the instantaneous-priority of the process when it is scheduled
to run. Normally, all processes inherit the system nice value of
their parent process when they are spawned. The shell (sh, csh, ksh,
etc.) can create a child process with a different priority from the
current shell process by spawning the child process via the nice
command. If the priority_change value is unsigned (positive), the
child process is nicer (lower in priority) relative to the parent. If
the priority_change value is negative, the child process runs at a
higher priority with a greater share of available system resources.
To spawn a higher priority child process, the parent process must be
owned by a user who has the appropriate privileges.

At boot-up, the system starts the init process at a system nice value
of 20 (system default). On most systems, all processes (down to the
login shells) inherit this priority. Starting from their individual
login shell processes, users can alter the system nice value of
descendent processes to as much as 39, or, with appropriate
privileges, as little as 0. A system nice value of 0 establishes an
extremely high priority, whereas a value of 39 indicates a very low
priority.

Your nice value is 36

This is set by the system load balancing to allow the machine to function when a heavy process is busy.

The processor NICE is the percentage of time the processor runs processes with a nice changed value


There have been p[roblems with top so check you have the latets patch

Regards

Steve Steel

Quote of the moment
-------------------
"We are drowning in information but starved for knowledge."
-- John Naisbitt
If you want truly to understand something, try to change it. (Kurt Lewin)
John Bolene
Honored Contributor

Re: application causes CPU to spend a lot of time in the NICE state.

Nice is a good thing if the niced processes are low priority. Nice allows these processes to get some cpu time, but not as much as they would want.

If there is sufficient cpu capacity to get them done, great, otherwise they will take longer to process.

Since you still have idle time left on the machine, then they are processing as fast as they can. When you get higher priority processes, which would be almost any at your nice level, the niced will run slower.
It is always a good day when you are launching rockets! http://tripolioklahoma.org, Mostly Missiles http://mostlymissiles.com
Adam J Markiewicz
Trusted Contributor
Solution

Re: application causes CPU to spend a lot of time in the NICE state.

Hi
You have a nice set of handy answers here, but mayby it's not exactly what you wanted to know. So, I won't write again what 'nice' is and what it does, as it's written above (besides I have an impression that you knew it before). Let's concentrate on top results:

NICE is the time spent by CPU for the process that's been niced.
USER is the time spent by CPU for process that's not been niced.

The meaning is actually the same, but it's comfortable to have it separate sometimes. And remember that the every process can renice itself without operator's help. Even more - as your myApplication seems to be CPU consumimg it's very good choice that it's been niced.

As you have quite big IDLE there is nothing for you to worry about, untill you run another CPU consuming process that won't be niced.

Everything else that would be interested for you has already been told before.
I do everything perfectly, except from my mistakes