writing
iOS Launch Performance: A Reading GuideiOS 启动性能优化系列文章目录
· Performance & internals
Translated from Chinese — .
On this page
Over the past two-plus years, I’ve written a number of articles on iOS app launch performance optimization. This article puts together a simple table of contents.
The SpringBoard Stage
This is the stage where the iOS system’s SpringBoard launches the app; the app’s own process hasn’t started yet.
The pre-main Stage
The stage within the app’s own process, before the main function.
- A Method for Hooking Objective-C +load
- A Method for Hooking C++ static initializers
- A Method for Delaying premain code
- iOS App Launch Performance Optimization (1) - premain
- Hooking All +load Methods (Including Categories)
The main Stage
The stage from the main function to didFinishLaunching, and on to when the home screen finishes displaying.
- Methods for Getting the Current Time on iOS
- A Simple Thread Pool in C++
- A Glance at mmap
- How FastImageCache Works
- The Simple LRU Cache (LRUCache) in MMKV
- Methods for Getting the Thread Identifier
- The Simplest Launch Task Classification
Tools
With good tools, analysis becomes a pleasure.
- AppleTrace Performance Analysis Tool
- AppleTrace Combined with MonkeyDev to Trace Any App
- VSCode Extension Filter Line
- Trying Out the os_signpost API
- Instruments (TimeProfiler): I always wanted to write an article but never did. There’s plenty online, so I won’t bother.
- dtrace: I always wanted to write an article but never did. You can refer to this book Advanced Apple Debugging & Reverse Engineering
Warm Launch
90% of the content of this article was written by me two years ago on Alibaba’s intranet. After I left Ant, colleagues on the mPaaS project organized and published it (though without my byline 😓). The most valuable part is the Background Fetch section. But that section is just the tip of the iceberg, or rather just the first step of a long march. If you want to learn more, you’re welcome to join Meituan.
Resource Collection
Cheatsheet
Areas to Explore
- Profile-Guided Optimization (PGO)
- Improving Locality of Reference
I’ll just mention these two by name; if you want to actually pursue them, they’re quite interesting — search for them yourself.
Summary
Over the past month or so I’ve had a lot of miscellaneous things going on and haven’t written articles, so this article serves as a table of contents to pad the count. It also gives those scattered past articles a classification.
As for ideas on iOS app launch optimization, this article covers most of them at least. Of course, many of the articles above are fairly simple, and some optimization directions are just barely scratched the surface — going deeper is left as an exercise for the reader. Business governance and technical breakthroughs need to go hand in hand, and you also need to build various automated analysis and monitoring platforms in parallel — slow and steady, sustainable development, green planet (okay, I’m getting off track)…
In the future I probably won’t focus “so intensely on app launch optimization” the way I used to. Although “launch optimization” covers a lot of content, it’s still too narrow. There are many, many more directions to explore. Let’s get going… to put it more formally… let’s set sail~
文章目录
过去两年多的时间里,我写了一些iOS应用启动性能优化的文章,这篇文章整理个简单的目录。
SpringBoard 阶段
这个阶段是iOS系统的SpringBoard启动App的阶段,App本身进程还未启动。
pre-main 阶段
App自身进程中,main函数之前的阶段。
- 一种 hook objective c +load 的方法
- 一种 hook C++ static initializers 的方法
- 一种延迟 premain code 的方法
- iOS应用启动性能优化(1)-premain
- Hook所有+load方法(包括Category)
main 阶段
main函数到didFinishLaunching,再到首页显示完成的阶段。
工具
工具好了,分析起来就愉快了。
- AppleTrace 性能分析工具
- AppleTrace 搭配 MonkeyDev Trace任意App
- VSCode Extension Filter Line
- os_signpost API 尝鲜
- Instruments (TimeProfiler) 一直想写篇文章,但没写。网上很多,就不写了。
- dtrace 一直想写篇文章,但没写。可以参考这本书 Advanced Apple Debugging & Reverse Engineering
热启动
这篇文章90%的内容是两年前我于阿里内网写的,在我离开蚂蚁后,mPaaS项目的同事整理发出(虽然没有我的署名😓)。其中最有价值的就是Background Fetch这一段。但这一段只是冰山一角,或者说是万里长征的第一步。若想了解更多,欢迎加入美团。
资料收集
手册
可探索
- Profile-Guided Optimization (PGO)
- Improving Locality of Reference
这两点仅仅提下名字吧,如果要执行,还是很有意思的,可自行搜索。
总结
最近一个多月杂事较多,未写文章,这篇文章做个目录,凑个数。也是给过去零散的文章分个类。
iOS应用的启动优化思路,本文至少涵盖了大多数了。当然上面的很多文章都比较简单,部分优化方向仅仅开了个头,深入研究就交给读者啦。业务治理与技术突破需要双管齐下,也要同步搭建起各类自动化分析和监控平台,细水长流,可持续发展,绿色地球(扯远了哈)……
未来我应该不会像以前那样“如此关注App的启动优化”,“启动优化”虽然包含很多内容,但还是太窄了。可以探索的方向还有很多很多,搞起来……正式点……启航吧~