Pi Tweaks and Configuration
Shutting down non essential hardware
If you're only using a headless Raspberry Pi for distributed computing, you can shutdown quit a bit of the onboard features to save power. I have only tested the following in Raspbian Lite, but they should all work in any distribution of Raspbian. I also assume that you will be using wired networking - setting up dozens of wireless clients can cause Wifi interferance that I did not not want to deal with.
Many configurations involve modifying /boot/config.txt. Any line that has a reference to this file will require a reboot to take effect.
If a command does not involve /boot/config.txt, it will last until the next reboot. I personally created a small shell script called power.sh to turn off HDMI, the power LED, and USB.
#Disable Wifi, and disable check for wifi
echo "dtoverlay=disable-wifi" | sudo tee -a /boot/config.txt
sudo systemctl disable wpa_supplicant
sudo rm /etc/profile.d/wifi-check.sh
#Disable Bluetooth and bluetooth services
sudo systemctl disable hciuart
echo "dtoverlay=disable-bt" | sudo tee -a /boot/config.txt
#disable host controller serial transmitter (hciuart)
sudo systemctl disable hciuart
#Disable HDMI:
sudo tvservice --off
#Turn off Power LED:
echo 0 | sudo tee /sys/class/leds/led1/brightness
#disable network Power LEDs
echo "dtparam=eth_led0=4" | sudo tee -a /boot/config.txt
echo "dtparam=eth_led1=4" | sudo tee -a /boot/config.txt
#disable audio
sudo sed -i "s/dtparam=audio=on/dtparam=audio=off/" /boot/config.txt
Power Savings reference thread:
www.raspberrypi.org
Over / Under clocking
The ARM CPU can be over and under volted and over and under clocked the same as any other CPU, though there are limits baked into Raspbian.
Frequency settings are controlled in /boot/config.txt via the setting arm_freq. Default is 1500 for the Pi 4, maximum is 2147.
#sample line to over clock to 2000 mhz
arm_freq=2000
Voltage Settings are controlled in /boot/config.txt via the setting over_voltage. Settings are 1-6 (over volting), and -1 to -6 (under volting), and each +/- adds / subtracts .0250V. Default is 0, which is .8750V
#sample line to over volt 5 (.125V)
over_voltage=5
Across 4 Raspberry Pi 4s, my most successful results are:
Frequency / voltage
1500 / -2
1750 / 2
1900 / 4
2025 / 5
2147 / 6 (needs excellent cooling for 24x7 usage, and even then can generate failed WUs)
Thermals and Heatsink
Offical raspberry pi org thermal testing.
Raspberry Pi 4 just got a lot cooler! The last four months of firmware updates have taken over half a watt out of idle power and nearly a watt out of fully loaded power
www.raspberrypi.org
Best heatsink I've used is the Flirc case:
Pi 4 4GB in a Flirc Case, w/ 100% load from 4 Rosetta processes, ~20c ambient, Max Temps:
Passive w/ plastic top on 58c
Active w/ top on + 60mm fan blowing at front opposite network cable 42c
Passive w/ plastic top off 55c
Active w/ plastic top off + 60mm fan blowing at front opposite network cable 35c
Active w/ plastic top off + 60mm fan blowing at side opposite power cable 40c
Passive w/ plastic top off + a Thermaltake Volcano 6cu+ heatsink resting on top 51c
Active w/ plastic top off + heatsink + 60mm fan blowing at side opposite power cable 38c
Active w/ plastic top off + heatsink + 60mm fan blowing at front opposite network cable 35c
Stretching Ram
This is most applicable to the 2GB Pi 4, or a 4GB pi 4 trying to run 4 Rosetta processes.
Reduce ram allocated to CPU
By default, 64MB of memory is allocated to the GPU. This is unnecessary when running headless, so it can be reduced to the mimimum, freeing up memory for the OS.
#set the GPU to 16MB, the minimum amount of allocated ram
echo "gpu_mem=16" | sudo tee -a /boot/config.txt
Configure Zram
Zram creates a compressed, in memory swap partition that is used when all available memory runs out. Testing shows this to work very well up to a partition size = to total memory size to increase the amount of fast memory available to the pi. This is expecially useful when you randomly get 4 1.2+gb processes running at the same time.
sudo apt-get install zram-tools
sudo vi /etc/default/zramswap
PERCENTAGE=100
sudo zramswap stop
sudo zramswap start
The default compression is lzo - I have found lz4 to be slightly better performing, but will cover that in a later update.