In the process of learning new knowledge, I have always recommended a combination of practical tasks to learn, only through the actual combat, can deepen the understanding of theoretical knowledge. "Android Kernel Development" series has written eight, this article combined with the previous content, to give you a practical task: optimize the android system start speed.
Here I briefly introduce the basic idea of optimization and the documents involved, the specific details by the people in their own practice to explore, improve their ability to Google and solve problems.
The startup optimizations for Android are divided into three main parts:
(1) bootloader optimization
(2) Tailoring and optimization of Linux kernel
(3) Tailoring and optimization of Android OS parts
This article focuses on the start-up optimization of the Android OS section, and the noteworthy optimization points are described below:
1. Streamlining preload's classes and resource
As described earlier, since all Android applications are forked from the zygote process, in order to share some class and resourse resources, the zygote process initializes some of the common Java Class and resource files into the process's memory so that other applications fork out and do not have to be loaded again, thus increasing the startup speed of the application.
This process can be streamlined and optimized, you can reduce the loading of some classes and resource, thus speeding up the system boot speed. Documents involved in this process:
Frameworks/base/preload-classes
Frameworks/base/core/res/res/values/arrays.xml
2. Streamline native service and Java service
As described earlier, the launch of the Android OS is essentially a series of local services and Java services, all of which are indirectly provided by the Android system.
Many of these services do not have to be started, depending on the business requirements can be removed some of the documents involved in this process:
System/core/rootdir/init.rc
Frameworks/base/services/java/com/android/server/systemserver.java
3. Thin pre-installed APK file
During the system boot process, all apk files under the system's specified directory are scanned, and the process is time consuming, with fewer pre-installed APK files and faster system startup, so streamlining the pre-installed apk is one of the most important tools for optimizing system startup speed.
To reduce the pre-installed APK file, you need to analyze the system's build file, remove the unwanted APK compilation options, and the files involved in this procedure:
Build/target/product/xxxx.mk
Device/<company>/<product>/xxxx.mk
Vendor/..../xxxx.mk
4. Reduce the log print level of the kernel
Excessive log printing messages can significantly increase the system startup time, the log print level has many adjustments, it is recommended to modify the loglevel in the init.rc file to change the log print level.
System/core/rootdir/init.rc
5. Other means of optimization
Described above are the most commonly used optimization methods, in fact, there are many other ways, briefly listed as follows:
(1) Optimize start animation, reduce frame rate and picture size
(2) compact system, reduce boot.img file size, can significantly reduce the time of loading and decompression boot.img during startup
(3) Pre-create some directories and files instead of creating them during the init process
(4) Other ...
6. Summary
Here I give a foreign master optimization results as a comparison and reference (my optimization results only increased the start speed of 20%, far from achieving his effect):
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/D6/wKiom1WJRXqRrLCVAAFlKtcg5Fg090.jpg "title=" boot_ Time_op.png "alt=" Wkiom1wjrxqrrlcvaaflktcg5fg090.jpg "/>
I hope you can leave a message in this blog, Weibo private message or email me, tell me your optimization before and after the Android system startup speed.
About the startup speed optimization of Android system is introduced here, sincerely hope that beginners can practice, in practice gradually master the basic process and skills of kernel development, and then slowly in-depth understanding of the basic principles of the system and theoretical knowledge. Have any questions or suggestions welcome message or letter [email protected] exchange, or follow my Sina Weibo @ Lu _ June get the latest articles and information.
This article is from the "Shadow Three People" blog, please be sure to keep this source http://ticktick.blog.51cto.com/823160/1664754
Android Kernel Development: System startup Speed optimization