As far as I can tell, this just switches the cpufreq governor based on whether the laptop is on AC or not. Tools to do this have existed for at least a decade, and integrated into various desktop environments too, so this isn't really novel in any way.
It also suggests using "powersave" on battery, based on the old idea that lower CPU frequencies save energy. This is not a given; lower frequencies use less power but also take longer to get the same amount of work done. While the CPU is active, it is consuming static power regardless of frequency. This has gotten even more significant with newer CPUs.
What the optimal power saving config is varies from system to system. Ultimately, what you need is to actually benchmark the performance and energy consumption of your system. It's complicated and you also have to deal with things like switching latencies so the cpufreq governor and scheduler can make optimized decisions. Most PCs don't really do a good job of this at all, which is one reason why battery life can be all over the place.
Sadly, switching to the "powersave" governor may not, in fact, end up saving you power, depending on what you're doing :)
> It also suggests using "powersave" on battery, based on the old idea that lower CPU frequencies save energy. This is not a given; lower frequencies use less power but also take longer to get the same amount of work done.
Hmmmm... I've always heard from chip engineers that power consumption / heat dissipation was not linear compared to clock speed. I'd be very surprised to find a case where a linear amount of work to be done by the CPU would cause more energy consumption overall at lower clock speed then the same task ran on the same CPU in a shorter timeframe, but at a higher clock rate.
I do agree that if the task takes longer to run, there's a longer timeframe where more scheduling/switching and whatnots needs to be done, so it's not a totally linear increase in time, but can that really be sufficient to offset the energy consumption when running the CPU at an higher clock speed?
There has to be some numbers out there: it's not hard that hard to test.
EDIT: as per the other comments, googling "race to idle" and "race to sleep" which may enlighten my curious self
Power consumption through an asic is P=CfV^2 aka power is capacitance times frequency times voltage squared. So power does scale linearly with frequency.
When you gate on/off portions of a chip, you are changing the capacitance.
What that equation doesn't tell you is that the voltage necessary to make a chip run at 4GHz is higher than the voltage it needs to run at 1GHz. So in practice with real CPUs, increasing frequency also means increasing voltage, and thus power does not increase linearly. (Unless you have a chip that's configured to idle with unnecessarily high voltage.)
> Hmmmm... I've always heard from chip engineers that power consumption / heat dissipation was not linear compared to clock speed. I'd be very surprised to find a case where a linear amount of work to be done by the CPU would cause more energy consumption overall at lower clock speed then the same task ran on the same CPU in a shorter timeframe, but at a higher clock rate.
Both cases ("slower is better" and "faster is better") are true at different points on the frequency curve, because the frequency (hereafter "F") and power (hereafter "P") relationship has both linear and superlinear terms.
To a first order approximation, dynamic power (roughly the power actually used to do work) scales with F^3, but chips also have a significant static power draw as well: power they draw for just being on. Actually, the relationship is more complicated than that since static power may also depend on V, hence indirectly on frequency, but the bottom line is that as you reduce frequency to zero power use doesn't go to zero but asymptotically approaches some non-zero plateau.
So imagine a simplified CPU where we care only about the order-0 and order-3 terms, and it happens that power goes like (P in W, F in MHz):
P(F) = 2 + 1e-10*F^3
That is, this chip draws at least 2W at any frequency, plus a cubic term in F.
This gives a power curve like this [1] where I've also plotted "work vs energy" which is energy efficiency: how much computation you can do for a given energy input (this is simply F/P).
As you can see, power use increases in a cubic way to the right, but has an asymptote at 2W on the left. Work/energy has a maximum in the middle: at too low frequencies, you are doing very little work/time but paying the full 2W cost, while at the right the cubic term kills power: P increases with F^3 but work only with F. The most efficient spot is somewhere in the middle. Let's call this point Feff.
So it never really makes sense to run your CPU at less than Feff: you are less efficient and it takes longer. It can definite makes sense, however, to run your CPU at more than Feff: you use somewhat more energy but get your work done faster. People don't buy 5 GHz CPUs because they just want their work done efficiently, after all: they want it done fast too.
That's what a lot of the discussion misses: it's not a one dimensional problem that can be solved in terms of joules and MHz: it depends on your time preference too. That's why there are so many tunables, such as Intel's EPP (energy performance preference).
Different processes may have different ideal F values as well: if you have a periodic job running in the background that takes 1s of (nominal) CPU every minute, you won't care if it is on your CPU for 0.5s or 2s, as it runs on a fixed schedule anyway which is much less than a full CPU: this should run at Feff. OTOH when you are compiling a source file and twiddling your thumbs there might be a big difference between 5 and 20 seconds.
This is really only brushing the surface: there are a lot of additional considerations too: e.g., the whole chip may have a power limit, so it may not be possible to go all the way to right on the F graph, especially if multiple cores are running: even if your "performance preference" is way to the right (prefer a higher work/rate regardless of the power cost) you might get the fastest work rate by running more cores at lower F, or even one core at lower F to avoid throttling (because running at F is generally more efficient than running at F-d and F+d in a 50/50 ratio, due to the cubic term, so throttling is inherently inefficient).
> Sadly, switching to the "powersave" governor may not, in fact, end up saving you power, depending on what you're doing
Independently of whether that's true, isn't most consumer hardware (laptops) running "idle" most of the time?
Not setting "powersave" might be better if you want to compile something, transcode a video or do some machine learning and turn the machine off as soon as it's done. But that's hardly how a majority uses their devices.
> Independently of whether that's true, isn't most consumer hardware (laptops) running "idle" most of the time?
Yes, which is why you want to become idle as fast as possible - and that means running at the fastest clock speed when you need to get some work done. Otherwise you are extending the amount of the time system is not idle, which has a fixed power cost beyond the CPU cores themselves.
Here's a Lenovo power optimization guide. It's for servers, but the same principles apply to pretty much all modern systems. Spoiler alert: the "ondemand" governor has the highest energy efficiency, significantly higher than "powersave" (page 14). The newer schedutil governor (page 23) is even better, over 34% more power-efficient than powersave.
"Powersave" means saving power, it doesn't mean saving energy. Your battery holds a fixed amount of energy, not a fixed amount of power. Energy is what matters.
> "Powersave" means saving power, it doesn't mean saving energy. Your battery holds a fixed amount of energy, not a fixed amount of power. Energy is what matters.
Ignoring everything else, your battery doesn't hold a fixed amount of energy either. Or, if it does, it doesn't deliver a fixed amount. The energy you get out depends on the load. If you draw enough power that it heats the battery, you'll get less energy out. Of course, if you draw so little energy that self discharge becomes significant, you'll get less energy out.
As with the rest of the discussion, there's clearly a balance to be had, but it's hard to make the optimum choice because the systems usually don't know the load profile of (immiment) future work, and there are many systems that interact, and there may be no part of the system that has enough information to make an overall decision. That said, there's clearly been lots of progress on getting quite good results in most scenarios.
> "Powersave" means saving power, it doesn't mean saving energy.
Powersave means saving energy (for a given amount of work), despite the name. Any other behavior is a bug. It usually saves energy by running at a lower frequency, where the frequency/watt and work/joule are better (those aren't the same: there is a region where the first is better but the latter is worse, and you want to avoid that!).
"Race to sleep" isn't binary: it's not a choice between the slowest supported speed and the fastest. Rather, you can select any supported speed. The fastest speeds (usually north of 3 GHz) will almost never provide the best work/joule, regardless of whether you sleep earlier.
That's the entire governor. It sets the lowest frequency. This is the documented behavior. Not the frequency with the highest performance per watt. The lowest frequency, period.
Yes, "race to sleep" isn't binary, which is why we have smart modern governors that do a very good job at picking appropriate frequency states - but just as the highest turbo is almost always a bad idea, so is the lowest state, which is what "powersave" does. "ondemand" is more power efficient than "powersave", and "schedutil" even moreso, on modern CPUs.
Right, because the lowest supported frequency is supposed to be the most energy efficient frequency, Feff, at least on Intel chips. I.e. it is the minimum in the joules/work chart.
After all, there's no point
running at a lower frequency: those frequencies are always dominated regardless of your time/energy preference, so Intel claims to set Fmin to Feff.
So lowest freq is a good proxy for "I only care about efficiency".
That said, powersave is a bit ambiguous: it's a policy in more than one driver. For example, intel_pstate, the default recommended driver for Intel chips, has powersave and performance governors too, and there powersave is much more sophisticated and can run at high frequencies.
OK, I actually read the Lenovo paper and it seems fine.
One big difference with what I'm trying to claim is that what I'm saying considers only the power use of the CPU itself: i.e., the thing whose power use varies with frequency. From the CPU manufacturer's point of view, that's all they can really do.
The Lenovo paper is looking at total system power, and the way they calculate efficiency includes the system power in the efficiency calculation. This pushes the efficiency point well above what you'd get from looking at the CPU alone.
Both approaches are right some of the time: on a laptop where the rest of the system is running regardless, you probably want to consider only the CPU power in the efficiency calculation: if your CPU work finishes more quickly it's not going to stop the draw from the screen, wifi chip, etc.
OTOH on a server if you size your fleet based on the total work, you should really use total power since if your work takes less time you need fewer total servers (or fewer cloud CPU hours, etc) so the system power is also saved.
I think it’s more that a lower TDP might mean the compile takes 50% longer but I’m still multitasking and I might get 2h more out of a battery charge than when the cpu is spiking to max TDP
Yes, that's mentioned in the parent comment. The problem is that at slower frequencies also keep the core powered up for longer, which is often bad for power consumption. For many mobile devices, it's often much better to ramp up the processor to 100% and get the work done quickly, then rush to idle as quickly as possible.
This strategy is typically known as "race-to-sleep" or "race-to-idle". Just figured it was worth mentioning, as there's lots of additional information that can be found if you know what to search for.
I see what you’re saying but I believe there’s an issue at the silicon level where the gates literally use more power to do the same work at higher frequencies.
It's a well-known feature of CMOS gates that they consume almost all of their power at the moments of switching. AFAIK only recently has static leakage become substantial, necessitating power gating.
To add context: this is especially true for tasks that are likely to end in the device sleeping again. Two examples: user checking phone after hearing a notification sound or opening the laptop lid to check train departure time in the browser (then closing it again).
The faster the CPU deals with the task once the device is fully awake the shorter the time other power hungry parts of the system (like screen) need to be awake.
That's why slow phones, where the user needs to wait for their browser to finish loading the page will never be battery effective.
My view is that this works for CPU heavy tasks, but not for low-frequency repeated background tasks like browser window drawing, where if you speed up your CPU you just burn energy to get a higher framerate, something you generally don't care about on powersave.
So optimally you'd want to clock up for "burst tasks" and keep freq low for "per-frame tasks". But I don't know of a scheduler that does that, or even how it could do it. But if you assume most of your battery loss will be to frame tasks, powersave makes sense.
These kinds of things do get used in laptops–the keyword you're looking for is "race to idle", as the processor quickly clocks up and then rushes back to a lower-frequency state or even goes back to sleep. On the mobile side, I do know that Apple did work a couple years back to scale up to maximum clock rate very quickly to handle user-interactive tasks: https://www.anandtech.com/show/13392/the-iphone-xs-xs-max-re.... Then they'd ramp it back down to save on battery life.
I am not a hardware engineer, so I don't have actual stats on me, unfortunately. But the reasoning behind it makes sense: https://mjg59.livejournal.com/88608.html. Given that everyone is doing it, I am sure that there is data that shows that; I just don't have it :P
Well you can take the battery size (and screen times you get from those). iPhone batteries are tiny compared to android. Like seriously tiny that my 10Wh Powerbank can charge it 5 times with some to spare (I only really get 4 due to losses but still).
So yes comparing iPhones to anything else highly suggests that the tuning Apple did pays off. That being said: I’m not aware of a useful comparison. I’m not even sure how you would design something like that, ie what would you like to keep constant?
With the modern web there is no "rush back to idle". Browsers will burn your CPU until you turn off your browser, which in most cases is only when you turn your computer off.
Assuming you are using a reasonable browser with a reasonable set of websites open, a browser should not really burn unbounded CPU in the background. Tabs that do are generally throttled, allowing the scheduler to burst their work and then have the processor go back to sleep.
It also suggests using "powersave" on battery, based on the old idea that lower CPU frequencies save energy. This is not a given; lower frequencies use less power but also take longer to get the same amount of work done. While the CPU is active, it is consuming static power regardless of frequency. This has gotten even more significant with newer CPUs.
What the optimal power saving config is varies from system to system. Ultimately, what you need is to actually benchmark the performance and energy consumption of your system. It's complicated and you also have to deal with things like switching latencies so the cpufreq governor and scheduler can make optimized decisions. Most PCs don't really do a good job of this at all, which is one reason why battery life can be all over the place.
Sadly, switching to the "powersave" governor may not, in fact, end up saving you power, depending on what you're doing :)