Up to Main Index Up to Journal for February, 2020 JOURNAL FOR WEDNESDAY 12TH FEBRUARY, 2020 ______________________________________________________________________________ SUBJECT: Compiling Go from source — RPi3, RPi4 and desktop compared DATE: Wed 12 Feb 19:11:14 GMT 2020 I finally spent some time setting up and tweaking my Raspberry Pi 4. When it comes to setting up my Linux systems I’m very picky and they have to be done just so. I install the latest Raspbian, switch to the testing distribution, tweak some configuration settings, uninstall packages that I’ll never use and replace others, install my essential tools, then configure my environment. By the end of it I have a slim, fast little Pi. After everything was setup it was time for some testing — comparing the latest Raspberry Pi 4 model B 4Gb and my older Raspberry Pi 3 Model B. I also chucked my ageing desktop into the mix for comparison. Some specifics on the Raspberry Pi setup. To save wear and tear on the SDCard and SSD I setup a small, 64Mb zram swap file — things tend to run better than having zero swap space. The /tmp directory is also memory backed using tmpfs and is sized to 20% on the RPi3 and 5% on the RPi4 which works out to a /tmp of 192Mb in size. The RPi3 has /boot on an SDCard and then boots from a Western Digital Green 240Gb M.2 SATA SSD in a USB3 enclosure[1]. The RPi4 just runs off of a 32Gb SanDisk Ultra SDCard at the moment. For the comparison of the two Raspberry Pi I decided on compiling Go 1.13.7 from source. Compiling is something I do a lot of and so was interested in the results of my own testing. For compiling Go from source the small swap space and limited /tmp directory are not enough on the RPi3. To get around this I mount a temporary 4Gb swap file and a separate tmp dir — both on the SSD. For the RPi4 I just needed a larger tmp directory. As root on the RPi3, the temporary swap file is created using: dd if=/dev/zero of=/tmpswap bs=1M count=4096 mkswap /tmpswap As root, I can then turn the additional swap file on and off using: swapon /tmpswap swapoff /tmpswap When compiling Go the maximum swap I saw in use was 452Mb of the 4Gb. To use the separate tmp dir I set the TMPDIR environment variable when compiling: TMPDIR=/home/diddymus/tmp ./all.bash For the RPi3, with just a small passive heat sink on CPU, the CPU would have been throttling a lot during the compilation as it was running at an average of 82.7°C hitting a maximum of 83.2°C. The RPi4 with a fan SHIM reached a maximum of 53.5°C. The Raspberry Pi Foundation have a good overview of the Raspberry Pi thermal control[2] for those interested. For comparison I also timed compiling Go from source on my ageing desktop from 2011 — a quad core i5-2400 CPU @ 3.10GHz with 8Gb RAM and two hard drives in a Raid1 (mirroring) configuration. The results of running all.bash to compile Go 1.13.7 from source: RPi3: 28 minutes (SSD + passive heat sink) RPi3: 25 minutes (SSD + active cooling) Rpi4: 18 minutes (SDCard + active cooling) RPi4: 17 minutes (SSD + active cooling) Desktop: 7 minutes For the RPi4+SSD test I simply plugged the SSD from the RPi3 into the RPi4 and had the build cache and tmp directory on the SSD. With the compile not being that disk I/O heavy using the SDCard or SSD made little difference. Normally the RPi3 runs with just a small passive heat sink. I did re-run the RPi3 test with some active cooling — a small plastic battery powered fan from a pound store held over the heat sink with air blowing down towards the RPi3. This reduced the CPU temperature to 60°C or just below most of the time peaking at 62.7°C very briefly towards the end. Disappointedly this only reduced the compile by 3 minutes down to 25 minutes :( I also compiled WolfMUD from source after clearing the build caches, bin directory and pkg directory: RPi3: 9 seconds (SSD + passive cooling) RPi4: 5 seconds (SDCard + active cooling) Desktop: 2 seconds Looking at the figures above the RPi4 is a definite improvement over the RPi3. Compared to the desktop the RPi4 might not seem that great at first glance. When considering the cost, size and power requirements of the RPi4 it is a remarkable little machine. -- Diddymus [1] The USB3 enclosure has a Transcend chip. Not my best buy. However it works booting from the SDCard, switching to the SSD, plus a USB quirks setting. [2] Raspberry Pi - Frequency management and thermal control: https://www.raspberrypi.org/documentation/hardware/raspberrypi/frequency-management.md Up to Main Index Up to Journal for February, 2020