In the first boot of a system using a rather slow CPU (imx6ull, one core), installation times for snap can go up to more than 2 minutes. For instance, installation of the network-manager snap
is taking around 2m15s.
The time used is split between snapd processing and calls to apparmor_parser
(seccomp compile
calls are not very costly in comparison). It looks like apparmor_parser
is called more than once per profile, depending on the snap it can be up to 3-5 times.
This can be seen in the attached bootchart. I recommend opening it with firefox, and search there for apparmor_parser --replace --write-cache -O no-expr-simplify --cache-loc=/var/cache/apparmor --quiet /var/lib/snapd/apparmor/profiles/snap.network-manager.networkmanager
. The same profile is parsed 5 times, spending 3-5 seconds each time. These calls sum up 40 seconds for this snap, if we reduce them to 10 sec, that would save 22% of the installation time.
Bootchart: https://drive.google.com/file/d/1nIIMyD0flXL6R4c_NeXJKvpdOaPEoIop/view?usp=sharing
Journal: https://drive.google.com/file/d/1AdBi0UsrO_vjMGQBfJatwwy28SQA1W5I/view?usp=sharing
Calls to apparmor_parser
(note that it forks, so the number is half of what is seen in the text. Also, the times shown are strict CPU time, not real time, which takes longer for each process): https://paste.ubuntu.com/p/b7ysv5FKH8/