Trauma

CPU Frequency scaling for DS918+

Recommended Posts

Good morning everyone. First of all congratulate Trauma for creating the script.

I have a problem and I am not able to install / run it. I am quite noob in the use of DSM and I do not know if it is possible that a simple guide could be made explaining its installation step by step.

Thank you.

Share this post


Link to post
Share on other sites

The script is designed to be automatic and only needs one small change initally. Change the "Highload" value to 65. More on why that needs to match the "midload" value below. 

 

- Save it to your home folder

- Make it executable - `chmod +x <scriptname.sh>` - e.g: - `chmod +x scaling.sh`

- Run the script (in background) - `./<scriptname.sh> &` - e.g: -  `./scaling.sh &`

- By default the script is set to do this

---- Set CPU Speed to lowest value, it can support, at below 50% load

---- Set CPU Speed to 50% value, it can support, above 50% & below 65% load

---- Set CPU Speed to 100% value, it can support, at above 85% load. (This needs to match midload i.e 65%, as the script will not change CPU between mid & highload)

 

- Before you go changing any values, I would suggest trying the script out first. See if the machine seems "fast" enough. If not, then change those "lowload", "midload" & "highload" values.

 

=> For example, if you want it to be "snappy", set the "lowload" value to say 5% load, "midload" to say 50% and "highload" to say 50%. This will keep your CPU at lowest below 5% CPU usage, at 50% speed till 50% load and at 100% speed above 50% load

 

=> If you want it extra "snappy" - set the "lowload" value to say 5% load, "midload" to say 15% and "highload" to say 15%. This will keep your CPU at lowest below 5% CPU usage, at 50% speed till 15% load and at 100% speed above 15% load 

 

 

NOTE:

 - CPU Speed is gathered from the CPU supported values, so it auto-adjusts to your CPU

 - The script will do NOTHING when CPU is between "midload" & "highload". Thus they need to be set to the SAME VALUE. 

 

 

Edited by Jseinfeld

Share this post


Link to post
Share on other sites
On 9/30/2019 at 9:19 PM, Trauma said:

Please try this as well and report the output of the command here please (for your cpu it should return "8") :


cat /proc/cpuinfo | grep cores | sort -u | awk '{ print $4 }'

 

is 1 ok for AMD? 4 cpus are listed in cpuinfo, but cores=1. interesting by default cpu is at max freq all of the time in all OS, but in DSM the performance is halved after boot (proven by benchmarks). scaling_setspeed is <unsupported>. Governor is performance. Min freq, max freq is correct.

cat $(ls /sys/devices/system/cpu/cpufreq/policy*/scaling_cur_freq)
2100000
2100000
2100000
2100000
grep "MHz" /proc/cpuinfo
cpu MHz         : 2100.000
cpu MHz         : 2100.000
cpu MHz         : 2100.000
cpu MHz         : 2100.000

cpuinfo_min_freq, cpuinfo_max_freq, cpuinfo_cur_freq,  all seems correct, but performance is lower

aes-256-xts      90198.74k   342936.66k   777926.06k  1132937.56k  1292978.86k

setting governors does nothing, powersave keeps lowest freq, performance keeps highest freq (only the scaler.sh does the job, although very slowly.). driver is acpi-cpufreq, only one available on DSM.

i set scaling_driver to highest freq, still low performance and fans off. dmidecode and UI shows highest freq. Performance still low.


tried hundred commands, only when setting scalers up and down (which sets userspace), and then setting performance:

for i in 0 1 2 3; do cpufreq-set -f 1400 -c $i; done

for i in 0 1 2 3; do cpufreq-set -f 2100 -c $i; done

for i in 0 1 2 3; do cpufreq-set -u 1400000 -c $i; done

for i in 0 1 2 3; do cpufreq-set -u 2100000 -c $i; done

for i in 0 1 2 3; do cpufreq-set -g performance -c $i; done

 

........performance is unlocked and fans go loud under load

aes-256-xts     225339.77k   833591.27k  1901271.72k  2758488.41k  3190287.02k

