3

Using an I9-12900KS intel cpu, 128gb ram, Asus Z690 mainboard. Originally Win 10 then upgraded to Win 11 hoping to fix problem.

When I run heavy computational tasks and keep the application in the foreground, everything is great, performance is as expected, cpu load is high, fans are whirring. As soon as I switch to a different application (while waiting for the comp. task), cpu usage drops to half and performance is similarly reduced. It stays like this until I switch back to the computational app, when performance increases again.

I've tried adjusting processor scheduling to support background processes, updating drivers, updating windows, and monitoring the process priority in task manager.

I would like to fix this behaviour in general, the computational tasks can involve thousands of spawned processes if it runs for a long time, adjusting individual processes by hand is not desirable :)

Charlie
  • 101
  • 7
  • 1
    Your CPU has separate performance and efficiency cores. The Windows CPU scheduler is probably trying to do something sensible here. – Daniel B Jan 19 '23 at 10:49

3 Answers3

5

The problem relates to Windows handling of the efficiency cores -- apparently it unloads non foreground tasks to e-cores only. This can be disabled on a per executable basis using the following command line tool:

powercfg /powerthrottling disable /path "c:\myprogram\myprogram.exe"
Charlie
  • 101
  • 7
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 25 '23 at 09:48
0

The default setting in Windows is to favor foreground tasks over background ones. This might be more dramatic on Windows 11 running on a modern CPU, since Windows 11 can choose between cores that are for Efficiency or for Economy. In this case, lower priority might mean the allocation of a slower CPU core.

You may want to modify how background and foreground are tasks are handled.

This is done in the registry at key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\PriorityControl, and especially the item named Win32PrioritySeparation.

You may find a detailed description of this 6-bit item in the article Win32PrioritySeparation. But in short, the field's 6 bits are divided to three 2-bit fields : 112233.

Field 11:

Value Meaning
00 or 11 Shorter intervals (Windows 2000 Professional), Longer intervals (Windows 2000 Server)
01 Longer intervals
10 Shorter intervals

Field 22:

Value Meaning
00 or 11 Variable-length intervals (Windows 2000 Professional), Fixed-length intervals (Windows 2000 Server)
01 Variable-length intervals
10 Fixed-length intervals

Field 33:

Value Meaning
00 Equal and fixed. The threads of foreground processes get the same amount of processor time as the threads of background processes and as the threads of processes with a priority class of Idle. Also, the processor interval is fixed. This value overrides the specification of a variable-length interval in the middle two bits.
01 2 : 1. The threads of foreground processes twice as much processor time than the threads of background processes each time they are scheduled for the processor.
10 or 11 3 : 1. The threads of foreground processes three times as much processor time than the threads of background processes each time they are scheduled for the processor.

In another Win32PrioritySeparation post, a user has compiled all the hexadecimal values that are possible as a combination of these three fields:

2A Hex = Short, Fixed , High foreground boost.
29 Hex = Short, Fixed , Medium foreground boost.
28 Hex = Short, Fixed , No foreground boost.

26 Hex = Short, Variable , High foreground boost.
25 Hex = Short, Variable , Medium foreground boost.
24 Hex = Short, Variable , No foreground boost.

1A Hex = Long, Fixed, High foreground boost.
19 Hex = Long, Fixed, Medium foreground boost.
18 Hex = Long, Fixed, No foreground boost.

16 Hex = Long, Variable, High foreground boost.
15 Hex = Long, Variable, Medium foreground boost.
14 Hex = Long, Variable, No foreground boost.

You would probably favor 18 hex, meaning long intervals, fixed size (no advantage for foreground), No foreground boost.

After changing this registry item, I would counsel a reboot. Note the old value, in case you wish to undo the change.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • This does not help unfortunately, had already tried but without the reboot, reboot didn't help. – Charlie Jan 19 '23 at 13:08
  • It's possible that the new scheduler in Windows 11 is ignoring it. Can you still go back to Windows 10? – harrymc Jan 19 '23 at 13:24
  • I already tried this approach on win10, and win 11 still has the background / foreground applications preference. Have now verified it's a problem related to the efficiency cores. – Charlie Jan 19 '23 at 13:27
  • Try [this method](https://www.technewstoday.com/cpu-priority-to-prefer-foreground-apps/) to prioritize background services (and maybe penalize foreground ones). – harrymc Jan 19 '23 at 13:35
  • That appears to be a gui approach to the regedit you proposed before... – Charlie Jan 19 '23 at 13:42
  • The regedit method had no way to *prioritize* background tasks, which this seems to do, which is why I suggested it. But it just might only be bad phrasing by Microsoft. – harrymc Jan 19 '23 at 13:49
0

You can go into the Task Manager -> Details page and right-click your process. With 'Set priority' you can set it to real time, which should fix the performance drain. However, you do have to do this every time you start the program.

Vincent
  • 19
  • 4