squashing the beast into a 60mb cage
play

Squashing the beast into a 60MB cage Tor Lillqvist - PowerPoint PPT Presentation

Squashing the beast into a 60MB cage Tor Lillqvist <tml@collabora.com> tml, #libreoffice-dev, irc.freenode.net Background: One single executable in an iOS app. No own shared libs Repeat: all non-system code has to be in one executable


  1. Squashing the beast into a 60MB cage Tor Lillqvist <tml@collabora.com> tml, #libreoffice-dev, irc.freenode.net

  2. Background: One single executable in an iOS app. No own shared libs

  3. Repeat: all non-system code has to be in one executable

  4. App Store rules: “iOS App binary files can be as large as 2 GB”

  5. “but”

  6. “the executable file cannot exceed 60 MB”

  7. We have one test iOS app: TiledLibreOffice

  8. (which is a simple viewer for Writer docs)

  9. At first, the TiledLibreOffice executable was ~90MB

  10. (optimised build, no debug information or symbols in the file)

  11. A third had to go without loss of functionality

  12. Obviously there is a lot of code that gets linked in but never will get called at run-time

  13. But we don't want to sprinkle ugly ifdefs all over the place if we don't have to

  14. Only in as few key places as possible

  15. Largest code reduction: ICU data

  16. (“Internationalisation Components for Unicode”)

  17. Normally, ICU data is present as constant data in code segment

  18. When building ICU one has the option to use a data file instead

  19. This data file needs to be memory-mapped in and passed to a single ICU call

  20. Saving from ICU data: 23MB. Still lots to go

  21. Locale data tables

  22. Desktop LibreOffice includes data for all locales we know of

  23. … but no need to do that in an iOS app

  24. Introduce --with-locales configure-time option

  25. Restricts what locales have data compiled in

  26. Even better would be to use data files instead of constant data in code

  27. … but that can be complicated

  28. Our Japanese and Chinese “dictionaries” are large

  29. Luckily simply structured, so can use memory- mapped data files instead

  30. Use generated data files instead of generated code for OOXML custom shape presets

  31. Split UNO components into smaller ones by refactoring factory methods

  32. More aggressive ifdeffing-out of code irrelevant on mobile platforms

  33. (for instance: to bypass code for desktop-style help, a11y features or extensions)

  34. Charset/encoding conversion tables in sal: Optionally bin obscure ones

  35. Tell compiler to optimise harder: -Oz

  36. Unfortunately, somewhat fragile, compiler bugs?

  37. Link-time optimisation? Not feasible: Linker grew to 40 GB in one hour before I lost patience

  38. Non-issue: Unreferenced functions. Linker is smart, we use -dead_strip

  39. Note: Don't make assumptions based on Linux experience

  40. Apple's object file format, executable file format, and toolchain are different

  41. How to find stuff to get rid of?

  42. Inspect the linker map, workdir/ TiledLibreOffice.map

  43. Use the bin/ios-mapfile- statistics script

  44. Oh, and after the squashing spree, the size of TiledLibreOffice was 43MB

  45. Thanks to CloudOn for funding this work

  46. FIN

  47. Collabora ● C o l l a b o r a L t d . – L e a d i n g O p e n S o u r c e C o n s u l t a n c y – 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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend