原创 Processor affinity

2012-12-30 16:56 2542 20 21 分类: 消费电子

There is a simple way of getting more performance from the multicore processors. It is called Processor Affinity. It is supported by mainstream operating systems. Let us see how to use it.

Suppose, we have a quad core linux machine, and we use as a desktop. All the applications running on the system will be running on one of the 4 cores. You want to assign one specific cores for music playing, one for routine background backup process, and rest for all desktop applications.

Linux allows a way of "pinning down" a process to a core or a set of cores, through a command line option. For example, we can use taskset command to pin down a running application (say apache webserver, whose PID is 2000) to core 1 as below:

$ taskset -cp 1 2000

While you can pin a running process task to a set of your cores, that does not mean that the process and its threads will be immediately moved to those CPU's you dictated. The kernel scheduler starts preferring your appointed cores instead of the cores your processes are currently using. It can take sometime to see the effect of taskset command for a running process.

Other way is to start a process "pinned down" to a specific core with this command:

$ taskset -c 3 apache

The apache server will start running on core 3 and will be pinned to that core

What are advantages of the processor affinity?

Firstly, one can isolate critical processes to one core and leaving the rest of them to the other cores, it allows the critical processes to receive the full power of the processor core.

Secondly, it can improve performance by reducing the number of cache flushes when process threads move to another processor. If the process is directed to use the same core everytime, performance can be improved due to the ability to re-use the cache. This is particularly true if we use a mix of programs that use high CPU power like anti-virus scan, flash applications which can be tied to cores to avoid the cache flushes

To summarize, processor affinity can improve performance by allocating applications to cores at a coarse grained granularity. Like other tools, one needs to experiment it and find the optimum mix!

文章评论1条评论)

登录后参与讨论

用户1582657 2013-1-4 14:08

Good , Thanks

相关推荐阅读
用户3673633 2013-10-25 12:03
Update your software without disruption, thanks to multicore!
 Most of us have installed third party software like Chrome browser or Adobe PDF reader in our des...
用户3673633 2011-12-14 13:35
Multicore support in Linux
Before multicore processors became mainstream, there was a popular model called Symmetric Multipro...
用户3673633 2011-04-28 18:00
Multicore and server side computing
We have seen the challenges of multicore programming in mainstream programming in earlier articles. ...
用户3673633 2010-07-03 22:27
Multicore in Networking
Networking gear companies are bullish about the multicore processors and are seeing tangible benefit...
用户3673633 2010-05-07 17:42
Simple technique that improves single threaded app performance
Recently, scientists from NCSU have discovered a  technique that improves performance of  applicatio...
我要评论
1
20
关闭 站长推荐上一条 /2 下一条