Jump to content
XPEnology Community

CPU Throttle Script Tutorial


wakkawakka

Recommended Posts

I just discovered that the xpen .nl site is gone - very, very, very upsetting to see that.

 

As a new user and operator of Xpenology (within past 2 months) that site and the TUTORIALS were invaluable to me. I am very displeased to see that the site owner was forced to remove all content due to Synology greed/bullying. That action has completely soured me to Synology and I will not ever purchase their product. /end rant.

 

To the point of my thread. Before the wonderful aforementioned site had to be forcibly removed, I downloaded the .sh script and the win app that were part of the CPU THROTTLE tutorial. I read the tutorial when it was available but did not get a chance to set it up until last night which is when I saw the removal of all content. I immediately checked this forum hoping to find a tutorial and did see a related thread, however, the linked stuff does not work.

 

TL;DR - Does anyone have the CPU THROTTLING TUTORIAL, please?!

Link to comment
Share on other sites

I just discovered that the xpen .nl site is gone - very, very, very upsetting to see that.

 

As a new user and operator of Xpenology (within past 2 months) that site and the TUTORIALS were invaluable to me. I am very displeased to see that the site owner was forced to remove all content due to Synology greed/bullying. That action has completely soured me to Synology and I will not ever purchase their product. /end rant.

 

To the point of my thread. Before the wonderful aforementioned site had to be forcibly removed, I downloaded the .sh script and the win app that were part of the CPU THROTTLE tutorial. I read the tutorial when it was available but did not get a chance to set it up until last night which is when I saw the removal of all content. I immediately checked this forum hoping to find a tutorial and did see a related thread, however, the linked stuff does not work.

 

TL;DR - Does anyone have the CPU THROTTLING TUTORIAL, please?!

Who said it was a action of synology?

Link to comment
Share on other sites

Special thanks Poechi

 

This tutorial describes how to control your CPU frequency when power is not needed and thus resulting in lower power consumption of your NAS.

 

 

Prerequisites:

XPEnoboot 5.1-5022.3

CPU Power Saving script (Scripts section)

WinSCP (Tools section)

 

 

Attention:

If you have an Intel based CPU, make sure that the power setting options in your BIOS is set to ‘OS Controlled‘. In case of the HP Gen 8 micro server, save this setting as ‘User default‘ or else the bios reset bug will reset it at reboot.

 

 

Check power state

Before installing the script, let’s check your current CPU power state.

1-Start a SSH session to your NAS and login as ‘root‘.

2-Type the following command:

grep "MHz" /proc/cpuinfo
 

and press Enter.

3-Example output of an AMD 2 core processor (HP N54L):

cpu MHz         : 2196.380
cpu MHz         : 2196.380
 

4-What this shows is that your cores are running at max power and thus using max power consumption.

5-Now that we know this we can use the script to bring power state level down to save power. Once the script is enabled the power states are automatically toggled according to the load of the CPU.

 

 

Installation:

1-Download the script for AMD or Intel from the DSM software page, under the Scripts section.

S99PowersavingAMD.zip

http://uloz.to/xXvu2WX2/s99powersavingamd-zip
 

S99PowersavingINTEL.zip

http://uloz.to/xbdrT8xC/s99powersavingintel-zip
 

2-Download and install WinSCP and make a connection to your NAS. Start ‘WinSCP‘ and start a new connection with protocol ‘SCP‘. Enter the ip address or hostname of your NAS and login as ‘root‘. Click on ‘Login‘ and fill in your password.

winscp.png

3-Upload the script to the

/usr/local/etc/rc.d/
 

directory.

Win_SCP.jpg

4-Right click on the script and choose ‘Properties‘ and give it ‘Execution‘ rights for the owner. Octal : 0744

Win_SCP-2.jpg

5-Close WinSCP.

6-There is a possibility that after your disk are woken up from hibernation that the power state is overwritten. To fix this you can make an adjustment in crontab that runs the script say every 15 minutes.

7-Start a SSH session to your NAS and login as ‘root‘.

8-Type the following command:

vi /etc/crontab
 

