How to reduce flatpak app size?

Aleix Pol aleixpol at kde.org
Tue Aug 7 12:38:11 UTC 2018


On Tue, Aug 7, 2018 at 10:38 AM Alexander Larsson <alexl at redhat.com> wrote:
>
> I looked at what runtimes these apps use, and they are almost all different:
>
> spotify - org.freedesktop.Platform 1.6
> gimp - org.gnome.Platform 3.28
> org.telegram.desktop - org.kde.Platform 5.9
> visual studio - org.freedesktop.Sdk 1.6
> android studio - org.freedesktop.Sdk 1.6
>
> However, things are not as bad as they appear, because both the gnome
> and the kde platforms are based on the freedesktop one, so if you have
> both installed they share lots of files.
> Here are the total size used by these installed runtime together:
>
> $ cd /var/lib/flatpak/flatpak/runtime
> $ du -csh org.freedesktop.Platform/x86_64/1.6/
> org.gnome.Platform/x86_64/3.28/ org.kde.Platform/x86_64/5.9/
> org.freedesktop.Sdk/x86_64/1.6/
> 560M    org.freedesktop.Platform/x86_64/1.6/
> 253M    org.gnome.Platform/x86_64/3.28/
> 542M    org.kde.Platform/x86_64/5.9/
> 620M    org.freedesktop.Sdk/x86_64/1.6/
> 2.0G    total
>
> Whereas this is the size of each individual one, not counting the sharing:
>
> $ for i in org.freedesktop.Platform/x86_64/1.6/
> org.gnome.Platform/x86_64/3.28/ org.kde.Platform/x86_64/5.9/
> org.freedesktop.Sdk/x86_64/1.6/; do du -sh $i; done
> 560M    org.freedesktop.Platform/x86_64/1.6/
> 796M    org.gnome.Platform/x86_64/3.28/
> 1.1G    org.kde.Platform/x86_64/5.9/
> 1.1G    org.freedesktop.Sdk/x86_64/1.6/
>
> The later sums to 3.5 G, so, about 1.5 G is shared between these.
> Also, the org.freedesktop.Sdk runtime is actually a full development
> runtime with all the tools needed for building apps, rather than a
> minimal runtime, so that will always be large.
>
> The kde runtime does seem a bit large though. Partly because it
> contains a 250 meg libQt5WebEngineCore. Aleix, could this be made
> smaller?
>
> Anyway, I think the exact set of apps you installed was sort of
> non-optimal in terms of measuring sharing. Once you have these
> runtimes installed its unlikely that further apps will require more
> runtimes.
> On Mon, Aug 6, 2018 at 4:31 PM M. A. Spadaru <maspadaru at gmail.com> wrote:
> >
> > Hello again,
> >
> >
> > Sorry for not being clear enough when describing my method. Here is a better description:
> >
> >
> > Test:
> >
> > Read used disk space: d1
> >
> > Install spotify
> >
> > Run spotify + login + play “Manowar - Carry on”
> >
> > Read used disk space: d2
> >
> > Compute disk footprint of spotify as d2-d1
> >
> > Install VSCore
> >
> > Run VSCore + open an existing project folder + edit and save a file
> >
> > Read used disk space: d3
> >
> > Compute disk footprint of VSCode as d3-d2
> >
> > Install telegram-desktop
> >
> > Run telegram-desktop + login + send a message to a friend
> >
> > Read used disk space: d4
> >
> > Compute disk footprint of telegram-desktop as d4-d3
> >
> > Install Gimp
> >
> > Run Gimp + open an image
> >
> > Read used disk space: d5
> >
> > Compute disk footprint of Gimp as d5-d4
> >
> > Install Android-Studio
> >
> > Run Android-Studio + create new project + install sdk + run project
> >
> > Read used disk space: d6
> >
> > Compute disk footprint of Android-Studio as d6-d5
> >
> >
> > After a test I would uninstall the apps, dependencies, and settings/config files and any leftover files I could find, as best I could. Then proceed to the next test. I executed these 3 tests in this order: Native, Snap, Flatpak.
> >
> > I read the used space on my disk using GParted. Since I have only one partition (except swap and /boot/efi), I think this method of computing the used disk space should cover any app files, dependencies, package format specific files and any config files added to /home. It should also over any files added by snapd and the core snap.
> >
> >
> > As pointed out by Alexander Larsson, my values seem to imply that I am starting from scratch downloading the runtimes for each flatpak application. However, this was not the case. When installing the GIMP flatpak, the flatpaks of Spotify, VSCode, and Telegram are already installed. Still GIMP needs 450MB of storage space.
> >
> >
> > I also expected that flatpak apps would share runtimes, however this does not seem to be the case. So, returning to my initial question: Is it possible to reduce the size of this overhead of each individual app? Maybe a way to force apps to share runtimes?
> >
> >
> > Cheers,
> >
> > Mike
> >
> >
> > On 08/06/2018 11:14 AM, Muayyad AlSadi wrote:
> >
> > I guess the VSCode and alike require SDK runtime (having compiler, headers ..etc) which is like *-devel host packages
> > snap does not ship those
> >
> >
> > On Mon, Aug 6, 2018 at 11:37 AM Alexander Larsson <alexl at redhat.com> wrote:
> >>
> >> On Thu, Jul 12, 2018 at 9:05 AM, Mike Spadaru <maspadaru at gmail.com> wrote:
> >> > Dear Flatpak community,
> >> >
> >> > I attempted a small experiment to benchmark Snap and Flatpak. On
> >> > Ubuntu 16.04 I picked some apps: Spotify, VSCode, Telegram-Desktop,
> >> > Gimp, Android-Studio. I performed three tests Native (via apt, .deb or
> >> > PPA), Snap and Flatpak. In each test I would read the used disk space,
> >> > install an app, run the app and perform a task (same task in each
> >> > test), then read the used disk space again. Before moving to the next
> >> > test, I uninstalled all the apps and removed any config files created.
> >> >
> >> > The machine uses only one disk partition. I also recorded CPU, RAM and
> >> > Power consumption, but there was no clear difference between the three
> >> > package formats.  My results for the disk usage are shown bellow.
> >> > Values are in mega-bytes:
> >> >
> >> > | App | Native | Snap | Flatpak |
> >> > | Spotify | 240 | 290 | 980 |
> >> > | VSCode | 270 | 220 | 1030 |
> >> > | Telegram | 80 | 100 | 600 |
> >> > | Gimp | 80 | 200 | 450 |
> >> > | Android Studio | 3290 | 3330 | 5930 |
> >>
> >> This is not really a fair comparison. You already have basically all
> >> the dependencies of the native packages installed, so installing just
> >> the app is just going to measure the app itself, whereas the flatpak
> >> application will download the dependencies (the runtime) in addition
> >> to the app.
> >> The same happens for snap, i.e. since you're on ubuntu it will already
> >> have installed the ubuntu core snap, so you're not counting that space
> >> against the app.
> >>
> >> Also, the values you get seem to imply that you're starting from
> >> scratch downloading the runtimes for each flatpak application, but
> >> most apps share the runtimes so if you were to install all the
> >> flatpaks at the same time the total size would not add up to the sum
> >> of your measured sizes.
> >>
> >> A better test of snap/flatpak might be to first remove all of snapd,
> >> including all snaps (thus also the core snap), then measure the free
> >> space, install snapd + al* the above snaps and compare the free size
> >> with before. Then do the same with all flatpaks in one install.
> >> That way you will count shared things only once, and accurately
> >> include the size of the snap base in the comparison.
> >> _______________________________________________
> >> Flatpak mailing list
> >> Flatpak at lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/flatpak

Hi,
Yes, I know Qt5WebEngine is too big there and part of the problem. My
fear there is that as soon as 2 applications start to use it we'll be
on the worse side of things automatically. I'll be happy to consider
it for 5.12.

Aleix


More information about the Flatpak mailing list