I have a Windows 11 laptop (Flow x16) connected to an external "secondary" monitor. I use Rstudio
for some CPU intensive computations. When Rstudio
is on my laptop's monitor, the CPU is maximally utilized:

The strange thing happens when I move Rstudio
to the secondary monitor and change focus to something else, the CPU utilization drops significantly:

Setting focus back on it doesn't change the CPU utilization. If I move Rstudio
to the primary (laptop) monitor and change focus, then after 2-3 seconds the CPU will again go to max, as it should.
Windows 11 is a clean install with nothing else installed except drivers. I don't think this issue was prior to the recent 24H2 Windows 11 update.
Some observations
- When I run the same code within
cmd
then the CPU is at max, irrespective of where thecmd
window resides. But I also doubt this has anything to do withRstudio
itself. - When I make the external monitor my primary monitor, then this issue no longer manifests on any of the monitors.
Preliminary solutions
- The laptop is on "Best Performance" power mode. Looking further in task manager, it seems the computations are moved exclusively to efficiency cores when on the secondary monitor. This article discusses a similar topic. A suggested workaround is to simply put Rstudio's underlying
R
session to "above normal" priority, for example by puttingtools::psnice(value = -5)
within.Rprofile
so it is applied on startup and every child process.