Power consumption reduction with powerd++

Started by becks0815, April 20, 2022, 08:00:40 PM

Previous topic - Next topic
April 20, 2022, 08:00:40 PM Last Edit: April 21, 2022, 09:19:36 PM by becks0815
And another one....

Just like with the C-states, I also played around with powerd. Tried to run my sys with "minimum" as power profile which resulted in an immediate drop in the CPU core temp on the most used core 3 by 4°C (from 60°C down to 56°C), but ended in network discos due to the cpu being overrun when trying to push 20 MB data/sec over the firewall.

Then I tried some settings with powerd and fine tune adaptive mode on command line, but this resulted in nor eal improvements.

And here comes powerd++ (https://github.com/lonkamikaze/powerdxx) which - according to the author(s) offers a much better way in handling/scaling the CPU based on the load.

Installation is pretty easy:

1) open the opnsense frontend, and under system -> settings -> misc disable powerd.
2) Open a shell on the FW box, change to the home directory of root, then install git:
# pkg install git

3) Clone powerd++, change to the directory, compile and install it:

# git clone https://github.com/lonkamikaze/powerdxx.git
# cd powerdxx/
# make
# make install


4) change the config for powerd++ by editing /etc/rc.conf:

# nano /etc/rc.conf

rc.conf:
powerdxx_flags="-a adp -n adp -m 480 -M 1600" # set adaptive mode, min frequency to 480 and max freq to 1600 MHz


5) Enable powerd++ and start it:

# service powerdxx enable
# service powerdxx start



Results on my end:
When running powerd in combination with minimum as cpu profile, idle temp of core 0 was 55-56°C but I ran into network disruptions as soon as I tried to push 12 MB/sec or more data from WAN to LAN. With powerd/adaptive I ended up on 59-60°C SPU core temp and 63°C under load, but was able to push 20 MB/sec without issues.

With powerd++ / adaptive (no other changes applied), idle temp is at 57°C and I have no network problems pushing 20 MB/sec with core 0 reaching 59°C max.

As soon as I can shutdown the box and plug in a powermeter I can have a look at how much difference this makes, but based on the initial results you can save some energy.

April 21, 2022, 12:50:44 AM #1 Last Edit: April 21, 2022, 12:52:20 AM by meyergru
1. You do not need to compile this package:


cd /tmp
wget -O powerdxx.pkg https://pkg.freebsd.org/FreeBSD:13:amd64/latest/All/powerdxx-0.4.4_1.pkg
pkg add powerdxx.pkg


2. In my case, the tool cannot be started:


service powerdxx onestart
Starting powerdxx.
powerd++: (EDRIVER) frequency control driver not supported: hwpstate_intel0
/usr/local/etc/rc.d/powerdxx: WARNING: failed to start powerdxx


This is due to this: https://github.com/lonkamikaze/powerdxx/issues/15

I.e. my CPU is already supported by hwpstate, such that powerd++ cannot be used.

3. Your link to the C-states thread is broken. This should be the correct one.
Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005

1100 down / 440 up, Bufferbloat A+

I have corrected the link. The forum software changed my data when I first saved it.

April 22, 2022, 05:07:14 PM #3 Last Edit: April 22, 2022, 06:05:50 PM by abulafia
I get a different error on OPNsense 22.1.6 (Intel i5250u / Qotom Q355G4):

Starting powerdxx.
powerd++: (ECONFLICT) a power daemon is already running under PID: 22
/usr/local/etc/rc.d/powerdxx: WARNING: failed to start powerdxx


PID 22 is, of course, the regular powerd:
22 root         20    0    12M  2240K select   0   0:46   0.00% /usr/sbin/powerd -b adp -a adp -n adp

So ... as per https://opensourcelibs.com/lib/powerdxx, I'll change over to powerdxx:

root@OPNsense:/tmp # service powerdxx onestart
Starting powerdxx.
powerd++: (ECONFLICT) a power daemon is already running under PID: 22
/usr/local/etc/rc.d/powerdxx: WARNING: failed to start powerdxx
root@OPNsense:/tmp # service powerd stop
Stopping powerd.
Waiting for PIDS: 22.
root@OPNsense:/tmp # service powerd disable
Cannot 'disable' powerd. Set powerd_enable to YES in /etc/rc.conf or use 'onedisable' instead of 'disable'.
root@OPNsense:/tmp # service powerd onedisable
powerd disabled in /etc/rc.conf
root@OPNsense:/tmp # service powerdxx enable
powerdxx enabled in /etc/rc.conf
root@OPNsense:/tmp # service powerdxx start
Starting powerdxx.


