thiagoralves / OpenPLC_v3

OpenPLC Runtime version 3
GNU General Public License v3.0
1.08k stars 438 forks source link

Installing on Raspberry Pi with swapfile #167

Open ALTracer opened 2 years ago

ALTracer commented 2 years ago

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.

thiagoralves commented 2 years ago

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