9-Go to the end of the last line, press ‘Insert‘, press ‘Right arrow‘ and press ‘Enter‘. This will get you on the next line.

crontab1.jpg

10-Type the following command and use ‘Tab‘ for spacing and use the correct script name accordingly:

*/15 * * * * root /usr/local/etc/rc.d/S99PowersavingAMD.sh
 

crontab21.jpg

11-Press ‘Esc‘ and type ‘:wq‘.

12-Reboot your NAS.

 

 

Check power state again

1-After the reboot start a SSH session to your NAS and login as ‘root‘.

2-Type the following command:

grep "MHz" /proc/cpuinfo
 

and press Enter.

3-Example output of an AMD 2 core processor (HP N54L) after applying the script:

cpu MHz         : 800.000
cpu MHz         : 800.000
 

4-This result shows current power state under no load. When CPU load increases, the power states automatically toggle up so that your CPU runs at higher frequencies. When CPU load decreases, the power state is adjusted accordingly down, saving energy.

5-If you want to check if the power state has changed after waking up from hibernation type the following command in SSH:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
 

If the answer is ‘performance’ that means the governor has been changed. If you check again in a few more minutes (maximum 15) it should revert to ‘conservative‘ due to the crontab schedule.

 

Note

This tutorial is based on the following topic at xpenology.com:

 

 

Link to comment
Share on other sites

  • 7 months later...
  • 1 month later...

omg, THANK YOU too! I almost gave up on this when I could no longer find the shell scripts.

 

After applying the procedure, my Celeron J based ASROCK board is now at 1.3GHz as opposed to 1.9GHz. That's not quite the savings I was hoping for but is that where it should be? Or

Link to comment
Share on other sites

  • 1 month later...

I assume this is only for people installing XPenology on a physical device? Anyone tried using a throttle script for ESXi or another hypervisor?

Looks like XPenology is using quite a lot of CPU (unnecessarily), but I haven't had the time to take a deeper look at it yet.

Link to comment
Share on other sites

So I made a test with this script and the result surprised me:

 

Power consumption with script:

CPU idle and HDD's run: 22,8-23 watt

CPU idle and HDD's spin down: around 15,1 watt

 

Power consumption without script:

CPU idle and HDD's run: 22,0 - 22,1 watt

CPU idle and HDD's idle: 12,3 - 12,4 watt

 

Test with a Profitec KD 302 to measure the power consumption. My hardware is in my signatur. So I guess that this how-do is out of time and only valid for older XPEnology and DSM-firmware. If your really want to use it just test the power consumption if its good for your hardware or not. In my case I don't use it.

Link to comment
Share on other sites

I guess this script is useless with the latest DSM-firmware. The powermanagement within DSM works better instead of the script. Just my two cents. With older XPEnology and DSM maybe it's a good workaround for powermanagement but not with the latest ones. Just look at the power consumption of my "NAS" I posted one befor yours.

Link to comment
Share on other sites

When you run the command to show current CPU frequency after running the script, does it show a lower frequency, or same frequency?

 

So I made a test with this script and the result surprised me:

 

Power consumption with script:

CPU idle and HDD's run: 22,8-23 watt

CPU idle and HDD's spin down: around 15,1 watt

 

Power consumption without script:

CPU idle and HDD's run: 22,0 - 22,1 watt

CPU idle and HDD's idle: 12,3 - 12,4 watt

 

Test with a Profitec KD 302 to measure the power consumption. My hardware is in my signatur. So I guess that this how-do is out of time and only valid for older XPEnology and DSM-firmware. If your really want to use it just test the power consumption if its good for your hardware or not. In my case I don't use it.

Link to comment
Share on other sites

When the script is running with the command "grep "MHz" /proc/cpuinfo" it show 480MHz when the cpu is idling and 1600MHz under load and the steps in between (for all four cores and MHz varies for the single cores when cpu is working).

But without script the before mentioned command only shows 1600MHz for all four cores. Even when the cpu is idling. Under GSM GUI it shows when the cpu is idling or working (shows speedstep). I guess that the command doesn't show the real frequency (without script) but DSM is doing it correctly. That means that is better watching DSM GUI instead of watching the grep "MHz" /proc/cpuinfo - command.

