开发者

On throughput of linux scheduler when there are more threads than cores

开发者 https://www.devze.com 2023-03-20 09:10 出处:网络
I have done some measurement over linux scheduler. The linux is \"Linux version 2.6.18-194.el5 (mockbuild@x86-005.build.bos.redhat.com)\" and machine is with 8 cpus. The measurement is the only worklo

I have done some measurement over linux scheduler. The linux is "Linux version 2.6.18-194.el5 (mockbuild@x86-005.build.bos.redhat.com)" and machine is with 8 cpus. The measurement is the only workload on that machine.

The measurement is two sets. In the first set, 8 threads are set up and each of same computation costs. Second set is to split one thread into two, resulting in totally 9 threads (2 out of which is half in cost of the other 7 threads).

When I run the two measurement sets, I expect the throughput is the same, for the total 开发者_JS百科computation costs are the same and linux scheduler should (though I'm not sure) schedule those two smaller threads in one core. The results turn out to be there is dramatic decrease in throughput from 8 threads to 9 threads. Anyone has ideas what could be the reason.

Edit: @Waldheinz. Those threads are set up in order (say 0, 1 ... 7) and a (endless) stream of tuples go through from thread 0, 1 to thread 7. Each tuple spend sometime on each thread, doing some computation. All 8 threads are of the same computation costs as in the first set of measurement.

Updates: If the number of threads changed to 16, meaning every core has two threads, throughput is improved to the case of 8 threads...


Linux 2.6.18 is quite old now, dating to 2006, and multi-core systems were not as common or important back then. It's possible that your benchmark exercises some of the deficiencies of the O(1) scheduler that the kernel used up until 2.6.23. I forget exactly what those problems were, but it sounds plausible. The O(1) part refers to the fact that overhead of scheduling is essentially constant, but even though that was the case, the scheduler made poor decisions in some situations.

If you can, try a more recent kernel (after 2.6.23) and see if the new completely fair scheduler makes a difference.


Nine women can have nine babies in nine months, a rate of nine months per baby per person. One woman can have one baby in nine months, again a rate of nine months per baby per person. But nine women still need eighteen months to have ten babies, a much worse rate of more than sixteen months per baby per person!

You are assigning your threads chunks of work that are too large and not running your test for long enough to smooth out the chunk size.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号