https://access.redhat.com/articles/5467
In the event that a process is not achieving the desired performance performance benchmarks, it can be helpful to set CPU affinity, real-time scheduling policy and real-time scheduling priority. Experimenting with different options using the taskset
and chrt
commands can help determine if this approach will provide the desired results.
The taskset
sets CPU affinity for a process. The chrt
sets real time scheduling options. The two commands can be used in tandem. For example:
# taskset -c 2-3 <command>
# chrt -f 1 <command>
The above usage would force <command>
to run on CPUs 2 through 3, using the "fifo" scheduling policy at priority level 1. The results of using these options depend on the workload of the application, as well as the load of the system in general.
For more information on the taskset
and chrt
commands, see their respective man pages. For more information on setting these attributes within an application, rather than when launching the application, see man 2 sched_setaffinity
and man 2 sched_setscheduler
.