开发者

any real performance gain of setting affinity mask for threads?

actually, subject. when is it reasonabl开发者_StackOverflow社区e?

any difference between linux and windows?


There is an example (it's just a benchmark) where it's possible to get a real performance gain when setting affinity of threads (they get ~10x gain in performance with affinity and some other hacks).

In this benchmark affinity settings at least allow utilizing the Core Quad's feature that it is really two dual core processors so the price of communication between different cores is not the same.

They run two parallel simulations to rid of expensive interaction between pairs of cores. Each simulation runs on its pair of cores and here affinity helps again to avoid (as was said in other answers) moving threads from one core to another and back.


When you believe you can outsmart the scheduler. This should be pretty rare.


At some point we were automating Microsoft Word to do some batch processing and it was crashing randomly on multi-cpu systems. We figured it was a concurrent memory access bug and started setting Word process affinity to only run on a single core. It resolved the issue. I know this is not exactly what you are looking for, but decided to share :)


As MK said the only conditions when this is necessary is if you feel that your application only needs to run on a set amount of cores. Which in his example is reasonable. In other cases you want to have your application avoid bottlenecking a system, for instance lets say your process runs concurrently on 4 cores of a quad core machine, which causes other programs that may be doing activity to have to wait extra time. You could instead set your program to only use 2 of the cores to allow the other 2 cores to process other important information from different applications. Most of the time you will not need to do this unless there are specific needs or if your application needs certain performance tweaks to run efficiently by itself or with other applications.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