background

With the rapid growth of the business, THE APP is becoming bloated, and the lag of many Dachang apps has been criticized by users. In addition, with the development of the Internet, the occupancy of the sinking crowd is also gradually expanding, so it is particularly important to ensure the app experience, help the business speed up, and improve the conversion rate of each business scenario.

preface

For development students, startup optimization is often measured by subjective feelings. You may often hear “it seems to be getting faster, it seems to be getting slower”. Therefore, it is necessary to establish reasonable data indicators to measure the effect of each optimization point in the optimization process from the perspective of data. In addition, as a technology, we should not only pay attention to technical indicators, but also to business indicators when making technical requirements. What value can we bring to the business by doing this?

The overall design

The overall design mainly includes, which will be divided into several articles to explain the overall content in detail.

  • The startup framework solves the problems of startup dependence and efficiency. Establish launch task development specifications.
  • Data index setting and monitoring.
  • AB experiment to verify the optimization effect; Ensure the stability and safety of online
  • The collection of buried sites and logs at each stage ensures the deterioration of attribution analysis.

The index set

Technical indicators

Technical metrics are usually broken down into the time it takes to start rendering the home page.The whole process can be divided into technical aspectsProcess startedApp creation, home page creation, data request,Data rendering

Process Creation Time

  • Process creation time describes the system time of process creation. This time can objectively reflect the operation time from the user clicking the icon of the target program to the user entering the target page.
  • The earlier start time is often from the Application. The attachBaseContext obtaining target process is the first line of code execution time, the time is a “good start time” program, but it is not perfect, we hope to get an objective real user body sense data. The /proc/slef/stat file records some status data of the process.
  • Therefore, we can obtain the /proc/slef/stat information through the asynchronous thread during startup, which can truly and objectively reflect the user’s real sense of entity, and can also include the preparation time of resources required by Zogyte to create and initialize the child process. Android 8 + equipment system provides Process. After getStartUptimeMillis (), The time Process. GetStartUptimeMillis () is on the first news BIND_APPLICATION ActivityThread Process. SetStartTimes () set in, students can be interested in watching this part of the code, Understand the differences in the details of ActivityThread after writing 8.+. Through the above analysis, the realization of APM in 8. – device through the/proc/slef/stat gain Process creation time, 8 + through the Process. The getStartUptimeMillis () to obtain the Process time, through this point in time, and the user interactive point to the target page, The interval between the two generates the user’s cold boot time.
  • In /proc/slef/stat, we found a lot of dirty data, so we started to think about the new implementation. The process will create a memory file when the process is created. The last time a file was modified in Java is file.lastmodified (), which is a good indicator, as long as a file associated with the target process is found and it has not been modified since creation. /proc/slef/stat cannot meet the requirements, because stat involves a lot of process-related information, such as io_WAIT and process status, which changes with the process status. I’m glad /proc/slef/comm is in the name of the process that was created. That is, the process name is created after the process is created and will not be changed. The new algorithm sets the startup time to the last modification time of the /proc/slef/comm file.

Data rendering

Due to the Android rendering mechanism, how to define the home page rendering completion.

  • At the beginning, we referred to Meituan’s article and defined the first drawChild completion of the root layout after the data is loaded as the rendering is completed. However, there is a problem with this scheme. After the data is loaded, the image needs to be loaded asynchronously.
  • Subsequently, we study, by starting the thread traversing the root layout, judge the control real rendering, by calculating the control of a single area to synthesize the total rendering area, more than 80% of the screen area is considered to be completed.
    • TextView, View, ViewGroup, etc. consider rendering complete
    • ImageView determines that it is BitmapDrawable and considers the render complete

Business indicators

Business indicators miss rate, home page exposure, retention, etc.

AB experiment

With data indicators, we need to measure our optimization results through AB experiments. In addition, since the optimization logic may change a lot, we need to gradually increase the volume to ensure safety and stability, and timely stop bleeding when problems occur. For small companies without a complete data platform can simply take the configuration center as AB experiment, in all data buried points with the configuration center bucket information. In addition, for the AB experiment, it is necessary to ensure that the control bucket and the optimized bucket have the same condition factor and the same volume ratio.

Offline test

Through automation, video recording is started, and then the video is divided into frames. Click frames and render completed frames are screened out by algorithms.

At the end

After the App optimization series is completed, the startup time is reduced from the initial 4.5s to 1.3s. Next, I will share a series of articles on APP startup optimization, including indicators, architecture design, combat, etc., and summarize and precipitate what I have done during this period of time.