Booting my very capable PC has become a fingers-on-chalkboard-grating slow nightmare because of snap. It’s gone from 5-10 seconds to login screen after GRUB to now 30-45 seconds, sometimes up to a minute or more.
This is absurd.
I’d prefer to not remove every single snap on my machine, but I’m prepared to do that. How do I defeat snap mounts on boot and regain my sanity, without having to scorch the earth?
Specifically looking for an answer to this: how do I modify individual snaps so that they do not mount during boot?
This is a great question. It would be great if snaps could mount on demand (although that would slow down their startup even further) or have delayed mount until some other trigger, such as the desktop being launched. Some might auto-launch (like snap-store) and need to be launched earlier, whereas another like Spotify, which only launches when you click the icon could be mounted later.
well, i think a good start would be if only the actually running revision would be mounted (mounting the others during revert/refresh only) …
deciding based on the underlying system doesnt seem like such a good idea but basing on “its a service”, it should go into early boot vs “it doesnt ship any service” it can go late into systemd’s multi-user-target would appear better to me and require also less cleverness from snapd and the packaging system itself IMHO.
PS: actually if disabling the snap would unmount it, that would already be a massive improvement (and could actually help the original issue)
So @mborzecki looked into this a while ago and there seem to be some kernel bugs surrounding mounting many squashfs’s at the same time, resulting in inefficient clashing with multiple mount units trying to use the same device mapper, one of them wins the other fails and tries to find another one and fails, etc. etc.
Yes, there need to be decent heuristics. snap-store would fail your example. It’s not a service, but does have a background daemon/server, and is launched on desktop login.
based on my above heuristics (doesnt define daemon in snapcraft.yaml) it would be mounted while/after gdm starts in i.e. graphical-target, i think that would be totally fine …
Did you generate a graph of service dependencies, to check if Snaps are really the culprit? I may be wrong, but I believe the number shown in analyze are “unordered” - I mean, systemd parallelizes a lot and, even though they’re really big, they might not really be the cause of such slowness (but they might be, of course).
I think the command to do so is:
$ systemd-analyze plot > file.svg
Then you can use any SVG viewer to see what is really happening. There’s also a more “elaborate” version of command above:
systemd-analyze dot [PATTERN] > file.dot
You can the use graphviz tools to format and visualize the output.
I guess there’s no working in this matter?
It would be very useful if the developer could set in the yaml file whether the application requires automount or if it can be mounted on demand. I also don’t think it’d be very complicated to add to the description file (if no key is set, then consider it must be automonted, for backward compatibility purposes).
Some time ago, I dug a little on this subject. Fount out (at the time) that it would be possible to use kernel automount features to avoid (minimize?) this problem. Think it wasn’t up to the task, though.
I made my own tests. Snaps seem to consume around 4 and 5 mb of RAM when mounted (or rather, SquashFS do, which is the foundation for snaps).
This is very little for a few snaps, but can go up quite a lot when you start installing lots of apps through snap (which could easily be a preferred way).
I kindly request the team to have an option for those snaps that opt-in, for example, to be mounted on demand rather than during startup. It would also be nice if the user could force this behavior. Not everyone uses Ubuntu on powerful machines. Lubuntu users have low spec PCs which may have 4gb of RAM or less, and the raspberry pi and other SBCs are limited too. I’d really appreciate if the team could work on this, it shouldn’t be too difficult to do.