Setting processor affinity not working in Windows 10? Thread starter Mut1ny; Start date Mar 16, 2016; Mar 16, 2016. You might decide Prio is worth keeping around even in spite of it not being able to help in this situation. And of course the ability to set affinity per process is there too - right click on any process on the Process tab.
Processor affinity, or CPU pinning or 'cache affinity', enables the binding and unbinding of a process or a thread to a central processing unit (CPU) or a range of CPUs, so that the process or thread will execute only on the designated CPU or CPUs rather than any CPU. This can be viewed as a modification of the native central queue scheduling algorithm in a symmetric multiprocessing operating system. Each item in the queue has a tag indicating its kin processor. At the time of resource allocation, each task is allocated to its kin processor in preference to others.
Processor affinity takes advantage of the fact that remnants of a process that was run on a given processor may remain in that processor's state (for example, data in the cache memory) after another process was run on that processor. Scheduling that process to execute on the same processor improves its performance by reducing performance-degrading events such as cache misses. A practical example of processor affinity is executing multiple instances of a non-threaded application, such as some graphics-rendering software.
Scheduling-algorithm implementations vary in adherence to processor affinity. Under certain circumstances, some implementations will allow a task to change to another processor if it results in higher efficiency. For example, when two processor-intensive tasks (A and B) have affinity to one processor while another processor remains unused, many schedulers will shift task B to the second processor in order to maximize processor use. Task B will then acquire affinity with the second processor, while task A will continue to have affinity with the original processor.
Usage[edit]
Processor affinity can effectively reduce cache problems, but it does not reduce the persistent load-balancing problem.[1] Also note that processor affinity becomes more complicated in systems with non-uniform architectures. For example, a system with two dual-corehyper-threadedCPUs presents a challenge to a scheduling algorithm.
There is complete affinity between two virtual CPUs implemented on the same core via hyper-threading, partial affinity between two cores on the same physical processor (as the cores share some, but not all, cache), and no affinity between separate physical processors. As other resources are also shared, processor affinity alone cannot be used as the basis for CPU dispatching. If a process has recently run on one virtual hyper-threaded CPU in a given core, and that virtual CPU is currently busy but its partner CPU is not, cache affinity would suggest that the process should be dispatched to the idle partner CPU. However, the two virtual CPUs compete for essentially all computing, cache, and memory resources. In this situation, it would typically be more efficient to dispatch the process to a different core or CPU, if one is available. This could incur a penalty when process repopulates the cache, but overall performance could be higher as the process would not have to compete for resources within the CPU.
Specific operating systems[edit]
On Linux, the CPU affinity of a process can be altered with the taskset(1) program[2] and the sched_setaffinity(2) system call. The affinity of a thread can be altered with one of the library functions: pthread_setaffinity_np(3) or pthread_attr_setaffinity_np(3).
On SGI systems, dplace binds a process to a set of CPUs.[3]
On DragonFly BSD 1.9 (2007) and later versions, usched_set system call can be used to control the affinity of a process.[4][5] On NetBSD 5.0, FreeBSD 7.2, DragonFly BSD 4.7 and later versions can use pthread_setaffinity_np and pthread_getaffinity_np.[6] In NetBSD, the psrset utility[7] to set a thread's affinity to a certain CPU set. In FreeBSD, cpuset[8] utility is used to create CPU sets and to assign processes to these sets. In DragonFly BSD 3.1 (2012) and later, usched utility can be used for assigning processes to a certain CPU set.[9]
On Windows NT and its successors, thread and process CPU affinities can be set separately by using SetThreadAffinityMask[10] and SetProcessAffinityMask[11] API calls or via the Task Manager interface (for process affinity only).
macOS exposes an affinity API[12] that provides hints to the kernel how to schedule threads according to affinity sets.
On Solaris it is possible to control bindings of processes and LWPs to processor using the pbind(1)[13] program. To control the affinity programmatically processor_bind(2)[14] can be used. There are more generic interfaces available such as pset_bind(2)[15] or lgrp_affinity_get(3LGRP)[16] using processor set and locality groups concepts.
On AIX it is possible to control bindings of processes using the bindprocessor command[17][18] and the bindprocessor API.[17][19]
See also[edit]References[edit]
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Processor_affinity&oldid=944734162'
Yesterday I was using a virtual machine from my Hyper-V server and I noticed it became sluggish at one point. A quick look at the task manager and it was clearly Windows Update who was slurping away my CPU power. There is no real point in killing the process but it should not interfere as much with my work as it did.
To tame the Windows Update task inside my 2 vCPU virtual machine I wanted to lower the priority of the Windows Update process and let it run on 1 core instead of both cores. PowerShell to the rescue!
Why change Affinity ?
You can always change the priority of a process with just a few clicks in the task manager but if you have a multi-core system fiddling with affinity probably will have more impact on your experience. Why?
Lets assume Task A will consume 237 units of time. Changing priority or affinity will not reduce the 237 units it takes to do the task. That’s just not gonna happen, it needs the 237 units to calculate the job one way or the other. How fast those units are calculated and what room is left for other tasks if a different story.
To keep things simple lets say your CPU is spinning on the same speed and waiting for tasks to do. Your browser or something else you are doing (lets call it Task B) needs 42 units of time to do his job you just instructed it to do. 237 vs 42 units. You can guess with which task your system will be the most active if priority is equal and both CPU’s are working on both tasks.
In theory you should not really notice a slow down because tasks are spread around both cores and the workload of Task A is given an amount of time before switching to Task B and back again to A, etc. But who here can say they never noticed Windows Update is working on the background and is slowing down your pc. If your pc is not really powerful and has plenty of headroom you will notice your pc feels a bit slower.
With changing the affinity you are disallowing a process to spread across all available cores. By limiting Windows Update to one core you will free the other core of this task. Your Task B won’t have to share one core with Task A. This means your Task B can use one CPU (or more if your pc has them) without the interruption of Windows Update. Because we haven’t changed the affinity of other processes on our system other tasks will still use all CPU’s. Tasks will take a bit longer on the busy CPU but they still will get some time to do their job there and combined with the Windows Update free CPU it will feel better than without changing affinity.
This can make your pc feel a lot smoother if it’s running low on ‘unused speed’ when updating Windows.
Change the priority and affinity of Windows Update
Open a PowerShell window with elevated permissions and paste the following:
This will make the current session of Windows Update running on a lower priority and limiting it to the 2nd core of your system.
Affinity
Explaining affinity is hard. Binary CPU masking, converting to hexadecimal and so on. Pretty sure not many people would be interested in this.
Here is a table on with values you can use for a 8 core processor.
If you want to make other combinations the easiest way is to open the Windows 10 Calculator and change it to Programmer mode (Alt- 3)
Here are some screenshots on how to get desired Hex value with the calculator app.
Where there is a 1 on your binary CPU layout the process will be active on that CPU.
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |