Ubuntu Desktop aims to deliver an open source operating system, available to everyone that just works for whatever they need. With Ubuntu 22.04 LTS, we believe we’ve come closer than ever to achieving that goal. However, as always, there are still a number of areas we want to improve to deliver the highest quality user experience. One of those areas is our default browser, Firefox, which transitioned to being distributed as a snap with Ubuntu 21.10.
To understand this decision, I want to focus on the ‘just works’ part of my opening statement. The Firefox snap offers a number of benefits to daily users of Ubuntu as well as a range of other Linux distributions. It improves security, delivers cross-release compatibility and shortens the time for improvements from Mozilla to get into the hands of users.
Currently, that decision has trade-offs when it comes to performance, most notably in Firefox’s first launch after a system reboot. A part of this is due to the inherent nature of sandboxing, however we feel there is still significant opportunity to improve start-up times across the board. We want to share the results of some of those investigations today, as well as highlight some recent meaningful changes in this area
This is an ongoing journey, and this blog article will be the first in a series as we update you on our progress.
Ultimately, the real test will be how you, the user, experience these updates as they land. At the end of this post, we’ve put together some tools to help you keep track of the snap performance on your own machines. If you still have questions you can also join us tomorrow for our monthly Ubuntu Desktop Team Indaba, where this topic will be our main focus.
Let’s dive right in.
This decision was made in collaboration with Mozilla based on the quality of life improvements that snap delivers:
We can divide our performance analysis into three specific areas:
Our current focus is on the cold start performance and we’ve been following a similar approach to our work on the Chromium snap to isolate the root causes.
When we talk about “cold start” we mean without any libraries loaded into memory. Essentially running Firefox right after a reboot, where the profile already exists on disk.
A “cold start after purge” means without any caches, nothing in memory, and no profile created. When an app initialises, various things are created in memory and on disk and a ‘cold – purge’ is essentially the worst-case scenario. This is basically what you have after a fresh install of Ubuntu, but we can simulate that by purging the snap and rebooting
In practice this is done by running:
sudo snap remove --purge firefox
This removes the snap and all snap data, including your Firefox profile and caches
Reboot and login. Then run:
sudo snap install firefox
Click the Firefox icon and wait for the window to appear to get your cold – purge time.
2019 Dell XPS 13 stable – rev 1377 (s) | Thinkpad X240 stable – rev 1377 (s) | Pi 400 (SD card) stable – rev 1381 (s) | |
Cold – Purge | 7.67 | 15.07 | 38.23 |
Cold | 3.09 | 15.16 | 22.92 |
Warm | 0.86 | 1.39 | 8.11 |
With these benchmarks established, we started profiling the cold – purge start under various configurations, including:
From this we were able to measure and compare:
Based on these tests, we identified a number of culprits for the slower startup (in order of estimated impact).
The snap is packed into a compressed squashfs which can create a bottleneck on more resource-constrained systems like the Raspberry Pi. For Firefox, which is quite heavy on the I/O during startup, this creates noticeable overhead as it searches for files in the squashfs. We’re investigating improving the ordering of content in the squashfs to improve seek times.
Something we identified whilst testing on the Raspberry Pi was that the current Firefox snap fails to determine which GPU driver it should use in its glxtest program. This causes Firefox to start up with the software renderer, adding significant overhead to shader compilation time. This was also observed on AMD GPUs.
Good news! A fix for this has now landed in upstream snapd.
Firefox creates a copy of all extensions that are bundled with the firefox package to a user-specific directory upon first start for each user. This is done by going through each extension and copying them block-by-block. In the snap, we bundle 98 language packs which unfortunately take quite a while to copy into the user directory. Especially because the language-packs are read from a compressed squashfs image.
When Firefox is confined, significant time is spent discovering all possible icon themes, font configurations and available fonts. This is not done when running unconfined, where Firefox simply loads what it needs instead.
These four issues are our current areas of focus when it comes to cold starts. We will add tracking bugs and updates to these sections going forward so you can follow our progress.
Future blogs will dive further into other areas of Firefox snap performance, but in the meantime, we wanted to share two additional updates.
With the release of Firefox 100.0 we enabled PGO and LTO. This has made significant improvements to runtime performance and is available in the current release. It also has some impact on startup times.
Beyond performance, native messaging has been our most significant outstanding issue to resolve. Native messaging enables a number of key features such as 2FA devices and GNOME extensions.
We have implemented a new XDG Desktop Portal to support this which is already in 22.04 as a distro patch that we are working to upstream. This portal is also useful for other packaging systems like flatpak as well as snap.
The integration with Firefox is also currently in review and expected to land next month.
If you are experiencing any other bugs or issues, please report them on the Mozilla meta-bug.
Whilst we’ve attempted to portray our performance improvements in this post as transparently and fairly as possible, we know that there’ll always be folks who want to see the data for themselves, on their own hardware. To that end, we’ve collected a suite of options for users to run their own benchmarks.
Our very own Marco ‘3v1n0‘ Trevisan has created a handy GNOME extension, the Applications Startup Time Measure, to avoid you wearing out your stopwatch.
To get it you first need to install the GNOME Extension Manager:
sudo apt install gnome-shell-extension-manager
Then open extension-manager, navigate to “Browse” and search for “startup”:
Choose ‘Install’ and that’s it. Now every application you launch (limited to launching via application icons) will display how long the application took to go from start to shown on-screen.
For side by side comparisons with the original snap that launched with Ubuntu 22.04 you can also switch to this channel:
sudo snap refresh --channel=latest/stable/jammy-release
Finally, if you want to go more in-depth, you can always add the Firefox Profiler to Firefox and share your insights.
Let us know your results in the ‘Known issues with the Firefox Snap?’ Discourse thread, and keep us updated over time as new improvements roll out.
That’s all for now! Check back in soon for part 2 and an update on our ongoing performance improvements.
Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…
Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…
At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…
I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…
Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…
Now I want to share the DNS server installation process on your Ubuntu 20.04 server.…