1

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 
3
  • To help get an answer, can you edit the question to show the output from top for the different cases? Commented Apr 23 at 19:40
  • Very likely top is seeing that you have 12 cores available, so when you only start 6 jobs, you naturally get 50% utilization. For scheduling purposes, each "hyperthread" instruction pipeline is treated like a core. Commented Apr 23 at 22:53
  • I remember htop filter by thread. Commented Apr 24 at 1:09

1 Answer 1

2

The Ryzen 5600X is a 6 core processor with 2 hyperthreads per core.

If you do not get a speed up going from 6 threads to 12 threads, then this indicates your process is fully using the core and not leaving any idle time for the other thread.

Other tasks may not use the cpu quite so completely, and may get some speedup from the second thread in the core.

The cpu accounting around hyperthreads causes both threads in the core to be charged for the cpu time even when only one of them actually got it. This is an unfortunate feature of the way hyperthreading works. I don't think the linux kernel itself has any visibility into this.

3
  • By " I don't think the linux kernel itself has any visibility into this." do you mean that there's no way to tell the actual CPU load short of adding threads and seeing if the performance improves? Commented Apr 24 at 18:17
  • Yes, I believe (but am not sure) that there is no direct way to determine the actual cpu load in a hyperthreaded situation. There are a number of indirect ways, including benchmarking like you did. Commented Apr 25 at 5:01
  • Do realize that hyperthreading implementation varies greatly between architectures. Apparently with Sparc and Power processors it is possible to determine actual core utilization. On Intel, it is not (unless they add something in newer cores). Not sure about AMD. Commented Apr 25 at 5:12

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.