当前位置:网站首页>Optimization of application startup speed
Optimization of application startup speed
2022-07-07 03:10:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack
Mac OS/Android Hereunder Static Initializer
Mozillaproject Through optimization Static Initializer( initiate static , Or global constructor , Global Constructor) and Binary Layout to improve FireFox Start speed article . It is of great reference value .
In the article x86 And x86-64 Platform based , Added below Mac OS And Android Upper binary Layout .
What is? Static Initializer? In short, the overall situation C++ Object initialization .
Someone laughed and said C++ programmatic main() Before the function runs , Maybe everything is done . This is it. Static Initializer Influence . Suppose there is another layer of dependent references , It will greatly affect the startup time . The following is a demo sample program :
MyClass oneClass(0x010203); const MyClass twoClass(0x010204); attribute ((constructor)) void foo(void) { printf(“foo is running and printf is available at this point\n”); } int main(int argc, const char * argv[]) { //do something here… }
The first two objects oneClass and twoClass That is, two objects that use static initialization , and foo Function is forced into the initialization section of the program through compilation options (init segement) in , It will run when the program is initialized . The following is finally in Mac OS Layout on :
stay Android ARM ELF The following layout is shown in :
FireFox The optimization of the stay Mozillaproject Teacher's article [ link ] in , be based on Firefox 4.0b8 stay x86 And x86-64 The test data found, for example, the following average startup time :
Average startup time (ms)
Pages Read
Bytes Read
x86
3,228.76 ± 0.57%
4,787
19,607,552
x86-64
3,382.0 ± 0.51%
5,874
24,059,904
Use systemtap[ link ] You can get an access to the core library libxul.so Of access pattern:
The red dot indicates the number of pages loaded from the disk
The red line is the location in the document (seek) operation
The color patches in the background represent .rel.dyn/.rela.syn( Red )..text( Pink ),.rodata( green ),.data.rel.ro( Light green ).
Static Initializers
At the beginning, those vertical lines are Static Initializers Running time , It takes up a lot of time . The solution is to reduce static initializers. Pay special attention to those global variables 、 Static variables .
Analyzed in this way , We all have 237 individual static initializers, among 147 By cycle collection globals Introduced . After revision cycle collection The global object of is reduced to a , The whole situation has not changed much :
Average startup time (ms)
Pages Read
Bytes Read
x86
3,216.1 ± 0.59%
4,656
19,070,976
x86-64
3,488.14 ± 0.75%
5,759
23,588,864
Here are the new I/O access pattern:
I/O Although it has decreased , In fact, there are many other reading operations in static initialization It happened before , So there are other jobs to do .
Reordering objects
Another job is to lay out again binary, So that the data required by the kernel can be obtained as soon as possible . Before Taras A study found that just do something toolchain Changes on can be achieved .
Use Taras Of icegrind After optimization . The improvement became obvious :
Average startup time (ms)
Pages Read
Bytes Read
x86
2,939.18 ± 0.81%
4,129
16,912,384
x86-64
3,247.64 ± 0.68%
5,254
21,520,384
I/O pattern: Packing Relocations Last , Then we can reduce relocation paragraph . To optimize startup time . This can effectively reduce I/O, as well as dynamic relocations section, It can also reduce the package . The tools I use are here . Refer to : About adjusting ELF Optimize the startup time. The following is the final effect :
Average startup time (ms)
Pages Read
Bytes Read
x86
3,149.32 ± 0.62%
4,443
18,198,528
x86-64
3,191.58 ± 0.62%
4,733
19,386,368
I/O Pattern For example, the following : This is an obscure topic , Non Party organizations deserve in-depth study . Start with the links provided by the author . My level is limited . throw away a brick in order to get a gem , Looking forward to more in-depth elaboration . Reprint please indicate the source : http://blog.csdn.net/horkychen Refer to 1. How to Make Startup Suck Less (Also Reduce Memory Usage!) 2. Death by static initialization 3. icegrind - Valgrind Plugin for optimizing Cold Startup 4. Resolving ELF Relocation Name / Symbols 5. Static initializers 6. ELF for ARM Architecture
Copyright notice : This article is the original article of the blogger , Blog , Do not reprint without permission .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116786.html Link to the original text :https://javaforall.cn
边栏推荐
- Oracle中日期的使用方法实例
- Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (initial assignment part)
- uniapp的表单验证
- Convert widerperson dataset to Yolo format
- 首届“量子计算+金融科技应用”研讨会在京成功举办
- 左程云 递归+动态规划
- The version control of 2021 version is missing. Handling method
- sshd[12282]: fatal: matching cipher is not supported: [email protected] [preauth]
- 【Swift】学习笔记(一)——熟知 基础数据类型,编码风格,元组,主张
- Uniapp adaptation problem
猜你喜欢
腾讯云原生数据库TDSQL-C入选信通院《云原生产品目录》
Starting from 1.5, build a micro Service Framework -- log tracking traceid
[socket] ① overview of socket technology
Django数据库(SQlite)基本入门使用教程
从零安装Redis
Redis入门完整教程:RDB持久化
Change your posture to do operation and maintenance! GOPs 2022 Shenzhen station highlights first!
Utilisation de la promesse dans es6
Dotconnect for DB2 Data Provider
MySQL is an optimization artifact to improve the efficiency of massive data query
随机推荐
Development of wireless communication technology, cv5200 long-distance WiFi module, UAV WiFi image transmission application
杰理之开 BLE 退出蓝牙模式卡机问题【篇】
Use of tensorboard
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (initial assignment part)
Utilisation de la promesse dans es6
leetcode-02(链表题)
How to find file accessed / created just feed minutes ago
Simple bubble sort
又一百万量子比特!以色列光量子初创公司完成1500万美元融资
Oauth2协议中如何对accessToken进行校验
Redis入門完整教程:問題定比特與優化
Kubernetes source code analysis (II) -- resource
SQL中删除数据
The first symposium on "quantum computing + application of financial technology" was successfully held in Beijing
How to analyze fans' interests?
Redis introduction complete tutorial: client case analysis
The annual salary of general test is 15W, and the annual salary of test and development is 30w+. What is the difference between the two?
「小样本深度学习图像识别」最新2022综述
Centerx: open centernet in the way of socialism with Chinese characteristics
IDEA重启后无法创建Servlet文件的解决方案