LWN.net Logo

Frequency vs. power consumption

Frequency vs. power consumption

Posted Feb 26, 2012 5:03 UTC (Sun) by jzbiciak (✭ supporter ✭, #5246)
Parent article: The Linaro Connect scheduler minisummit

Because CPU power consumption often rises as the square of the core clock frequency, you typically get the best battery life by running the CPU at the lowest frequency that gets the work done in time.

If I'm not mistaken, dynamic power is linearly proportional to clock speed, holding all other things constant. (Leakage power remains constant.) Both dynamic and leakage power, though, tend to be proportional to the square of voltage. (Power is V2 / R.) Now, if you need to increase voltage to get to a higher clock speed, then yes, the statement is true to an extent, but not all systems adjust voltage with clock frequency.

BTW, there's another reason running the CPU at a higher clock doesn't always help. If you have a memory-bound workload, such that you spend most of your time in cache miss cycles, you're just going to burn a lot of clock power running the CPU faster, without speeding up the workload appreciably. This is mentioned in the article as a possible reason to move a task from the A15 to the A7, but it's also just a more general argument for setting the "right" clock rate based on what you know of the task.


(Log in to post comments)

Frequency vs. power consumption

Posted Feb 27, 2012 20:08 UTC (Mon) by PaulMcKenney (subscriber, #9624) [Link]

Generally agreed on your point about voltage, frequency, and power, and hence the word "often" in my original. ;-)

Your point about a cache-missy workload being a good candidate for lower CPU frequency is a good one, depending of course on how much of the memory system is in the same clock domain.

Frequency vs. power consumption

Posted Feb 29, 2012 18:05 UTC (Wed) by jzbiciak (✭ supporter ✭, #5246) [Link]

I just amused myself wondering what a good API would be for hinting to the OS about this... Maybe not madvise(MADV_CACHE_THRASHY) (for the simple reason that it's an attribute of the task, not an attribute of a memory page), but then what?

On a more serious note, I wonder if the OS could use hardware performance counters to auto-detect this sort of stuff. If the ratio of stall to execute cycles is above a certain threshold, decrease the task's desired clock speed, and if it's above another threshold, increase it. Hmmm....

Frequency vs. power consumption

Posted Feb 29, 2012 18:06 UTC (Wed) by jzbiciak (✭ supporter ✭, #5246) [Link]

Errr... that second statement should be below, not above.

Frequency vs. power consumption

Posted Mar 27, 2012 12:51 UTC (Tue) by chrisr (guest, #83108) [Link]

I don't believe it would be reasonable for the kernel to expect applications to tell it how cache-missy or otherwise they are. I would expect the cache miss ratio is likely to vary significantly across portions of an application and anyway cores often come with variable cache sizes. This makes it hard to determine what an application will perform like on any particular platform.

For me, this means that the only reasonable way to know about a thread's optimal runtime performance requirement is therefore to measure it while its running and age older measurements as we do with load measurement.

Whether it is possible to do this in a generic enough manner that it could be accepted into a mainline Linux Kernel is IMO a different matter to the technical problem of doing the measurement and using those indications for something useful, and probably will take longer too :)

Frequency vs. power consumption

Posted Mar 27, 2012 14:06 UTC (Tue) by jzbiciak (✭ supporter ✭, #5246) [Link]

Well, remember, madvise() is a hint. I think you and I likely agree that the system should run reasonably if nobody ever calls it in a typical application. It exists to help you take performance from "reasonable, if not quite optimal" to "stellar." So, if you're bzip2 you might consider throwing that flag. As you said, though, it's less clear if you're a web browser or office app. (Although, I strongly suspect both are more cache thrashy than they'd like to be, even when idle.)

That said, my madvise() proposal above was partly tongue in cheek. (It was also partly inspired by MADV_RANDOM.) It would be interesting though, to try to characterize apps by their recent cache miss ratios and use that to make CPU affinity selections as well as operating frequency selections.

Actually, you need two ratios: Hit/(hit+miss) and Stall/(stall+non-stall) cycles. You could have a fairly high miss ratio with a low stall ratio. A faster CPU still helps you. The high miss ratio suggests streaming or a large working set, but there's enough prefetching and/or inherent parallelism the CPU can stay busy. A high miss ratio with a high stall ratio suggests a more serial program that's staying memory bound. Lower frequency or a slower CPU is unlikely to hurt the performance of the program.

Anyway... I've devolved into ramble-ville.

Calculate power consumption

Posted Feb 29, 2012 17:03 UTC (Wed) by Logicalis (guest, #83232) [Link]

Great info. Here is a great "power consumption calculator" resource for estimating how IT virtualization can impact carbon/energy usage: http://www.us.logicalis.com/tools/it-carbon--power-consumption.aspx.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds