3

I'm running a dual-boot Ubuntu MATE 16.04.3 LTS and Windows on a Thinkpad T430 (Core i7 dual-core, nominal 2.9 GHz clock, 8 GB RAM, 9-cell internal battery and 9-cell Slice battery). My battery life is excellent, as much as 10 hours of normal use on a full charge.

I recently had performance issues playing a game (Kerbal Space Program) on AC power, and found that the computer had been left in Power Saving mode, causing the CPU to run at lower clock speed than is necessary when I'm not trying to aggressively conserve energy. This probably occurred before I purchased the extended batteries, when I was trying to aggressively increase battery life with the original 6-cell battery.

I can easily switch the CPU back into Performance mode using the CPU Frequency Scaling Monitor widget that I've mounted in the system bar (which separately controls clock management of the real and virtual cores). I've examined the Power window of system settings and don't see any way to tell the OS to automatically switch between Power Saving (which I'd want when on battery power) and Performance (which I'd prefer when on AC power).

This similar question refering to end-of-life Ubuntu 14.10 may not be correct for my exact hardware. I can't tell if I have a Sandy Bridge CPU.

Zeiss Ikon
  • 5,128
  • Please see my answer below. Are you sure that CPU is the problem? According to game's system requirements it needs 1GB VRAM. Do you have dedicated video card? – N0rbert Dec 03 '17 at 15:24
  • No dedicated video (it's a Thinkpad -- did they ever offer such?). When I first installed KSP, it ran fine (about as well as my desktop system: Core2Quad 2.7 GHz, 8 GB RAM, GTx750); this has only become a problem in the last couple weeks. I haven't changed any game settings. Video has little effect on KSP performance anyway; it's usually CPU-bound due to the physics engine using only a single thread. – Zeiss Ikon Dec 04 '17 at 12:23

2 Answers2

5
  1. Create a file /opt/system_cupmode.sh using sudo

  2. Run the following command to give it the needed permissions

    sudo chmod +x /opt/system_cupmode.sh
    
  3. Open the file and add the following code:

    #!/bin/bash
    # This script will switch cpu mode to performance on charging automatically
    # Author: @saleh_awal
    

    tFile=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor if on_ac_power; then

    charging on

    if grep -qi "powersave" $tFile; then echo performance | tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor else echo "already updated to performance" fi else

    charging off

    if grep -qi "performance" $tFile; then echo powersave | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor else echo "already updated to powersave" fi fi

  4. Add a cronjob to your root user as follow:

    sudo crontab -e
    

    then add this line at the bottom of the file which will run the code every 10 seconds

    */10 * * * * /opt/system_cupmode.sh
    
Pablo Bianchi
  • 15,657
  • The script is very nice. However, I wanted to point out that the specified cronjob will not run the script every 10 seconds, but every 10 minutes as cron does not have sub-minute granularity. A workaround to run this every 10 seconds would be to add 6 cronjobs:
            • /opt/system_cpumode.sh
            • sleep 10; /opt/system_cpumode.sh
            • sleep 20; /opt/system_cpumode.sh

    ...

            • sleep 50; /opt/system_cpumode.sh
    – Sorin Dragan Dec 22 '22 at 11:45
0

I did some research. Its results is below.

I'm using Ivy Bridge i7-3537U on MATE with the same widget. My other CPU is Haswell i7-4790. According to sysfs they have only two governors

$ cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_g‌​overnors
performance powersave

It uses new intel_pstate driver.

Older CPU such as my Clarksfield i7-740QM are driven by acpi-cpufreq driver, it have 5 governors (conservative ondemand userspace powersave performance).

The current driver may be checked by cpufreq-info -d (from cpufrequtils package).

You can check your CPU with lscpu. I think you can monitor CPU actual frequencies with i7z or i7z_GUI (installable with sudo apt-get install i7z i7z-gui) or powertop (sudo apt-get install powertop, see Frequency stats tab).

On other thread it is explained how to switch off the intel_pstate driver. I tried so with my Haswell and Ivy Bridge CPUs, but I get very close results in Intel's LINPACK test.

I can conclude the following:

  • intel_pstate powersave governor is equivalent to the old acpi-cpufreq ondemand one;
  • it seems that you have already got peak performance from your CPU.
N0rbert
  • 99,918
  • I'll check the above, but if this is peak performance then I'm a little disappointed -- I was assured that a Core i5 or i7 with any core count would outperform the Core2Quad in single-threaded KSP at the same clock speed (due to the i* architecture doing more work per cycle). With my Core i7 stepping up to 3.4 GHz on demand, I don't get why it's hanging so badly. Guess I'll have to ask further on the KSP forums. – Zeiss Ikon Dec 04 '17 at 12:31