zvldz/vacuum

Reintroduce OOM adjustment on 2008+

bsdice opened this issue · 2 comments

When Roborock switched from Upstart to Busybox on 2008+ for Gen2, OOM adjustment for valetudo was lost. Reintroduce this feature for added operational safety. Implementation is through a sub shell, which adjusts its own OOM score and then execs the valetudo binary, replacing itself.

--- valetudo-daemon.sh.orig
+++ valetudo-daemon.sh
@@ -15,7 +15,12 @@
         echo "Running Valetudo"
         echo '|/bin/false' > /proc/sys/kernel/core_pattern
         if [ -f "/root/bin/busybox" ]; then
-            /root/bin/busybox ionice -c3 nice -n 19 /usr/local/bin/valetudo >> /var/log/upstart/valetudo.log 2>&1
+       (
+            # Make valetudo very likely to get killed when out of memory
+            echo 1000 > /proc/self/oom_score_adj
+            # Also run it with absolutely lowest CPU and I/O priority to not disturb anything critical on robot
+            exec /root/bin/busybox ionice -c3 nice -n19 /usr/local/bin/valetudo >> /var/log/upstart/valetudo.log 2>&1
+       )
         else
             nice -n 19 /usr/local/bin/valetudo >> /var/log/upstart/valetudo.log 2>&1
         fi
zvldz commented

Thanks
added 46ea481

zvldz commented

Closed #45