Since the first article on January 10, it has been 4 months and 20 days since then, and I have successively written a total of 12 performance optimization articles, about 3 articles a month. This article is the last in a series of performance articles. Without a new general direction of optimization, I’ll cover a few things about writing performance optimization articles: the beginning, the process, and the payoff.
1, the beginner’s mind
1.1 Why comprehensive and in-depth performance optimization?
The story started late last year: when I opened the App before the release of a certain version, the only experience I had was that it started up at tortoise speed. I was not only crushed by competing products, but also crushed my technical honor and shame: the poor performance of the App I made is my poor performance! This is how I decided to optimize the performance of the project.
1.2 Why write a series of articles?
Since I want to practice performance optimization, and I also have the habit of knowledge sorting, so writing a series of articles is natural, incidentally is a supervision of their own. But there’s another reason:
- Looking through various materials, I found that official documents serve as the best reference materials in the process of performance optimization, while the translation level of domestic developers is not too flattering and many developers focus on different angles, resulting in few excellent and comprehensive reference articles.
So since I’m going to do performance optimization, I’m going to challenge this to be excellent and comprehensive. Also leave good reference articles for later people!
2, process,
2.1 Performance optimization is not a warm treat
The process of performance optimization is a very difficult one that requires not only sufficient knowledge of the direction of optimization but also an understanding of the existing business. Take the first App startup optimization for example:
- See the official documentation for an overview of startup optimization;
- Sort out the logic of App startup;
- Use tools to accurately measure startup logic code;
- Determine the optimization scheme for the bottleneck;
- Optimize, test.
The difficulty lies in the middle three steps:
- No one can say how much logic or compensation logic is involved in the startup of the App.
- Different styles of code to read, that feeling is definitely a sour cool;
- Identified problem points, how to optimize? Refactor or redo?
And the process of sorting out the article is even more difficult, published the article is a commitment to their own, both professional, but also to be easy to understand; Both to have depth, optimization of the move and as far as possible comprehensive. Therefore, it is common to check documents and turn over the source code. I’m also busy with work, so I even feel a little productive at the pace of three articles a month.
2.2. You only know a little about optimization
When it comes to performance optimization, I believe you Android drivers and new drivers, can say a few words. Performance optimization is also a must-ask posture during the interview process. But everyone can say a few words does not mean that there is much understanding of performance optimization, do not believe the following questions:
- How does Android’s memory management differ between Dalvik and ART? When retrieving memory information through ADB, which value is the true memory footprint that can be reclaimed?
- How to calculate the memory occupied by resource images?
- Does thread priority depend on the process?
I don’t understand the principle, but I can also say several optimization rules. Can you say THAT I don’t understand performance optimization? Of course, there are many lessons and guidelines for performance optimization, but performance optimization should not be a mechanical act of memorization. If you do not understand the principle, the understanding of performance optimization, insufficient understanding, any scene with a unified routine mechanically, the depth of optimization, comprehensiveness, applicability will be greatly reduced.
3, the
So what did I get out of this not-so-easy performance optimization?
3.1 Familiarity with product business
Performance optimization may seem like a pure technical thing, but in fact it is inseparable from the business. After all, any technology is applied in a specific business scenario. Therefore, if you are not familiar with module business and implement it mechanically, performance optimization is often impossible to start.
3.2 In-depth understanding of performance optimization
Performance optimization is not an isolated piece of knowledge. In-depth understanding of performance optimization requires the assistance of various technologies. Here, I still take the first boot optimization as an example.
- Application startup classification and process;
- Startup optimization mode;
- Heavy App Initialization (thread usage, network requests, IO, layout nesting, etc.)
Especially the third point: each of these can lead to performance bottlenecks, and each of them can be elaborated on, strengthening your technical capabilities in the process.
3.3 Ability to organize knowledge and document
For the most part, we don’t create knowledge, we are porters of knowledge, we collect and integrate knowledge. That is the decisive victory for us is to quickly absorb knowledge and complete the judgment and integration of knowledge, know where there will be authoritative, reliable information, judge the use of knowledge and so on.
And all kinds of pain in the process of writing an article is not useless work. Only after experiencing the embarrassment of not knowing how to write an article, can we know how to determine the theme of the article, the main line, and enrich the article, can we exercise our expression ability and text organization ability.
4, other
4.1 Why is performance optimization important?
- Learning and practicing performance optimization is a way for technical staff to grow and improve, but also an opportunity to improve code quality.
- With the increase of App functions, performance problems have followed. It is no exaggeration to say that any App has performance problems, but the degree is different. Allowing performance problems to exist and turning a blind eye to them will eventually lead to an explosion of concentration, which will not only result in technical failure, but also affect the product and users.
- The process of performance optimization itself is also a process of excellence, representing your attention to the code, the pursuit of high quality application.
4.2 What are the recommended materials for performance optimization?
- Android performance optimization paradigm, official launch, must be a boutique. Not only tell you what’s wrong, but tell you why!
- Hu Kai’s blog, translated about the Android performance optimization model content, if you don’t want to watch the video can refer to the blog. However, the official model and translation are theoretical, need to practice.
- Official documentation, from Training modules to API modules, is full of dry stuff.
- “Mobile App Performance Evaluation and Optimization”, Tencent TMQ special test team’s work, deep into the bottom, trace back to the source, keep improving, bring people on the technical improvement at the same time more correct attitude to do technology, strongly recommended!
4.3 How to optimize performance?
Four words: prevent microcosm. A lot of performance issues don’t happen overnight, like the OOM. The code that led to OOM might just be the straw that broke the camel’s back. There’s a lot of code that doesn’t do anything wrong, that does something, but it’s in the wrong place.
It is better to review the technical solution before module development, and avoid the implementation of low performance as soon as possible from the implementation (source); It is best to use tools for performance analysis and optimization after the function is completed.
4.4 other
- After the optimization is completed, it is necessary to fully test, otherwise, although the performance is high, the occurrence of bugs is unacceptable;
- Recommend you to write blog, or collation, summary or;
- Never forget why you started, and your mission can be accomplished.
Welcome to pay attention to wechat public number: regularly share Java, Android dry goods!