idle consumption is the same. i think the sequence of commands unlocked CPU TPU max from 12W to 35W. Crazy.

Share this post


Link to post
Share on other sites

Morning guys, I've been loving the script and am ready to apply it to the startup folder using the directions provided in this forum. Would one of you guys please post up how to remove the script from the startup folder in case I decide to not use it anymore?

Share this post


Link to post
Share on other sites

Is this script supposed to be compatible with i5-4590T (base 2GHZ, boost 3GHZ). I always thought my virtual machines where slower then when I was running Linux but I just thought that it was overhead. However I recently noticed that my CPU was running at only 2GHZ so that would also explain it.

 

With the script running (default settings) I still only go up to 2GHZ

 


admin@nas:~$ cat /proc/cpuinfo | grep MHz
cpu MHz         : 2001.000
cpu MHz         : 2001.000
cpu MHz         : 2001.000
cpu MHz         : 2001.000
admin@nas:~$ uptime
 15:09:40 up 22 min,  2 users,  load average: 2.47, 2.08, 1.74
admin@nas:~$ cat /proc/cpuinfo | grep MHz
cpu MHz         : 2001.000
cpu MHz         : 2001.000
cpu MHz         : 2001.000
cpu MHz         : 2001.000
admin@nas:~$ cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
2001000 130778
2000000 0
1900000 0
1800000 0
1700000 0
1600000 0
1500000 0
1400000 3738
1300000 0
1200000 0
1100000 0
1000000 0
900000 0
800000 0

 

Share this post


Link to post
Share on other sites
Posted (edited)
On 4/17/2020 at 3:10 PM, mattie112 said:

Is this script supposed to be compatible with i5-4590T (base 2GHZ, boost 3GHZ). I always thought my virtual machines where slower then when I was running Linux but I just thought that it was overhead. However I recently noticed that my CPU was running at only 2GHZ so that would also explain it.

 

With the script running (default settings) I still only go up to 2GHZ

 



admin@nas:~$ cat /proc/cpuinfo | grep MHz
cpu MHz         : 2001.000
cpu MHz         : 2001.000
cpu MHz         : 2001.000
cpu MHz         : 2001.000
admin@nas:~$ uptime
 15:09:40 up 22 min,  2 users,  load average: 2.47, 2.08, 1.74
admin@nas:~$ cat /proc/cpuinfo | grep MHz
cpu MHz         : 2001.000
cpu MHz         : 2001.000
cpu MHz         : 2001.000
cpu MHz         : 2001.000
admin@nas:~$ cat /sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state
2001000 130778
2000000 0
1900000 0
1800000 0
1700000 0
1600000 0
1500000 0
1400000 3738
1300000 0
1200000 0
1100000 0
1000000 0
900000 0
800000 0

acpi-cpufreq do not, as far as know, support turbo boost. Turbo boost is managed by intel_pstate scaling driver, which is not available with the 918+ kernel. I did not succeed to build and load successfully intel_pstate for now.

 

Edited by Trauma

Share this post


Link to post
Share on other sites

sorry if this is a dumb question but is there an equivalent script for 1.03b/DS3615 6.2.2?

Share this post


Link to post
Share on other sites
1 hour ago, richv31 said:

sorry if this is a dumb question but is there an equivalent script for 1.03b/DS3615 6.2.2?

 

I too am looking for this same script for 6.2.2. 

Share this post


Link to post
Share on other sites
1 hour ago, JoeOIVOV said:

 

I too am looking for this same script for 6.2.2. 

figured it out, ds3615 has scaling governors, 918+ does not. So for 3615 all you need to do is change the governor for all cores to ondemand or conservative (the two scaling governors). use this script in a scheduled task: 

 

#!/bin/sh

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

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

then echo conservative >$c/cpufreq/scaling_governor ;

fi done

 

Share this post


Link to post
Share on other sites
On 4/18/2020 at 3:22 PM, Trauma said:

 

Hm, do you know if any other model does support this? I used to run the ds3615 but I changed it at some point (not sure why). Or perhaps I should switch to some other Hypervisor to run my VirtualMachines (esxi for example) and then run xpenology in a VM.

