[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/3497776.3517764acmconferencesArticle/Chapter ViewAbstractPublication PagesccConference Proceedingsconference-collections
research-article
Open access

Efficient profile-guided size optimization for native mobile applications

Published: 18 March 2022 Publication History

Abstract

Positive user experience of mobile apps demands they not only launch fast and run fluidly, but are also small in order to reduce network bandwidth from regular updates. Conventional optimizations often trade off size regressions for performance wins, making them impractical in the mobile space. Indeed, profile-guided optimization (PGO) is successful in server workloads, but is not effective at reducing size and page faults for mobile apps. Also, profiles must be collected from instrumenting builds that are up to 2X larger, so they cannot run normally on real mobile devices.
In this paper, we first introduce Machine IR Profile (MIP), a lightweight instrumentation that runs at the machine IR level. Unlike the existing LLVM IR instrumentation counterpart, MIP withholds static metadata from the instrumenting binaries leading to a 2/3 reduction in size overhead. In addition, MIP collects profile data that is more relevant to optimizations in the mobile space. Then we propose three improvements to the LLVM machine outliner: (i) the global outliner overcomes the local scope of the machine outliner when using ThinLTO, (ii) the frame outliner effectively outlines irregular prologues and epilogues, and (iii) the custom outliner outlines frequent patterns occurring in Objective-C and Swift. Lastly, we present our PGO that orders hot start-up functions to minimize page faults, and controls the size optimization level (-Os vs -Oz) for functions based on their estimated execution time driven from MIP. We also order cold functions based on similarity to minimize the compressed app size.
Our work improves both the size and performance of real-world mobile apps when compared to the MinSize (-Oz) optimization level: (i) in SocialApp, we reduced the compressed app size by 5.2%, the uncompressed app size by 9.6% and the page faults by 20.6%, and (ii) in ChatApp, we reduced them by 2.4%, 4.6% and 36.4%, respectively.

References

[1]
Arm. 2021. Arm A64 Instruction Set Architecture. https://developer.arm.com/documentation/ddi0596/2021-09
[2]
Brenda S. Baker, Udi Manber, and Robert Muth. 1999. Compressing differences of executable code. In ACM SIGPLAN 1999 Workshop on Compiler Support for System Software (WCSSS’99).
[3]
Milind Chabbi, Jin Lin, and Raj Barik. 2021. An Experience with Code-Size Optimization for Production IOS Mobile Applications. In Proceedings of the 2021 IEEE/ACM International Symposium on Code Generation and Optimization (CGO ’21). Association for Computing Machinery, New York, NY, USA. 363–366. isbn:9781728186139 https://doi.org/10.1109/CGO51591.2021.9370306
[4]
Stephanie Chan. 2021. The iPhone’s Top Apps Are Nearly 4x Larger Than Five Years Ago. https://sensortower.com/blog/ios-app-size-growth-2021
[5]
Dehao Chen, Tipp Moseley, and David Xinliang Li. 2016. AutoFDO: Automatic feedback-directed optimization for warehouse-scale applications. In 2016 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 12–23.
[6]
Malcolm C. Easton and Ronald Fagin. 1978. Cold-Start vs. Warm-Start Miss Ratios. Commun. ACM, 21, 10 (1978), Oct., 866–872. issn:0001-0782 https://doi.org/10.1145/359619.359634
[7]
Facebook. 2021. ReDex: An Android Bytecode Optimizer. https://github.com/facebook/redex/blob/master/libredex/MethodSimilarityOrderer.h
[8]
GNU. 2020. XZ Utils. https://tukaani.org/xz
[9]
Irfan Ul Haq and Juan Caballero. 2021. A Survey of Binary Code Similarity. ACM Comput. Surv., 54, 3 (2021), Article 51, April, 38 pages. issn:0360-0300 https://doi.org/10.1145/3446371
[10]
Ellis Hoag and Kyungwoo Lee. 2021. RFC: Machine IR Profile. https://lists.llvm.org/pipermail/llvm-dev/2021-June/151086.html
[11]
Apple Inc. 2015. LZFSE compression library and command line tool. https://github.com/lzfse/lzfse
[12]
Apple Inc. 2021. Automatic Reference Counting. https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html
[13]
Apple Inc. 2021. Document for objc_msgSend. https://developer.apple.com/documentation/objectivec/1456712-objc_msgsend
[14]
Meta Inc. 2021. Superpack: Pushing the limits of compression in Facebook’s mobile apps. https://engineering.fb.com/2021/09/13/core-data/superpack/
[15]
LLVM Compiler Infrastructure. 2021. MergeFunctions pass, how it works. https://llvm.org/docs/MergeFunctions.html
[16]
Teresa Johnson, Mehdi Amini, and Xinliang David Li. 2017. ThinLTO: Scalable and Incremental LTO. In Proceedings of the 2017 International Symposium on Code Generation and Optimization (CGO ’17). IEEE Press, 111–121. isbn:9781509049318
[17]
Aditya Kumar, Ian Levesque, and Sam Todd. 2020. Cheap Function Entry Instrumentation. https://llvm.org/devmtg/2020-02-23/slides/Aditya-FunctionEntryInstrumentationLLVM.pdf
[18]
Kyungwoo Lee. 2020. Homogeneous Prolog and Epilog for Size Optimization. https://lists.llvm.org/pipermail/llvm-dev/2020-March/140206.html
[19]
Kyungwoo Lee and Nikolai Tillmann. 2020. Improving Machine Outliner for ThinLTO. https://llvm.org/devmtg/2020-02-23/slides/Kyungwoo-GlobalMachineOutlinerForThinLTO.pdf
[20]
Giovanni Motta, James Gustafson, and Samson Chen. 2007. Differential Compression of Executable Code. In 2007 Data Compression Conference (DCC’07). 103–112. https://doi.org/10.1109/DCC.2007.32
[21]
Andy Newell and Sergey Pupyrev. 2020. Improved Basic Block Reordering. IEEE Trans. Comput., 69, 12 (2020), 1784–1794. https://doi.org/10.1109/TC.2020.2982888
[22]
Guilherme Ottoni and Bertrand Maher. 2017. Optimizing function placement for large-scale data-center applications. In 2017 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 233–244. https://doi.org/10.1109/CGO.2017.7863743
[23]
Maksim Panchenko, Rafael Auler, Bill Nell, and Guilherme Ottoni. 2019. BOLT: A Practical Binary Optimizer for Data Centers and Beyond. In 2019 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 2–14. https://doi.org/10.1109/CGO.2019.8661201
[24]
Jessica Paquette. 2016. Reducing Code Size Using Outling. https://llvm.org/devmtg/2016-11/Slides/Paquette-Outliner.pdf
[25]
Alan Phipps and Cody Addison. 2020. Source-based Code Coverage for Embedded Use Cases. https://llvm.org/devmtg/2020-09/slides/PhippsAlan_EmbeddedCodeCoverage_LLVM_Conf_Talk_final.pdf
[26]
Manman Ren. 2019. Order File Instrumentation. https://lists.llvm.org/pipermail/llvm-dev/2019-January/129268.html
[27]
River Riddle. 2018. IR Outliner Pass. https://reviews.llvm.org/D53942
[28]
Rodrigo C. O. Rocha, Pavlos Petoumenos, Zheng Wang, Murray Cole, Kim Hazelwood, and Hugh Leather. 2021. HyFM: Function Merging for Free. In Proceedings of the 22nd ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES 2021). Association for Computing Machinery, New York, NY, USA. 110–121. isbn:9781450384728 https://doi.org/10.1145/3461648.3463852
[29]
Rodrigo C. O. Rocha, Pavlos Petoumenos, Zheng Wang, Murray Cole, and Hugh Leather. 2020. Effective Function Merging in the SSA Form. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2020). Association for Computing Machinery, New York, NY, USA. 854–868. isbn:9781450376136 https://doi.org/10.1145/3385412.3386030
[30]
Greg Roelofs. 2008. Info-ZIP. http://infozip.sourceforge.net/Zip.html
[31]
Apple Open Source. 2021. Source code for objc-arr.mm. https://opensource.apple.com/source/objc4/objc4-493.9/runtime/objc-arr.mm
[32]
The Clang Team. 2021. Clang Compiler User’s Manual. https://clang.llvm.org/docs/UsersManual.html##profile-guided-optimization
[33]
The Clang Team. 2021. Objective-C Automatic Reference Counting (ARC) — Clang 13 documentation. https://clang.llvm.org/docs/AutomaticReferenceCounting.html

Cited By

View all
  • (2024)The Cost of Profiling in the HotSpot Virtual MachineProceedings of the 21st ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes10.1145/3679007.3685055(112-126)Online publication date: 13-Sep-2024
  • (2024)Reordering Functions in Mobiles Apps for Reduced Size and Faster Start-UpACM Transactions on Embedded Computing Systems10.1145/366063523:4(1-54)Online publication date: 10-Jun-2024
  • (2024)Procedural Abstraction on RISC-V Using TP Register2024 IEEE 7th Information Technology, Networking, Electronic and Automation Control Conference (ITNEC)10.1109/ITNEC60942.2024.10733182(1246-1257)Online publication date: 20-Sep-2024
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
CC 2022: Proceedings of the 31st ACM SIGPLAN International Conference on Compiler Construction
March 2022
253 pages
ISBN:9781450391832
DOI:10.1145/3497776
This work is licensed under a Creative Commons Attribution International 4.0 License.

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 18 March 2022

Check for updates

Author Tags

  1. iOS
  2. machine outlining
  3. mobile applications
  4. profile-guided optimizations
  5. size optimizations

Qualifiers

  • Research-article

Conference

CC '22
Sponsor:

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)520
  • Downloads (Last 6 weeks)64
Reflects downloads up to 03 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)The Cost of Profiling in the HotSpot Virtual MachineProceedings of the 21st ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes10.1145/3679007.3685055(112-126)Online publication date: 13-Sep-2024
  • (2024)Reordering Functions in Mobiles Apps for Reduced Size and Faster Start-UpACM Transactions on Embedded Computing Systems10.1145/366063523:4(1-54)Online publication date: 10-Jun-2024
  • (2024)Procedural Abstraction on RISC-V Using TP Register2024 IEEE 7th Information Technology, Networking, Electronic and Automation Control Conference (ITNEC)10.1109/ITNEC60942.2024.10733182(1246-1257)Online publication date: 20-Sep-2024
  • (2023)MePof: A Modular and End-to-End Profile-Guided Optimization Framework for Android Kernels2023 IEEE 47th Annual Computers, Software, and Applications Conference (COMPSAC)10.1109/COMPSAC57700.2023.00111(820-829)Online publication date: Jun-2023

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media