In another forum a user wrote that this script also had no effect on his N40L. But I don't know which DSM and XPEnology he used.

Link to comment
Share on other sites

That is such a good insight. With such a small community working on these Xpenology boxes under varying conditions, it is very difficult to determine what is best practice. It might actually be the case that for most scenarios, relying on the GUI is more accurate than trying to rely on the CLI to understand what is going on "under the hood." I'm going to go look for something I can measure the actual power usage with so I can get a better understanding!

Link to comment
Share on other sites

  • 3 months later...
  • 4 weeks later...

In my case it was a new install plus I have an Intel CPU.

Basically the ...cpu0/cpufreq/scaling_governor files do not exist any more and thus the governor cannot be set.

On the same machine I had those entries on xpeno 5.2 5592.2 (boot loader and synology) but now on bootlolader 5644.5 and syno 5664 update 8 the CPU is always running at max speed...

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

please run :

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

 

this will show you available governors, then select the one you like and edit the script.

 

there are 2 governors because this kernel uses intel_pstate

Edited by Guest
Link to comment
Share on other sites

Hi,

 

please run :

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

 

this will show you available governors, the select the one you like and edit the script.

 

there are 2 governors because this kernel uses intel_pstate

 

Done. It says:

performance powersave

 

And now? I'm sorry, I'm not so advanced.. Could you please show me what I have to do?

Link to comment
Share on other sites

Change the script so it matches the available powersave governor.

Example:

/usr/local/etc/rc.d/S99Powersaving.sh

 

Script-content:

#!/bin/sh

 

echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor

 

Make the script executable (look above this thread or "chmod a+x scriptname.sh"). Afterwards run it or reboot.

Link to comment
Share on other sites

Any idea how to throttle the CPU if the folder structure for the CPU does not exist? After upgrading to 5664 and the latest 5967 I don't have cpuX/cpufreq/ entries anymore on a GT1610T Celeron CPU:

 

Diskstation> ls -lR /sys/devices/system/cpu/cpu0

/sys/devices/system/cpu/cpu0:

drwxr-xr-x 6 root root 0 Jul 25 01:13 cache

-r-------- 1 root root 4096 Jul 25 01:15 crash_notes

-r-------- 1 root root 4096 Jul 25 01:15 crash_notes_size

drwxr-xr-x 2 root root 0 Jul 25 01:15 power

lrwxrwxrwx 1 root root 0 Jul 25 01:15 subsystem -> ../../../../bus/cpu

drwxr-xr-x 2 root root 0 Jul 25 01:13 topology

-rw-r--r-- 1 root root 4096 Jul 25 01:13 uevent

 

Thanks!

Link to comment
Share on other sites

Change the script so it matches the available powersave governor.

Example:

/usr/local/etc/rc.d/S99Powersaving.sh

 

Script-content:

#!/bin/sh

 

echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu5/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor

echo powersave > /sys/devices/system/cpu/cpu7/cpufreq/scaling_governor

 

Make the script executable (look above this thread or "chmod a+x scriptname.sh"). Afterwards run it or reboot.

 

Thank you for this point.

I did some modification on the script. But seems it still doesn't work.

 

DS-B85> grep Hz /proc/cpuinfo

model name : Intel® Celeron® CPU G1820T @ 2.40GHz

cpu MHz : 2400.187

model name : Intel® Celeron® CPU G1820T @ 2.40GHz

cpu MHz : 2400.187

DS-B85> cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

performance powersave

DS-B85> cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

powersave

DS-B85> cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_available_governors

performance powersave

DS-B85> cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor

powersave

DS-B85> cat /usr/local/etc/rc.d/S99PowersavingINTEL.sh

#!/bin/sh

 

for c in $(ls -d /sys/devices/system/cpu/cpu[0-9]*);

do if ! grep -q 'powersave' $c/cpufreq/scaling_governor ;

then echo powersave >$c/cpufreq/scaling_governor ;

fi

done

 

Any suggestion?

Thanks.

 

G1820T+B85 runs 5.2-5967-2

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...