Share this post


Link to post
Share on other sites

As @richv31 mentioned DS3615 kernel also use acpi_cpufreq by default. But i don't know if intel_pstate is available /usable with this kernel/os.

 

IMHO the hypersisor has nothing to do with this, or at least should be able to provide the necessary to use both. 

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks for that great script.
At starting with it had some problems with the load Avarage settings. Load Avarage needs to configured special to your system. 1, 2 or 4 Core CPU needs other settings for example...
maybe this article will help some one else, too

 

https://www.howtogeek.com/194642/understanding-the-load-average-on-linux-and-other-unix-like-systems

 

EDIT:
Would like to know, which load avarage is that script using ?

Because it ´seems not to work correctly...

For example:

uptime show a la from 0.9( 1 Minute )

Lowload is set to 400


So for my understanding, everthing below a value from 4.0 should use the lowspeed config.

But that is not the case.

 

Alex

 

Edited by Lexizilla

Share this post


Link to post
Share on other sites
Posted (edited)
On 5/26/2020 at 12:07 PM, Lexizilla said:

Thanks for that great script.
At starting with it had some problems with the load Avarage settings. Load Avarage needs to configured special to your system. 1, 2 or 4 Core CPU needs other settings for example...
maybe this article will help some one else, too

 

https://www.howtogeek.com/194642/understanding-the-load-average-on-linux-and-other-unix-like-systems

 

EDIT:
Would like to know, which load avarage is that script using ?

Because it ´seems not to work correctly...

For example:

uptime show a la from 0.9( 1 Minute )

Lowload is set to 400


So for my understanding, everthing below a value from 4.0 should use the lowspeed config.

But that is not the case.

 

Alex

 

Could you please be more precise. Can you let us know your thoughts in detail? I will like to take advantage of the script, but at the same time I want my computer snappy. And I notice a little slow lately. Thanks

 

By the way, I use the scaler with the following command line in the task scheduler (at boot-up event):

lowload=025 midload=065 /volume1/Filer/Configuration\ DSM/cpu\ frequency\ scaling/scaler.sh &

How can I change the values and update the running task with the new values safely. I guess if I change the values and save it, it will not change the current process, how can I do it then without restarting the machine?

Edited by ed_co

Share this post


Link to post
Share on other sites

CALM DOWN

 

coming back to the script as my NAS is busier and busier, and having now cpu load around 0.5, it can get noisy. The noise is sinuous and therefore annoying. There's no real load, it's just the amount of of services is high and fileindexd makes sure to make repeated load pops.

 

i attach my fork for HP Gen10 (non Plus).

  • core count is reported as 1 for AMD, instead for processors are there, using nproc
  • have only 3 frequencies, so had to remove unused coolfreq
  • didn't like IF for each core, double conditions, added it to the same block to save some cpu cycles
  • instead added Ramp mode, to switch to Turbo mode faster if there's a load spike
  • added debug mode "-d"
  • deamon checks only once per 5 seconds, it doesn't make sense to check it too often,  if the load stats isn't updated

You can merge with the original and pick what you like. Thanks for the script as I now can have quiet machine again. 👌

 

note: High cpu equals Turbo, processing power (e.g. AES test, or 10gbit encrypted transfer) gets doubled with minimal freq raise, and is handled by cpu

note: freq ramp and deramp will be slow just like the cat /proc/loadavg interval but this is fine for me, if a long operation (10gbit copy, backup, plex transcoding, emby maintenance) is going to take place, it will catch up soon and delay will be meaningless

note: "Fan speed mode" in DSM might have zero impact, and by default my machine starts in power saving mode

@ed_co : once scripts runs, it's in memory, as a basic concept, you need to kill the existing process and restart if you did modifications

 

scaler.sh

Share this post


Link to post
Share on other sites
Le 01/07/2020 à 00:26, nadiva a dit :

CALM DOWN

...

 

Hello nadiva,

 

Thanks for you feedback, much appreciated. I look into your contribution later this month i think (quite busy at this time).

 

Cheers.

Share this post


Link to post
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.