Your submission was sent successfully! Close

Thank you for contacting us. A member of our team will be in touch shortly. Close

You have successfully unsubscribed! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates about Ubuntu and upcoming events where you can meet our team.Close

Snap startup time improvements

This article is more than 5 years old.


Several months ago, we shared an article titled I have a need, a need for snap that detailed the application performance results of snaps compared to their classic repo counterparts. We tested GIMP and VLC on both Ubuntu and Fedora, with some rather interesting findings.

The one aspect of the application usage sequence we did not cover in that piece was the first-time run just after the installation. In general, with graphical software, this used to take a fair deal of time, causing a delay in application opening, and would impair the user experience. We took this problem seriously, and implemented changes that resolve most of the issues, and we’d like to talk about them here.

Overview of the problem

We simulated a typical run of an application after it’s been installed, the same way a Linux user would do. We tested the behavior of the Vscode application,as it’s a fairly representative example of a GUI-based software. After the installation, we timed the loading of Vscode. We conducted several permutations of this test, including different hardware platforms, Linux distributions, and packaging formats (DEB, RPM and Snaps).

The results below were gathered on a system with 6-core/12-thread Xeon(TM) processor, 64GB RAM, 2TB 970 EVO NVMe SSD, and Nvidia Quadro(R) P2000 GPU.

SystemUbuntu 16.04Ubuntu 18.04.1Ubuntu 18.10
snap2.35.52.35.52.35.5
snapd2.35.52.35.52.35.5
series161616
kernel4.15.0-38-generic4.15.0-39-generic4.18.0-10-generic
Vscode (DEB) [s]20.38.015.3
Vscode (Snap) [s]32.8127.8119.9

Similarly, we collected the results on a system with 4-core i3(TM) processor, 4GB RAM, 1TB 5,400rpm mechanical hard disk, and Intel(R) HD 440 graphics, on Fedora 29 Workstation and Kubuntu 18.10 distributions.

SystemFedora 29 WorkstationKubuntu 18.10
snap2.36-1.fc292.36.1
snapd2.36-1.fc292.36.1
series1616
kernel4.19.3-300.fc29.x86_644.18.0-11-generic
Vscode (RPM/DEB) [s]28.522.3
Vscode (Snap) [s]57.779.5

The significant difference in results between platforms (and on each platform separately) indicates the hardware configuration plays a less important part than the behaviour of the snap sub-system. We focused on profiling the application startup, and after thorough investigation, we narrowed down the issue to font cache generation on the first run.

Namely, graphic desktop applications typically use the fontconfig library to query available fonts on the system. This operation happens on application startup. For improved performance, fontconfig will use font information cache files built by the fc-cache utility available in the fontconfig bundle.

If there are no existing font caches, or they cannot be accessed for any reason, they will be generated. This task can take a long time, especially if there is a large number of fonts that needs to be enumerated (which can vary from system to system, also accounting for some variation in actual application loading times), during which the GUI application may not render on the screen, and users will interpret this delay as a slow application startup.

Fontconfig cache improvements

To resolve the issue of slow application startups due to font cache generation, starting with snap 2.36.2, fc-cache-v6 and fc-cache-v7 binaries are included in the core snap, and they are used to create fontconfig caches automatically when snaps get installed – at the installation time. This operation eliminates the excessively long startup times that some users have been seeing. With these architectural results in place, the results now portray a different picture. While there is still some time penalty, similar to what we have outlined in the first article, the difference is much more tolerable.

On the Xeon(TM)-powered machine, we see roughly a 6x improvement in loading times. For instance, with Ubuntu 18.10, the loading times are reduced from about 2 minutes to about 20 seconds.

SystemSnap/snapdVscode (DEB) [s]Vscode (Snap) [s]
Ubuntu 18.102.36.215.322.9

On the i3(TM)-powered host, we also see significant improvements. With Fedora 29, the snap startup time is roughly halved. With the Kubuntu 18.10, we have observed a 3x improvement.

In is useful to note that there is also some variation in the startup time of the Vscode application installed from the distribution repo (19.1±5.4 seconds), caused mostly by background system activity. Similarly, on the first test platform, we observed a startup time of 14.5±6.2 seconds for the DEB package.

SystemSnap/snapdVscode (RPM/DEB) [s]Vscode (Snap) [s]
Fedora 29 Workstation2.37.4-2.fc2921.232.0
Kubuntu 18.102.37.4+18.1017.222.6

We also profiled yet a third machine, running 4-core/8-thread i5(TM) processor, 16GM RAM, 500GB SSD, and Intel(R) UHD 620 graphics, with Kubuntu 18.04.2 installed, with the 4.15.0-46-generic kernel and snapd/snapd 2.37.4. On this machine, we observed the most favorable results for both the repo-provided and snap-provided Vscode applications, with very fast launch times (<10 seconds).

SystemSnap/snapdVscode (DEB) [s]Vscode (Snap) [s]
Kubuntu 18.04.22.37.42.96.8

With font cache improvements in place, the loading of the Vscode snap takes roughly 4-11 seconds longer than the repo-provided package, with an average value of 6.7 seconds. With the startup times no longer impacted by font caches, we can now also focus on package format and platform-specific differences. From our previous tests, we know that the initial delay of about 2-3 seconds is expected on “cold” application starts. The remaining delta stems from a number of other factors.

For instance, Vscode needs to load its embedded libraries (approximately 80 libraries). This results in about 9,700 I/O operations compared to about ~4,500 I/O operations for the Debian package, which does not use embedded libraries. In general, any approach that bundles libraries has to bear this cost. However, it can be mitigated by sharing libs from a common snap, like the gnome-3-* content snap or via bases.

We will examine and explain these factors in detail in future articles. Indeed, we are continuing to profile and analyze these results, so we can introduce additional optimization and improvements.

Conclusion

The inclusion of fc-cache binaries in snapd 2.36.2 onwards introduces significant (2-6x) improvements in GUI application startup times. The results are applicable for both Ubuntu and non-Ubuntu platforms. Snaps users across different Linux distributions should be able to see immediate, positive differences in the loading of their snaps. The exact figures will depend on the application type, usage patterns and, to a lesser extent, the underlying hardware platform choice.

We believe our testing with Vscode provides a good, indicative example of a complex GUI tool. The reduced application loading times on first run should translate into a more streamlined and enjoyable user experience. If you have any feedback or suggestions on this topic, please join our forum for a discussion.

Photo by Robin Pierre on Unsplash.

Ubuntu desktop

Learn how the Ubuntu desktop operating system powers millions of PCs and laptops around the world.

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

Managing software in complex network environments: the Snap Store Proxy

As enterprises grapple with the evolving landscape of security threats, the need to safeguard internal networks from the broader internet is increasingly...

Improving snap maintenance with automation

Co-written with Sergio Costas Rodríguez. As the number of snaps increases, the need for automation grows. Any automation to help us maintain a group of snaps...

Snapcraft 8.0 and the respectable end of core18

‘E’s not pinin’! ‘E’s passed on! This base is no more! He has ceased to be! ‘E’s expired and gone to meet ‘is maker! ‘E’s a stiff! Bereft of life, ‘e rests in...