Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One...
Transcript of Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One...
![Page 1: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/1.jpg)
Squashing the beast into a 60MB cage
Tor Lillqvist <[email protected]>
tml, #libreoffice-dev, irc.freenode.net
![Page 2: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/2.jpg)
Background: One single executable in an iOS
app. No own shared libs
![Page 3: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/3.jpg)
Repeat: all non-system code has to be in one
executable
![Page 4: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/4.jpg)
App Store rules: “iOS App binary files can be
as large as 2 GB”
![Page 5: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/5.jpg)
“but”
![Page 6: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/6.jpg)
“the executable file cannot exceed 60 MB”
![Page 7: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/7.jpg)
We have one test iOS app: TiledLibreOffice
![Page 8: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/8.jpg)
(which is a simple viewer for Writer docs)
![Page 9: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/9.jpg)
At first, the TiledLibreOffice
executable was ~90MB
![Page 10: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/10.jpg)
(optimised build, no debug information or symbols in the file)
![Page 11: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/11.jpg)
A third had to go without loss of functionality
![Page 12: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/12.jpg)
Obviously there is a lot of code that gets linked
in but never will get called at run-time
![Page 13: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/13.jpg)
But we don't want to sprinkle ugly ifdefs all
over the place if we don't have to
![Page 14: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/14.jpg)
Only in as few key places as possible
![Page 15: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/15.jpg)
Largest code reduction: ICU data
![Page 16: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/16.jpg)
(“Internationalisation Components for
Unicode”)
![Page 17: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/17.jpg)
Normally, ICU data is present as constant data
in code segment
![Page 18: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/18.jpg)
When building ICU one has the option to use a
data file instead
![Page 19: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/19.jpg)
This data file needs to be memory-mapped in and passed to a single ICU
call
![Page 20: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/20.jpg)
Saving from ICU data: 23MB. Still lots to go
![Page 21: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/21.jpg)
Locale data tables
![Page 22: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/22.jpg)
Desktop LibreOffice includes data for all locales we know of
![Page 23: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/23.jpg)
… but no need to do that in an iOS app
![Page 24: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/24.jpg)
Introduce --with-locales configure-time option
![Page 25: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/25.jpg)
Restricts what locales have data compiled in
![Page 26: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/26.jpg)
Even better would be to use data files instead of constant data in code
![Page 27: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/27.jpg)
… but that can be complicated
![Page 28: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/28.jpg)
Our Japanese and Chinese “dictionaries”
are large
![Page 29: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/29.jpg)
Luckily simply structured, so can use memory-
mapped data files instead
![Page 30: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/30.jpg)
Use generated data files instead of generated
code for OOXML custom shape presets
![Page 31: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/31.jpg)
Split UNO components into smaller ones by refactoring factory
methods
![Page 32: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/32.jpg)
More aggressive ifdeffing-out of code irrelevant on mobile
platforms
![Page 33: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/33.jpg)
(for instance: to bypass code for desktop-style help, a11y features or
extensions)
![Page 34: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/34.jpg)
Charset/encoding conversion tables in sal: Optionally bin obscure
ones
![Page 35: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/35.jpg)
Tell compiler to optimise harder: -Oz
![Page 36: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/36.jpg)
Unfortunately, somewhat fragile, compiler bugs?
![Page 37: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/37.jpg)
Link-time optimisation? Not feasible: Linker grew
to 40 GB in one hour before I lost patience
![Page 38: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/38.jpg)
Non-issue: Unreferenced functions. Linker is
smart, we use -dead_strip
![Page 39: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/39.jpg)
Note: Don't make assumptions based on
Linux experience
![Page 40: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/40.jpg)
Apple's object file format, executable file format,
and toolchain are different
![Page 41: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/41.jpg)
How to find stuff to get rid of?
![Page 42: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/42.jpg)
Inspect the linker map, workdir/
TiledLibreOffice.map
![Page 43: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/43.jpg)
Use the bin/ios-mapfile-statistics script
![Page 44: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/44.jpg)
Oh, and after the squashing spree, the
size of TiledLibreOffice was 43MB
![Page 45: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/45.jpg)
Thanks to CloudOn for funding this work
![Page 46: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/46.jpg)
FIN
![Page 47: Squashing the beast into a 60MB cage · tml, #libreoffice-dev, irc.freenode.net. Background: One single executable in an iOS app. No own shared libs. Repeat: all non-system code has](https://reader033.fdocuments.net/reader033/viewer/2022050213/5f5f016456b4e17d363911ba/html5/thumbnails/47.jpg)
Collabora
● Collabora Ltd.– Leading Open Source Consultancy
– 8 years of experience. 90+ People.
● Collabora Productivity Ltd.
– Dedicated to Enterprise LibreOffice
– Provides Level-3 support (code issues) to all Novell / SUSE LibreOffice clients
– Architects of Microsoft OpenXML filters