I really really hate it when vendors hide things on you. Even good vendors do it. It is rank evil.
So the Pi M3 is sold as running at 1.2 GHz ( 1200 MHz ).
It can run that fast. It just doesn’t.
It looks like the default setting of the CPU Governor is “powersave”, that limits speed to 600 MHz.
Why is an interesting question. It seems that the USB connector that powers it is limited to 1.8 A and at full load with stuff plugged into the USB 2.0 ports, the Pi + Stuff takes more than that, you get power drop along the wire and connector, low volts happens, and it becomes unstable and / or crashes. So to prevent most folks from discovering that, they limit the CPU speed to 1/2 of the advertized speed. Not Nice.
I ran into this here:
where there is a long and extensive discussion of it. Seems that the ASUS Tinkerboard has similar power issues with the little USB as power connector. In general, any SOC System On Chip with the quad core fast processors is likely to “go there” on power issues. The Banana Pi M3 (octocore) runs into it so hard there was another posting about how to send power into it through the CPIO headers so you could actually use the cores without immediately crashing.
I’m not sticking a bunch of stuff into the onboard USB connectors (just a tiny ‘dongle’ for the logitech keyboard) as I use a powered USB Hub if using any disks or multiple things (or the ‘real’ keyboard and mouse with direct USB plugs) so I don’t expect to be “pushing it” on power draw.
so the article says:
I would suggest either patching kernel config to use ondemand by default (powersave is the default and not the best choice), adding cpufrequtils package by default or adding this to /etc/rc.local:
echo ondemand >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
With the settings you use now the CPU cores are limited to 600 MHz. While I use a custom Armbian build on RPi 3 now where this isn’t a problem the users of your distro should be able to benefit from twice the performance too.
With the above changes the stupid sysbench pseudo benchmark finishes in 3 seconds compared to 48 seconds as usual. With powersave it’s 6.2 seconds. Just try it out yourself:
sysbench –test=cpu –cpu-max-prime=10000 run –num-threads=$(grep -c ‘^processor’ /proc/cpuinfo)
I had trouble believing that the thing was really limited to 600 MHz, so had to look for myself. Their claim of a 3 second finish for sysbench is, I think, some kind of error. If prior runs were 48 seconds, then halving it would be 24 seconds, but then they also talk about low volts causing a separate bit of sloth and I’ve not installed the volts testing thing. I also hoped maybe Devuan didn’t do this, but it looks like they just kept the defaults. In any case, here’s what I did.
First, I looked at CPU frequency. There’s a nice place were lots of statistics are stored. (BTW, this system is named “DevuanPiM2” but is running on the Pi M3. I just named it that so I’d know it was the Pi M2 build 32 bit v7, not the Pi M3 build 64 bit v8)
/sys/devices/system/cpu/ root@DevuanPiM2:/sys/class# ls /sys/devices/system/cpu cpu0 cpu2 cpufreq kernel_max online power uevent cpu1 cpu3 isolated offline possible present
if listed “long” you can see that the 4 CPU directories are in fact all links to the same thing:
drwxr-xr-x 4 root root 0 Nov 21 00:18 cpu0 drwxr-xr-x 4 root root 0 Nov 21 00:38 cpu1 drwxr-xr-x 4 root root 0 Nov 21 00:38 cpu2 drwxr-xr-x 4 root root 0 Nov 21 00:38 cpu3
That “4” is 4 hard links, so four names to the one file or directory. Editing any one or reading any one gives the same thing as any of them.
To look at your CPU speed, there’s a set of files in those directories.
root@DevuanPiM2:/sys/devices/system/cpu# ls cpu0 cpu_capacity cpufreq of_node power subsystem topology uevent
In particular that cpufreq directory
root@DevuanPiM2:/sys/devices/system/cpu# !!/cpufreq ls cpu0/cpufreq affected_cpus related_cpus scaling_governor cpuinfo_cur_freq scaling_available_frequencies scaling_max_freq cpuinfo_max_freq scaling_available_governors scaling_min_freq cpuinfo_min_freq scaling_cur_freq scaling_setspeed cpuinfo_transition_latency scaling_driver stats
These let you tune up how your CPU is run, what speeds it uses and under what conditions of load. Looking at the “stats” for use so far, I had:
root@DevuanPiM2:/sys/devices/system/cpu/cpu3/cpufreq# more stats/time_in_state 600000 169995 1200000 0
600,000 is 600 MHz. ALL my time was spent in that speed. Nothing at 1.2 GHz. OK, so “I’ve got the slows”…
So I made a couple of commands to be able to check on status:
chiefio@DevuanPiM2:/tmp$ bcat cputemp while true do cat /sys/class/thermal/thermal_zone0/temp sleep 10 done chiefio@DevuanPiM2:/tmp$ bcat cpuspeed while true do cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq sleep 10 done
now I can just type (as root for cpuspeed!) cputemp or cpuspeed and see what I’ve got. Temperature is reported in 1/1000 C so you get to drop 3 decimal places.
chiefio@DevuanPiM2:/tmp$ cputemp 51540
is 51.5 C
Then I put their “fix” in a similar one line script:
chiefio@DevuanPiM2:/tmp$ bcat cpusetondemand echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Issued my cpusetondemand command and checked my CPU speed.
Before (running the benchmark)
root@DevuanPiM2:/home/chiefio/bin# !while while true; do cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq; sleep 10; done 600000 600000 600000 600000 600000 600000 600000 600000
That was with all 4 cores loaded up to 100% using sysbench (that I needed to “apt-get install sysbench” to get) and put it into a script too.
chiefio@DevuanPiM2:/tmp$ bcat cputest sysbench --test=cpu --cpu-max-prime=10000 run --num-threads=$(grep -c '^processor' /proc/cpuinfo)
Then I changed the scaling_governor to ondemand and tried again:
root@DevuanPiM2:/sys/class# cpuspeed 1200000 1200000 1200000
Well… I don’t know if this will survive a reboot or not (so I’d need to put it in rc.local to be run each boot), but it’s clear that by default your Pi M3 is only using 1/2 it’s brain.
Here are my before and after runs of sysbench:
time cputest sysbench 0.4.12: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 4 Doing CPU performance benchmark Threads started! Done. Maximum prime number checked in CPU test: 10000 Test execution summary: total time: 103.8366s total number of events: 10000 total time taken by event execution: 415.2502 per-request statistics: min: 40.22ms avg: 41.53ms max: 112.35ms approx. 95 percentile: 44.51ms Threads fairness: events (avg/stddev): 2500.0000/16.60 execution time (avg/stddev): 103.8126/0.01 real 1m43.871s user 6m46.270s sys 0m0.160s chiefio@DevuanPiM2:/tmp$ !! time cputest sysbench 0.4.12: multi-threaded system evaluation benchmark Running the test with following options: Number of threads: 4 Doing CPU performance benchmark Threads started! Done. Maximum prime number checked in CPU test: 10000 Test execution summary: total time: 51.3217s total number of events: 10000 total time taken by event execution: 205.2621 per-request statistics: min: 20.11ms avg: 20.53ms max: 95.55ms approx. 95 percentile: 21.14ms Threads fairness: events (avg/stddev): 2500.0000/16.17 execution time (avg/stddev): 51.3155/0.00 real 0m51.351s user 3m22.820s sys 0m0.000s
1 minute 44 seconds cut to 52 seconds.
All because I’m actually using all the computer I bought.
I’d also point out that at no time did I get the “low volts” indicator lightning bolt in the upper left corner of the screen.
So I’m going to run this way for a while and see if any bad thing happens. I don’t expect any issues as I’m just not loading up the power drain from the Pi. But “we’ll see”. With these settings, the Pi runs at 600 MHz unless a core gets fully loaded, then it shifts to 1.2 GHz, so much of the time will be 600 MHz anyway. FWIW, the FireFox browser seems much “snappier” now too ;-) Many of the “just a bit too slow” seem to have fled…
Clearly, too, the stats show I’m using both speeds now:
root@DevuanPiM2:/sys/devices/system/cpu/cpu3/cpufreq# cat stats/time_in_state 600000 451866 1200000 89946
So sometime tomorrow I’ll need to check my two Pi M2 boards and see if they are similarly set.