当前位置:网站首页>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
边栏推荐
- Redis入门完整教程:复制拓扑
- 【Socket】①Socket技术概述
- Another million qubits! Israel optical quantum start-up company completed $15million financing
- The whole process of knowledge map construction
- Redis入门完整教程:RDB持久化
- Redis入门完整教程:客户端案例分析
- QT Bluetooth: qbluetooth DeviceInfo
- 硬件之OC、OD、推挽解释
- OC, OD, push-pull explanation of hardware
- LeetCode 77:组合
猜你喜欢

巴比特 | 元宇宙每日必读:IP授权是NFT的破圈之路吗?它的难点在哪里?Holder该如何选择合作平台?...

How to verify accesstoken in oauth2 protocol

Left value, right value

【基于 RT-Thread Studio的CPK-RA6M4 开发板环境搭建】

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

Redis入门完整教程:客户端管理

硬件之OC、OD、推挽解释

Es6中Promise的使用

Appx代码签名指南

Another million qubits! Israel optical quantum start-up company completed $15million financing
随机推荐
Redis introduction complete tutorial: replication principle
Hazel engine learning (V)
Data analysis from the perspective of control theory
c语言字符串排序
2022年信息安全工程师考试大纲
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (initial assignment part)
uniapp适配问题
Redis getting started complete tutorial: replication topology
2022 spring recruitment begins, and a collection of 10000 word interview questions will help you
Don't you know the relationship between JSP and servlet?
Metaforce force meta universe fossage 2.0 smart contract system development (source code deployment)
Error: could not find a version that satisfies the requirement xxxxx (from versions: none) solutions
【2022国赛模拟】多边形——计算几何、二分答案、倍增
Read fast RCNN in one article
从零安装Redis
上个厕所的功夫,就把定时任务的三种调度策略说得明明白白
PSINS中19维组合导航模块sinsgps详解(滤波部分)
杰理之在非蓝牙模式下,手机连接蓝牙不要跳回蓝牙模式处理方法【篇】
A complete tutorial for getting started with redis: AOF persistence
Left value, right value