OpenPLC_v3 icon indicating copy to clipboard operation
OpenPLC_v3 copied to clipboard

Installing on Raspberry Pi with swapfile

Open ALTracer opened this issue 3 years ago • 1 comments

When installing the runtime from master branch, I tried to time it and noticed a couple major inefficiencies. Hardware: Raspberry Pi 3B with 1G RAM & microSD showing 30MB/s seq.read, should achieve sub-1h build time on Raspbian buster armhf.

  1. 1000MB swapfile for dnp3 compilation was being dd-ed longer than the actual compilation ran
  2. make not parallel -- dnp3 builds in 9 minutes with make -j$(nproc) on 4 cores @1200MHz.
  3. Never cleaned after builds&installs -- the matiec and dnp3 leave A LOT of .o, .ii, .s build artifacts behind. (e.g. make -C matiec_src mostlyclean, make -C dnp3_src clean)

I already have set up ZRAM of ~500MB just in case.

#13 mentions install failures on 512MB RAM boards, so I tried to profile memory eaten -- dnp3 cmake make -j4 build in fact does require almost ~500MB once during linking stage. But you really should check for available memory before wasting half the build time on creating a temporary swapfile, potentially failing the build altogether on insufficient space (instead of insufficient RAM).

free -mt | grep "Total:" | awk '{print $4}' will return free RAM+SWAP as a decision point for requiring more swap (or ZRAM).

#62 mentions an install failure inside a Docker container on swapon, and I think, too, kernel-level manipulations should be avoided when possible.

I might do a PR later with make -j$(nproc) || make -j1, make clean after ALL installs and mem/swap checks. I am somewhat proficient in shell.

ALTracer avatar Jan 16 '22 19:01 ALTracer

Great points! Fixing those would indeed improve the installation process time a lot.

thiagoralves avatar Jan 17 '22 14:01 thiagoralves