balena-os / meta-balena

A collection of Yocto layers used to build balenaOS images
https://www.balena.io/os
971 stars 116 forks source link

Investigate baseline memory usage #1390

Open ZubairLK opened 5 years ago

ZubairLK commented 5 years ago

With/without the balena daemon, with/without the supervisor.

Overall check what is eating memory

ZubairLK commented 5 years ago

Device pi3b+ balenaOS: 2.29

root@balena:~# balena --version
balena-engine version 17.12.0-dev, build dceb2fc48071b78a8a828e0468a15a479515385f
root@balena:~# uname -a
Linux balena 4.14.79 #1 SMP Fri Dec 28 10:31:38 UTC 2018 armv7l armv7l armv7l GNU/Linux

stopped app container, supervisor/balena/balena-host are running. Started an alpine container using:

balena run -i -t --privileged --pid=host --net=host --ipc=host alpine /bin/sh

Then

apk add procps
ps -e -orss=,args= | sort -u -b -k1,1n

List of processes sorted with memory usage

 2708 /proc/self/exe --healthcheck /usr/lib/balena/balena-healthcheck --pid 30733                                                          
 2808 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only                             
 2872 avahi-daemon: running [balena.local]                                                                                                 
 3136 /lib/systemd/systemd-udevd                                                                                                           
 3280 /lib/systemd/systemd-logind                                                                                                          
 4192 /usr/sbin/wpa_supplicant -u                                                                                                          
 4340 /usr/sbin/openvpn --writepid /var/run/openvpn/openvpn.pid --cd /etc/openvpn/ --config /etc/openvpn/openvpn.conf --connect-retry 5 120               
 5116 /lib/systemd/systemd-journald                                                                                                                                                      
 5604 /sbin/init                                                                                                                                                                         
 7444 /usr/sbin/ModemManager --log-journal                                                                                                                                               
10608 /usr/sbin/NetworkManager --no-daemon                                                                                                                                               
10612 /usr/lib/polkit-1/polkitd --no-debug                                                                                                                                               
13660 @sbin/plymouthd --tty=tty1 --mode=boot --pid-file=/run/plymouth/pid --attach-to-session --kernel-command-line=plymouth.ignore-serial-consoles splash                               
21900 balena-engine-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/c6c3f603c54dfc37a7c1b07adfe7b9cb22d40e712045f789b8a3ad
23224 balena start --attach resin_supervisor                                                                                                                                             
23836 balena run -i -t --privileged --pid=host --net=host --ipc=host alpine /bin/sh                                                                                                      
24016 balena-engine-containerd-shim -namespace moby -workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/6e8ad0c4413091c25afd30a4c35e9a4d5d82812c4b17a8ead87f25
24292 balena-engine-containerd --config /var/run/balena-host/containerd/containerd.toml                                                                                                  
27208 balena-engine-containerd --config /var/run/balena-engine/containerd/containerd.toml                                                                                                
30168 /usr/bin/balenad --delta-data-root=/mnt/sysroot/active/balena --delta-storage-driver=aufs --log-driver=journald -s aufs --data-root=/mnt/sysroot/inactive/balena -H unix:///var/run
40020 /usr/bin/balenad --experimental --log-driver=journald -s aufs -H fd:// -H unix:///var/run/balena.sock -H unix:///var/run/balena-engine.sock -H tcp://0.0.0.0:2375 --dns 10.114.102.
42576 node /usr/src/app/dist/app.js

From OS perspective, I think the only thing we can do is stop plymouthd and balena-host if they aren't actively useful all the time. Might be tricky with plymouthd because it might be keeping the splash screen logo alive on the display.

More internal info https://www.flowdock.com/app/rulemotion/r-resinos/threads/NOYCWQMaNc69EWC2Cu6UkHzyoZQ?filter=search&query=memory