Pi4 for GoPiGo3: zswap AND Pi4 Are Hot Topics

zswap

After reading 6 Months with the Pi Desktop talking about setting up zswap when using a Pi4 in a desktop application, and Ubuntu 22 for RaspberryPi coming with zswap by default to make the Ubuntu desktop fit on a Pi4 2GB, I wondered if this should become a standard when setting up a Pi4 with Legacy PiOS (desktop version) for the GoPiGo3, (even though there is no SSD usually)? Yuk, what a run-on sentence…

The article makes the statement the compression+i/o is faster than the i/o time for uncompressed swaps, so it would seem to improve the performance, and decrease the writes to the SDcard.

Thoughts?

Pi4 Heat

As to really putting a Pi4 in a GoPiGo3, I have been hesitant for two main reasons:

  1. Pi4 processing power is only needed on a GoPiGo3 for OpenCV or TensorFlow-Lite vision analysis
    (and perhaps for folks that feel they just have to run a desktop environment on their robot…)
  2. GoPiGo3 to Raspberry Pi board mating does not provide for adequate cooling a Pi4 at high loads

and I have been opposed to putting a Pi4 in most use cases because:

  • The idle current is higher than the Pi3B+ which takes 2 hours off the play time.

Now that I actually have a Pi4 to test with, I am first starting with the cooling and mounting issues.

My initial performance vs. heat test on the Pi4 with a PiMoroni heatsink case looks very promising for being able to get the full Pi4 performance in a GoPiGo3 use, but it looks like I will need to add a 40 pin “spacer” and additional hex spacers to the board mating.

That should be about 3 hours of “GoPiGo3 with Vision Decision”

1 Like

looks like a heck of a heatsink. I look forward to seeing your results.
/K

2 Likes

I needed to figure this sooner than I expected. Need 6.5GB to do a “compile install” OpenCV for Pi4, so with only a 2GB Pi4 I need another 6GB of swap space

  • Increase swap to compile (reference says need 6.5 GB to build)
    • edit the swap configuration
sudo nano /sbin/dphys-swapfile

# Default next line
# CONF_MAXSWAP=2048
# Increase for compile OpenCV
CONF_MAXSWAP=6144


sudo nano /etc/dphys-swapfile

# Default next line:
# CONF_SWAPSIZE=100
# Increase to compile OpenCV
CONF_SWAPSIZE=6144
  • check available memory before and after:
free -m
               total        used        free      shared  buff/cache   available
Mem:            1820         143        1342          15         334        1582
Swap:             99           0          99
  • Enable zswap with 6GB swap space
sudo swapoff /swapfile
sudo fallocate -l 6g /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sed -i -e 's/$/ zswap.enabled=1/' /boot/cmdline.txt
sudo reboot

  • This reboot will take quite a while, then check swap:
free -m
               total        used        free      shared  buff/cache   available
Mem:            1820         157         142          15        1520        1556
Swap:           6143           0        6143



  • check zswap parameters
grep -R . /sys/module/zswap/parameters
/sys/module/zswap/parameters/accept_threshold_percent:90
/sys/module/zswap/parameters/enabled:Y
/sys/module/zswap/parameters/max_pool_percent:20
/sys/module/zswap/parameters/zpool:zbud
/sys/module/zswap/parameters/same_filled_pages_enabled:Y
/sys/module/zswap/parameters/compressor:lzo

  • check zswap status
sudo grep -R . /sys/kernel/debug/zswap/
/sys/kernel/debug/zswap/same_filled_pages:1
/sys/kernel/debug/zswap/stored_pages:19
/sys/kernel/debug/zswap/pool_total_size:61440
/sys/kernel/debug/zswap/duplicate_entry:0
/sys/kernel/debug/zswap/written_back_pages:0
/sys/kernel/debug/zswap/reject_compress_poor:1
/sys/kernel/debug/zswap/reject_kmemcache_fail:0
/sys/kernel/debug/zswap/reject_alloc_fail:0
/sys/kernel/debug/zswap/reject_reclaim_fail:0
/sys/kernel/debug/zswap/pool_limit_hit:0

Subsequent boots and reboots return to normal time.

2 Likes

I did something similar, a heatsink like that with fans and everything, thinking to use one on my touchscreen Pi and the other on Charlie.

Nope.

There is no external mounting capability at all. . . .

2 Likes

Dave’s Pi3B+ died yesterday, so ready-or-not he is sporting a Pi4 (with small-ish heatsinks)

=== Tested Pi4 with PiOS Bullseye 32-bit
Pi4 chip Heatsinks and in GoPiGo3

Basic Load:

  • htop
  • plib/status.py
  • vnc

Load average: 0.11
Temp: 45C
Clock 700MHz to 1GHz
Power: 5.6W 9.5V at 0.6A

Adding Heavy Load (results at 8 minutes):

  • stress --cpu 3

Load average: 3.11
Memory Used: 228MB
Processor Temp: 75C
Clock 1.8GHz
Throttled=0x0
Power: 7.9W 9.0V at 0.89A

OS: 5.15.32-v7l+ Mar 31 2022 Bullseye 32-bit

SUMMARY: Pi4 with small heatsinks in GoPiGo3 will support vision processing when limited to three full core loading.

3 Likes

Good luck with the transplant Dave…
/K

2 Likes

" We have the capability to build the world’s first [Bullseye GoPiGo3 robot]. [Dave] will be that [robot]. Better than he was before. Better , stronger , faster ."

(Without the six million dollars … unless Pi4 prices keep going up.)

2 Likes