Do you need to synchronize your threads? If so, you may experience the following problem:
Suppose you have a 4-processor system and a 4-stream job. When you run alone, threads get around to using all 4 cores and overall usage is almost perfect (we will call it 400%).
If you add one single-threaded interfering task, the scheduler can place 2 of your threads on one processor. This means that 2 of your threads are now working effectively at half their normal pace (drastic simplification), and if your threads need to be synchronized periodically, your work progress may be limited by the slowest thread, which in this case runs at half normal speed. You could use only 200% (of 4x 50% of work) plus 100% (interfering job) = 300%.
Similarly, if you assume that intervention in a task uses only 25% of one processor time, you can see one of your threads and a source of interference on one CPU. In this case, the slowest flow works at a normal speed of 3/4, resulting in a total use of 300% (4x 75%) + 25% = 325%. Play with these numbers, and itβs easy for you to find something similar to what you see.
If this is a problem, you can, of course, play with priorities to give nasty tasks only tiny fractions of the available CPU (I assume I / O delays are not a factor). Or, as you find, try increasing the threads so that each processor has, say, 2 threads, minus several, to solve system tasks. Thus, a system with 24 cores can work best, say, out of 46 threads (which always leave half of the 2 cores available for system tasks).
Eric Seppanen
source share