Stopping powerdxx and running it in foreground verbose mode confirms it works:
root@OPNsense:/tmp # powerd++ -vf -a adp -n adp -n 75% -M 1600
powerd++: cannot read hw.acpi.acline
Terminal Output
        verbose:               yes
        foreground:            yes
Load Sampling
        load samples:          4
        polling interval:      500 ms
        load average over:     2000 ms
Frequency Limits
        battery:               [500 MHz, 1600 MHz]
        online:                [500 MHz, 1600 MHz]
        unknown:               [500 MHz, 1600 MHz]
CPU Cores
        CPU cores:             2
Core Groups
          0:                   [0, 0]
          1:                   [1, 1]
Core Group Frequency Limits
          0:                   [500 MHz, 1601 MHz]
          1:                   [500 MHz, 1601 MHz]
Load Targets
        battery power target:  50 % load
        online power target:   50 % load
        unknown power target:  75 % load
Temperature Throttling
        active:                yes
        source:                dev.cpu.%d.temperature
          0:                   [95 C, 105 C]
          1:                   [95 C, 105 C]
power: unknown, load:  912 MHz,  54 C, cpu.0.freq: 1601 MHz, wanted: 1216 MHz
power: unknown, load:  900 MHz,  54 C, cpu.1.freq: 1601 MHz, wanted: 1200 MHz
power: unknown, load:  617 MHz,  54 C, cpu.0.freq: 1200 MHz, wanted:  822 MHz
power: unknown, load:  605 MHz,  53 C, cpu.1.freq: 1200 MHz, wanted:  806 MHz
power: unknown, load:  327 MHz,  54 C, cpu.0.freq:  800 MHz, wanted:  436 MHz
power: unknown, load:  308 MHz,  53 C, cpu.1.freq:  800 MHz, wanted:  410 MHz
power: unknown, load:   27 MHz,  54 C, cpu.0.freq:  500 MHz, wanted:   36 MHz


However, it does not seem to enable the turbo mode (when setting max MHz to 2700):

power: unknown, load: 1002 MHz,  69 C, cpu.0.freq: 1200 MHz, wanted: 1336 MHz
power: unknown, load:  993 MHz,  68 C, cpu.1.freq: 1200 MHz, wanted: 1324 MHz
power: unknown, load: 1093 MHz,  70 C, cpu.0.freq: 1300 MHz, wanted: 1457 MHz
power: unknown, load: 1075 MHz,  68 C, cpu.1.freq: 1300 MHz, wanted: 1433 MHz
power: unknown, load: 1159 MHz,  71 C, cpu.0.freq: 1400 MHz, wanted: 1545 MHz
power: unknown, load: 1117 MHz,  68 C, cpu.1.freq: 1400 MHz, wanted: 1489 MHz
power: unknown, load: 1110 MHz,  70 C, cpu.0.freq: 1500 MHz, wanted: 1480 MHz
power: unknown, load: 1045 MHz,  67 C, cpu.1.freq: 1500 MHz, wanted: 1393 MHz
power: unknown, load: 1095 MHz,  69 C, cpu.0.freq: 1400 MHz, wanted: 1460 MHz


Perhaps a hardware CPU temperature protection kicks in?

Sorry if I can't help here as I am not the developper of powerd++ and I also don't have any other hardware to test it.  :-\

Just a small feedback: I have tested the settings now for the past days, including long sessions with stress tests (running Soulseek), and the initial results haven't changed: the system runs stable, even the frontend is pretty fast reacting to update/changes, I haven't had any disconnects, timeouts or network interruptions (like with powerd/min), and still the CPU cores are cooler than before. Core 0, the most stressed one, even goes down to 48°C for some seconds, something i haven't seen before since I bought the box 1y ago. Max temp under heavy load is 55-56°C on that core (before: 63-65°C).

I hope I finally have time to assemble the power monitor (ESP8266/INA219) I plan to use for all hardware pieces running on 12V and then find a timeframe I can shut down the FW without interrupting anyone.


Have you found a way to make this stick / be applied on each boot? It seems that manually changing it does not survive a reboot /upgrade