This post is meant for basic users who wish to understand the concept behind CPU affinity for performance purposes. CPU affinity enables binding a process or multiple processes to a specific CPU core in a way that the process es will run from that specific core only. When trying to perform performance testing on a host with many cores, it is wise to run multiple instances of a process, each one on different core.
This enables higher CPU utilization. On Linux , a process's CPU affinity can be altered with the taskset command. For instance, there are two threads which use cache intensively.
Suppose particular cache is shared by two cores. If a cache-intensive thread is running on two cores, execution of both threads on two cores can depend on the availability of shared cache resource. So it is preferred to use these two threads on two cores that do not share common CPU. Like a cache, the same situation can have occurred for other shared resources like memory banks, IO devices…. If the important thread comes, Affinity is useful to set and reserve a core.
In this case, even if the CPU core is available to run the process, it will not run. The Process even will not be put on the ready list of denied CPUs. Note: All the screenshots has taken on Windows 8. Similar steps you have to follow for Windows 7 or Windows If you have any questions for Setting CPU Affinity, feel free to write a query in the comment section below. Keep learning! Save my name, email, and website in this browser for the next time I comment. What do you want to Learn Today?
These process and threads get executed on CPU cores. There is one more term very important to know about the execution of the program- CPU affinity. By default, all processes will run on all processors, but this can bog down the system with moving data from one Numa node to another.
I've found that if I segregate parts of a workload to to specific nodes, I get a 3X difference in performance overall. This is definitely worthwhile when doing something compute intensive for long periods on a system with multiple processors. Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Learn more. What is Windows Priority and Affinity and what advatanges does it provide? Ask Question. Asked 11 years, 2 months ago. Active 4 months ago. Viewed 54k times. Improve this question. James Mertz.
James Mertz James Mertz Add a comment. Active Oldest Votes. Setting affinity does do something, but you'll never want to use it. Improve this answer. Not true. Windows is smart enough to schedule CPU's efficiently. Synetech: That seems almost impossible. It would have to have been moving the two processes from core to core, always both at the same time. In this case, someone might decide to limit such an application to only some of the CPUs.
As a developer I use this feature frequently when profiling my CPU-intensive applications, as the act of profiling itself requires CPU.
Jim W Jim W 3 3 bronze badges. You would be much better off in this case simply setting your CPU hog process to a low priority. Setting affinity tells that process what processors it's allowed to run on.
While very useful for some niche cases, the average user probably shouldn't mess with it. Evan Plaice Evan Plaice 1, 1 1 gold badge 13 13 silver badges 18 18 bronze badges.
0コメント