当前位置:网站首页>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 ArchitectureCopyright 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
边栏推荐
- Kubernetes source code analysis (II) -- resource
- mos管實現主副電源自動切換電路,並且“零”壓降,靜態電流20uA
- leetcode
- Utilisation de la promesse dans es6
- The solution of unable to create servlet file after idea restart
- leetcode-02(链表题)
- sshd[12282]: fatal: matching cipher is not supported: [email protected] [preauth]
- Analysis of USB network card sending and receiving data
- HDU 4337 King Arthur's Knights 它输出一个哈密顿电路
- “零售为王”下的家电产业:什么是行业共识?
猜你喜欢

Form validation of uniapp

Left path cloud recursion + dynamic planning

上个厕所的功夫,就把定时任务的三种调度策略说得明明白白

密码学系列之:在线证书状态协议OCSP详解

Redis入门完整教程:问题定位与优化

The solution of unable to create servlet file after idea restart

input_delay

Another million qubits! Israel optical quantum start-up company completed $15million financing

The whole process of knowledge map construction

Redis introduction complete tutorial: client case analysis
随机推荐
How to write test cases for test coupons?
“零售为王”下的家电产业:什么是行业共识?
Code debugging core step memory
How-PIL-to-Tensor
Laravel php artisan 自动生成Model+Migrate+Controller 命令大全
input_delay
Left value, right value
Use of tensorboard
SQL Tuning Advisor一个错误ORA-00600: internal error code, arguments: [kesqsMakeBindValue:obj]
Redis getting started complete tutorial: replication configuration
Cloud Mail . NET Edition
C language exercises_ one
The version control of 2021 version is missing. Handling method
uniapp的表单验证
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (filtering part)
mos管实现主副电源自动切换电路,并且“零”压降,静态电流20uA
How to analyze fans' interests?
杰理之在非蓝牙模式下,手机连接蓝牙不要跳回蓝牙模式处理方法【篇】
惯导标定国内外研究现状小结(删减版)
Cglib agent in agent mode