Performance run for snap commands

I have created a test suite to measure performance for some snap commands. The results are stores in this document doc.

These are the results for a rpi2:

Command Time
services 602 ms
start 114 ms
stop 120 ms
logs 124 ms
interfaces 136 ms
interface 128 ms
connect 3089 ms
disconnect 1881 ms
list 131 ms
enable 10970 ms
disable 1790 ms
changes 175 ms
alias 530 ms
unalias 519 ms
aliases 166 ms
install_local 113 ms
remove_pack 122 ms
pack 135 ms
try 17501 ms
remove_try 7057 ms

Some things to review is the time the snap try command takes (17 sec), much more than the pack + install local (250 ms).
Also it is weird the time for the enable command, with is taking more than installing the snap.
Also something that could be reviewed is the time to complete the connect (about 3 seconds).

The objective of this analisys is to improve the performance time of the snap commands, and also to reduce the test time on devices with is taking about 4.5 hours to run the snapd suite.

There is an open PR with these tests PR

Awesome. Is the doc intended to be public? (It currently isn’t).

I have updated the doc to make it public. Thanks for the heads up.

FYI, some (but not all) of this will be due to apparmor_parser, which is slower on armhf than other architectures. Each connect/disconnect changes the policy so this is aggravated. For real world usage (nobody connect/disconnects interfaces hundreds of times in a row), snapd tries hard to only generate new policy when it has to and apparmor uses policy caching to avoid compiling altogether. There are compiler improvements that can be had (policy compiles can never be totally free) but it is prioritized below quite a few other things since in practice, policy caching and snapd try to avoid compiles most of the time.