Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

There is a server with vlc process for real-time video encoding.

Here is output of top with 1(show processors) and H(show threads)

top - 15:50:26 up 42 min,  1 user,  load average: 2.64, 2.60, 2.45
Tasks: 130 total,   7 running, 123 sleeping,   0 stopped,   0 zombie
Cpu0  :  0.0%us,  0.3%sy, 72.2%ni, 26.8%id,  0.0%wa,  0.0%hi,  0.7%si,  0.0%st
Cpu1  :  0.0%us,  0.0%sy, 56.0%ni, 44.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :  2.6%us,  0.0%sy,  9.4%ni, 87.6%id,  0.0%wa,  0.0%hi,  0.0%si,  0.3%st
Cpu3  :  0.0%us,  0.0%sy, 35.9%ni, 64.1%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu4  :  0.0%us,  0.0%sy, 35.0%ni, 65.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu5  :  2.6%us,  0.0%sy,  0.0%ni, 97.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu6  :  0.0%us,  0.6%sy, 18.0%ni, 81.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu7  :  4.9%us,  0.0%sy,  0.0%ni, 95.1%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:    533064k total,   233000k used,   300064k free,     4832k buffers
Swap:  2097144k total,        0k used,  2097144k free,    40516k cached

  PID USER       PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
 5841 videoenc   20   0  674m 119m 8228 R  8.0 22.9   2:32.50 vlc                
 5840 videoenc   20   0  674m 119m 8228 S  4.7 22.9   1:49.53 vlc                
 5843 videoenc   20   0  674m 119m 8228 R  4.7 22.9   1:45.36 vlc                
22787 videoenc   30  10  674m 119m 8228 R  4.7 22.9   0:00.14 vlc                
22788 videoenc   30  10  674m 119m 8228 S  2.0 22.9   0:00.06 vlc                
22789 videoenc   30  10  674m 119m 8228 R  1.3 22.9   0:00.04 vlc                
 5838 videoenc   20   0  674m 119m 8228 S  0.7 22.9   0:08.14 vlc                
22790 videoenc   30  10  674m 119m 8228 S  0.7 22.9   0:00.02 vlc                
22791 videoenc   30  10  674m 119m 8228 S  0.7 22.9   0:00.02 vlc              

Here is combined output of top (without 1 and H)

top - 16:01:09 up 52 min,  1 user,  load average: 3.88, 3.74, 3.10
Tasks: 110 total,   1 running, 109 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.2%us,  0.1%sy, 35.2%ni, 63.2%id,  0.1%wa,  0.0%hi,  0.0%si,  0.1%st
Mem:    533064k total,   234136k used,   298928k free,     5208k buffers
Swap:  2097144k total,        0k used,  2097144k free,    40992k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           
 5825 videoenc  20   0  674m 119m 8228 S  305 22.9  98:59.58 vlc                
    1 root      20   0 10328  736  616 S    0  0.1   0:00.08 init               
    2 root      15  -5     0    0    0 S    0  0.0   0:00.00 kthreadd           
    3 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/0        
    4 root      15  -5     0    0    0 S    0  0.0   0:00.00 ksoftirqd/0        
    5 root      15  -5     0    0    0 S    0  0.0   0:00.04 events/0           
    6 root      15  -5     0    0    0 S    0  0.0   0:00.00 khelper            
    8 root      15  -5     0    0    0 S    0  0.0   0:00.00 xenbus             
   10 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/1        
   11 root      15  -5     0    0    0 S    0  0.0   0:00.00 ksoftirqd/1        
   12 root      15  -5     0    0    0 S    0  0.0   0:00.02 events/1           
   13 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/2        
   14 root      15  -5     0    0    0 S    0  0.0   0:00.00 ksoftirqd/2        
   15 root      15  -5     0    0    0 S    0  0.0   0:00.02 events/2           
   16 root      RT  -5     0    0    0 S    0  0.0   0:00.00 migration/3        
   17 root      15  -5     0    0    0 S    0  0.0   0:00.00 ksoftirqd/3        

Here is the question:
Why sum of all %CPU is not equal sum of %ni. And why VLC produces 'nice' load when it's run without renice

share|improve this question
1  
2 (or 3) isn't terribly high load.. –  Tom O'Connor Jan 26 '10 at 16:15
    
Yeah, but still why nice, not user? –  SaveTheRbtz Jan 26 '10 at 16:53

3 Answers 3

One of the threads in VLC or one of the libraries it uses for encoding is probably using setpriority() to change the priority/niceness of the threads which it creates

share|improve this answer

You are running TOP in Irix mode which shows CPU % as the percentage of a single CPU. Press "I" to toggle into Solaris mode which shows CPU % as the percentage of the ALL CPUs.

share|improve this answer

from the man page:

CPU States The CPU states are shown in the Summary Area. They are always shown as a percentage and are for the time between now and the last refresh.
us -- User CPU time
The time the CPU has spent running users’ processes that are not niced.
ni -- Nice CPU time
The time the CPU has spent running users’ proccess that have been niced.

%CPU is everything and ni is only the niced rtime.

share|improve this answer
    
irolla said that he didn't use renice on process –  SaveTheRbtz Jan 26 '10 at 16:53
    
right -- but per James's comment above, programs can also set (reduced) priorities. –  Jon Lasser Jan 26 '10 at 20:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.