from Hacker News

Automatic CPU speed and power optimizer for Linux

by chetangoti on 10/17/21, 6:05 AM with 127 comments

  • by tamrix on 10/17/21, 10:07 AM

    If you're using Intel 8th gen or above. (7th gen supported if you manually set the flag each boot) you've got speedshift which the CPU will automatically auto scale itself. (changing the p-states)

    The CPU itself can change frequencies much faster on its own instead of the software based speedstep which programs like this controlled.

    This eliminates the need for an on-battery or plugged-in performance mode because it changes frequencies so fast, you're no longer losing performance by waiting for the software to speed up the cpu. So you can keep it on all the time.

    For these CPUs, all this is in the kernel and enabled by default.

  • by tomxor on 10/17/21, 11:42 AM

    > Using tools like TLP will help [...] but it also might come with its own set of problems

    I recently figured out TLP was the source of a couple of irritating issues for me on an XPS 9370:

    - Bluetooth audio continually cutting in and out, only when wireless module on AC "non power saving mode"!?!

    - DC bias on the audio out jack, on both modes, worse on power saving. (forcing a power amp into self protect mode).

    Both resolved by disabling TLP entirely. I knew TLP was not a set and forget tool, but it's easy to forget when on some machines it's fine (and necessary, especially older laptops). But then changing to a new machine where it causes lots of issues. It was a good reminder that these tools need to be used with care because they often exploit unusual hardware modes and can have strange side effects.

  • by 1kurac on 10/17/21, 9:55 AM

    A similar tool to prolong laptop autonomy is XSuspender <https://kernc.github.io/xsuspender/>. It configurably SIGSTOP-s unfocused X11 applications. It is, sadly, XWindows-only.
  • by CyberShadow on 10/17/21, 7:11 AM

    CPUs already adjust their own frequency based on load and temperature (maybe with some help from kernel drivers). It would be nice if the README explained how this tool is different from that.
  • by fooctrl on 10/17/21, 12:00 PM

    auto-cpufreq author here, I'm here if you have any questions!
  • by rcarmo on 10/17/21, 8:41 AM

    I’d like something that would actually disable CPU cores temporarily besides fiddling with governors and clock speeds. I currently do that with a cpufreq GUI wrapper, but it isn’t automatic.
  • by glandium on 10/17/21, 8:25 AM

    > For example, CPU will run using "performance" governor with turbo boost enabled regardless if it's plugged in to power or not.

    Don't most distros default to ondemand or schedutil governor these days?

  • by geokon on 10/17/21, 7:47 AM

    What's a straightforward way to clock down a CPU to a fixed rate?

    I sometimes want to run benchmarks and I'd like my laptop to stick to one speed

    I understand it's a bit problematic with the latest CPUs bc the gap between turbo and non turbo is so huge - and the CPU is in turbo a good chunk of the time (and your cache performance will be very different running at 1Ghz vs 4Ghz)

    Anyone have a good solution?

  • by londons_explore on 10/17/21, 10:45 AM

    Whats the overhead of this daemon running all the time? It uses RAM which effectively increases power consumption because now something else is pushed out of the cache. It polls therefore waking the CPU every few seconds, even if perhaps nothing else is going on on the machine and the CPU would otherwise be idle.

    I wonder if its benefits outweigh the disadvantages. Would be good to have numbers for a bunch of different hardware configs...

  • by jmngomes on 10/18/21, 2:38 PM

    TLP [1] covers this use case pretty well, although I confess I didn't expect this to still be an issue these days (until I bought my latest laptop and had to run TLP on Kubuntu 20.04 to ensure battery life on par with the factory specs, and TLP almost tripled it)

    [1] https://wiki.archlinux.org/title/TLP

  • by bravetraveler on 10/17/21, 2:14 PM

    Cool and all, but 'tuned' does this and so much more.

    Custom profiles that can control boot command line options, sysctl parameters, sysfs, and so on.

  • by christkv on 10/17/21, 10:33 AM

    I’ve found http://tbswitcher.rugarciap.com/ that can turn of turbo boost on intel macs to be useful when on battery and compiling. Since 100% cpu usage will run at a much lower TDP and not kill my laptop battery as fast.
  • by 29athrowaway on 10/17/21, 2:10 PM

    For games you can use gamemode.

    https://github.com/FeralInteractive/gamemode

    You run the game with gamemoderun and it will do few adjustments for you, including adjusting the CPU governor.

  • by bno1 on 10/17/21, 10:04 AM

    I wish the readme would compare it to laptop mode tools [1].

    [1] https://wiki.archlinux.org/title/Laptop_Mode_Tools

  • by wooque on 10/17/21, 12:21 PM

    The best thing battery wise for me was to actually disable turbo boost and limit max frequency.

    It can be done in TLP config.

  • by yewenjie on 10/17/21, 8:59 AM

    Can somebody with experience running this tell me if it actually works?
  • by shmerl on 10/17/21, 9:06 AM

    AMD are working on a better CPPC driver for schedutil for that.