Sample Header Ad - 728x90

How to measure actual CPU utilization in Linux for multi core applications?

1 vote
1 answer
128 views
I have a computation intensive process that I need to run multiple times on a multi-core processor but "top" isn't showing utilization or load in a useful way. For example, imagine my task runs in 1 minute in a single thread on a single core of my six core, 12 thread, SMT CPU. If I start the same task six times using six threads, it still finishes in 1 minute and top shows the load average as 6.0 and the cpu(s) at 50% us and 50% id. In the top process list, each of the six processes is showing 100% CPU. If I do the same thing but start 12 threads, it finishes the 12 jobs in 2 minutes and top shows the load average as 12.0, cpu(s) at 100% us 0% id, with 12 processes each at 100% CPU. Now, the 6 thread and 12 thread examples are both processing at the same fully loaded rate of completing 1/6 job per minute but why does top show the 6-thread case being 50% idle when clearly it isn't? Is there a better way of determining the actual load of the CPUs? This was run on a Ryzen 5600X processor on Ubuntu 24.12. Edit: top output for 12 tasks:
top - 08:35:37 up 54 days, 20:49,  3 users,  load average: 12.20, 6.70, 2.80
Tasks: 346 total,  13 running, 332 sleeping,   0 stopped,   1 zombie
%Cpu(s): 98.2 us,  1.7 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st 
MiB Mem :  64221.7 total,   1572.7 free,   4983.4 used,  58684.1 buff/cache     
MiB Swap:   8192.0 total,   7863.7 free,    328.3 used.  59238.3 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                
2249765 user    20   0  126952  64132  51200 R 100.0   0.1   3:48.87 sonicLiquidFoam                                        
2249759 user    20   0  127060  64220  51200 R 100.0   0.1   3:48.93 sonicLiquidFoam                                        
2249757 user    20   0  126624  64064  51328 R 100.0   0.1   3:49.32 sonicLiquidFoam                                        
2249761 user    20   0  128276  64868  50688 R 100.0   0.1   3:47.65 sonicLiquidFoam                                        
2249762 user    20   0  127652  63688  50432 R 100.0   0.1   3:49.13 sonicLiquidFoam                                        
2249755 user    20   0  128844  66128  51200 R 100.0   0.1   3:46.06 sonicLiquidFoam                                        
2249766 user    20   0  126576  63952  51328 R 100.0   0.1   3:47.87 sonicLiquidFoam                                        
2249764 user    20   0  126612  63824  51072 R  99.0   0.1   3:48.59 sonicLiquidFoam                                        
2249760 user    20   0  126888  63972  51072 R  98.7   0.1   3:45.06 sonicLiquidFoam                                        
2249758 user    20   0  127500  64860  51200 R  97.7   0.1   3:48.64 sonicLiquidFoam                                        
2249763 user    20   0  127916  64944  51072 R  97.0   0.1   3:39.58 sonicLiquidFoam                                        
2249756 user    20   0  126828  63948  51072 R  96.0   0.1   3:48.77 sonicLiquidFoam
For 6 tasks:
top - 08:40:22 up 54 days, 20:53,  3 users,  load average: 6.11, 6.67, 3.90
Tasks: 335 total,   7 running, 327 sleeping,   0 stopped,   1 zombie
%Cpu(s): 50.0 us,  1.0 sy,  0.0 ni, 49.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st 
MiB Mem :  64221.7 total,   1616.2 free,   4914.6 used,  58710.3 buff/cache     
MiB Swap:   8192.0 total,   7863.7 free,    328.3 used.  59307.1 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                
2250032 user    20   0  127392  64676  51200 R 100.0   0.1   2:39.15 sonicLiquidFoam                                        
2250027 user    20   0  126828  63096  50176 R 100.0   0.1   2:39.23 sonicLiquidFoam                                        
2250028 user    20   0  127060  63260  50176 R 100.0   0.1   2:39.23 sonicLiquidFoam                                        
2250029 user    20   0  128844  66124  51200 R 100.0   0.1   2:39.12 sonicLiquidFoam                                        
2250030 user    20   0  128276  65508  51200 R 100.0   0.1   2:39.21 sonicLiquidFoam                                        
2250031 user    20   0  126596  63808  51072 R 100.0   0.1   2:39.21 sonicLiquidFoam
Asked by tkw954 (113 rep)
Apr 23, 2025, 07:35 PM
Last activity: Apr 24, 2025, 02:43 PM