Up to Main Index                             Up to Journal for March, 2021

                     JOURNAL FOR TUESDAY 30TH MARCH, 2021

SUBJECT: Detour ahead — Raspberry Pi Zero, 3 & 4 performance testing
   DATE: Wed 31 Mar 04:04:53 BST 2021

I started writing this a week and a half ago. Since then it has taken a twisty
turn or two, meandered a bit here and there, finally arriving at the end of
the month where I’m rushing to get it finished. This little journey started
with an update to the WolfMUD documentation — included with WolfMUD and to the
accompanying website. Testing of said WolfMUD ensued, at which point things
took a sharp detour into the thickets of Raspberry Pi land…

When preparing for a release I like to test on all of the hardware platforms I
have available. This currently includes Raspberry Pi Zero W, 3, 4 and Intel
x86-64 — all running Linux. I also test on QEmu/x86-64 for Windows 10.

Recently the Raspberry Pi Zero had been neglected. First job was to compile Go
1.16.2 from source. Compiling Go on a Raspberry Pi Zero can be somewhat
tricky. I’d failed to compile Go1.13 or Go.14 at all, but did mange Go1.15
after numerous attempts, Go1.16.2 did compile, after nearly two days of failed
attempts and random errors like:

  runtime: garbage collector found invalid heap pointer

I hate to think what all that compiling has done to the poor SDCard. Normally
I bootstrap the compile with Go1.4.3. To compile successfully this time I had
to switch to using the previous Go1.15.4 install. I have no idea why Go 1.4.3
was suddenly causing so many problems :( Final time to build Go 1.16.2, using
Go 1.15.4, and running all of the tests was a leisurely five and a half hours
give or take. I’m now wondering if I could have compiled Go1.13 and Go1.14
using a Go1.12 compiler…

For those interested, these are the build times for Go1.16.2 on the Intel i5
desktop and Raspberry Pi. The Pi 4 has multiple entries. One entry for each
bootstrap compiler — just to see what difference it made, if any — and an
extra entry as the Fan SHIM, which stopped working weeks ago, sprang back to
life half way through testing — go figure…

                             Build               Max
        Machine  Storage      Time  Bootstrap   Temp  Cooling
        -------  -------  --------  ---------  -----  ----------------
        Desktop  HDD         8m26s  Go1.4.3
        Pi4      SDCard     21m38s  Go1.4.3    80°C+  None
        Pi4      SDCard     21m01s  Go1.4.3    68°C   Fan Shim
        Pi4      SDCard     18m51s  Go1.15.8   68°C   Fan Shim
        Pi3      USB M.2    42m25s  Go1.4.3    80°C+  Passive heatsink
        Pi0      SDCard   5h22m48s  Go1.15.2   55°C   No cooling

While I was on a benchmarking shindig, I wondered how many bot the Raspberry
Pi could handle. In doing so I opened another can of worms. I started on the
Pi Zero and found that two processes, related to handling Wifi, ran at 25% CPU


Not good when you have limited resources. So I loaded the USB ethernet gadget
module and also tested with TCP/IP over USB, which performed better. For the
testing each run lasted 15 minutes and all player commands had to be handled
in 3 seconds or less to be considered playable. The configuration value for
Stats.GC was set to false. I also made an additional 7 locations starting
locations to spread the bots out[1]: Z:L9, Z:L32, Z:L60, SZ:L5, SZ:L10, ZC:L17
and ZC:L20. In all cases the botrunner was run from the desktop.

          Machine  Networking  MaxBots  CPU Use  CPU Temp  Idle@24°C
          -------  ----------  -------  -------  --------  ---------
          RPi0     USB/IP          512   98%±2%  46°C±2°C       35°C
          RPi0     Wifi            352   97%±3%  47°C±3°C       35°C
          RPi3     Ethernet       8192   70%±7%  73°C±3°C       45°C
          RPi4     Ethernet      13312   75%±6%  55°C±3°C       42°C

It’s interesting to see that using TCP/IP over USB instead of Wifi, on the Pi
Zero, allows for a 45% increase in the maximum number of bots it can handle.

Getting these figures took many runs on each Raspberry Pi, in order to find
the sweet spot for the maximum number of bots while having all command handled
in 3 seconds or less. At 15 minutes a run the time soon flies by.

Whenever I mention the Raspberry Pi Zero, especially running WolfMUD on it,
people ask me “Why? Why bother?”. One answer to this is pocket money. You can
pick up a Raspberry Pi Zero W for £9.30 in the UK. For that you get something
that is capable of running Linux — which is freaking awesome for the money.
Yes, there are other costs. A 32Gb Sandisk Ultra SDCard is about £6. With this
I can run all of my usual tools: Git, vim, mutt, lynx, ssh, tig, Go, dvtm,
busybox (for httpd). I can run WolfMUD with over 350 players using Wifi or
more than 500 players with TCP/IP over USB. I can power the Raspberry Pi Zero
from my Chromebook and have a complete development environment on the go. I’ve
spent two weeks with just my Chromebook and Raspberry Pi Zero working away on
WolfMUD quite happily. For me, the Raspberry Pi Zero only has only one thing
missing — it can’t run the Go race detector :(

I wonder what the Raspberry Pi Pico with TinyGo could manage…


  [1] While writing this I’ve had an idea on how I can handle the high lock
      contention in starting locations ;)

  Up to Main Index                             Up to Journal for March, 2021