On 2022/03/20 18:13, Stuart Henderson wrote: > On 2022/03/20 18:13, Solene Rapenne wrote: > > I'm proposing a very simple change to the automatic policy of the CPU > > frequency scheduler. > > > > Currently, every 100ms the scheduler is doing this: > > > > - when the CPU load exceeds the threshold, CPU frequency is set to the > > maximum and the variable downbeats is set to 5. > > - when the CPU load is below the threshold, downbeats is decremented, if > > it's == 0 then the CPU load is reduced to 0 > > > > my proposal is to change the downbeat to be adaptive to the load, instead > > of setting it to 5 all the time, I propose to increment it with a limit > > of 5. Instead of having the frequency set at max for 500ms (5 cycles) > > every time the CPU usage is above the treshold, we will keep the > > frequency high for a number of cycles depending how long it was high > > (up to 5). So, in case of short CPU usage burst like opening a new MP3 > > file for decoding or a click on a GUI, we have a frequency burst of > > 100ms instead of 500ms.
Running with this now btw (on AC power, but I have #ifdef'd out the relevant parts of kern/sched_bsd.c). Watching with 'iwatch -i0.05 apm' it seems to be reacting nicely to changes in use, for example a very short blip at full speed when opening a new term and it drops down again quickly. And stays at high cpu during compiles as I'd expect. Also importantly, it stays at low speed with a browser with various tabs running, during which time there is some cpu load but not a high demand. > > I've been using it for a few days, I noticed a huge battery life > ^^^^^^^^^^^^^^^^^ > > improvement with no responsiveness change. > ^^^^^^^^^^^ > > This (and the couple of complaints from people who have now seen the fan > stay on when plugged in, when it didn't previously) suggests that mwait > is not everything and it _would_ still make sense to still have a way to > set automatic frequency rather than just force-high for plugged-in use > too... Just remembered I've got a shelly 1pm coming next week for something else, before I do that I can bodge a cable to plug my laptop in through it and get some figures that I'm hoping should be a bit more useful than the instantaneous readings from my UPS. (As of next month's prices here, 10W continuous will be approx GBP30/year, I've been trying to drop my base load as much as I can, everything helps!)