Introduction
The author, along with a few like-minded friends, are technology enthusiasts who have long wanted to undertake a project: can we combine our experiences to summarize some common issues, methodologies, and our thoughts encountered in work and study, and discuss and exchange ideas with peers through a series of articles? The reason for this is twofold: on one hand, as the saying goes, “three people walking together, one can be my teacher,” we can learn from each other and delve deeper into some technical points; on the other hand, we can supervise each other, as one person can go fast, but a group can go further. This idea has been brewing for a long time, and we can finally start it now.
Our knowledge system mainly focuses on the BSP field, primarily based on ARM architecture. Some of our friends have been deeply involved in the SoC low-level software field for many years, while others have a deep understanding of the Android framework, which roughly covers the entire link from upper-level software -> Android framework -> Linux kernel -> chip. Can we attempt to organize a comprehensive overview of this entire link? The hardware foundation is primarily based on ARM CPUs, supplemented by NPUs, and will also involve some SoC knowledge; on the software side, we will rely on Android/Linux, focusing on performance analysis and optimization. If conditions allow, we will also try to discuss how to establish a mapping from applications to chips, and how to break down the performance requirements of upper-level applications into CPU and other SoC specifications. In recent years, several of us have gradually entered the field of architecture design, which aligns well with our current work. At the same time, most of our friends have a strong interest in AI, and after a period of learning efforts, we have also stepped into the door of AI, having analyzed some of the underlying facilities due to work needs. In this era of rapid AI development, can we attempt to use AI foundational technologies to intelligently transform traditional BSP components, applying what we have learned?
Therefore, overall, we will explore the themes of BSP and AI, and how the two can be combined. Since we, including all our peers, have some understanding of CPUs, we will start our series with the topic of CPUs.
Once upon a time, we were all beneficiaries of the internet and open source. We hope that through this attempt, we can enhance our technical understanding and expression. If we can also inspire our peers, that would be a way to give back to the internet and open source, which is our original intention. Therefore, we will not take the paid route, but will adhere to the spirit of open source and build a communication platform. Currently, we will publish on WeChat public accounts, Zhihu, and Juejin.
In terms of narrative style, we hope to draw inspiration from “The Ming Dynasty and Its Affairs,” unfolding around various themes. We aim to explain a technology in a relatively interesting way, exploring the origins of the technology, the background it was proposed in, the problems it aims to solve, and its fundamental ideas and principles, as well as how we can establish an intuitive understanding. The same idea can lead to completely different outcomes in different engineering practices; the devil is in the details, hidden in the code. Therefore, when it comes to source code, we will also analyze it and extract the most critical parts.
Now, let us officially begin with the introduction – CPU Performance Matters.
CPU Performance Matters Series
CPU performance analysis and optimization is a grand topic, covering a wide range of areas. Different fields face different issues; for example, mobile devices are more sensitive to power consumption compared to servers/desktop systems, making optimization more complex. Different operating systems, such as Android and iOS (and now HarmonyOS as the third major mobile operating system), provide different tools and frameworks, and the specific solutions to such problems vary across different OSs, although there are also some commonalities. We will focus on Android + mobile device AP SoCs. Besides Android, if we have the energy, we will also look at the implementation of related technologies on iOS, while HarmonyOS will be temporarily set aside. Specifically:
- On the SoC hardware side, we will primarily analyze ARM public version CPUs, aiming to clarify: what are the characteristics of modern superscalar processors, what key components do they have, and how can we cleverly construct software programs to probe these components? Additionally, how do SoC manufacturers choose benchmarks to measure CPU and SoC performance, and how can we perform performance tuning through a combination of software and hardware?
- On the software side, we hope to approach it from a more general perspective, starting from the
<span>top-down</span>methodology, examining how it abstracts CPU microarchitecture details, allowing us, as low-level/embedded software engineers, to quickly identify performance bottlenecks for further tuning. For the CPU, we will attempt to analyze the principles and common optimization ideas of the<span>scheduler</span>, including some related improvements introduced in the Android/Linux kernel. Additionally, from the perspective of applications and the OS, besides the CPU, we will also consider how memory and I/O affect system performance. Memory management and I/O analysis will be discussed later.
Before this, I have actually done some preliminary explorations on CPU hardware. If anyone is interested, you can follow us to review:
- Introduction to ARM Processors 1 – Overview. This article briefly outlines the development history of ARM processors, the evolution of architectures, including the application directions of different processors, and focuses on the Cortex-A series processors and their inheritance relationships.
- Introduction to ARM Processors 2 – Introduction to Basic Features of Modern Processors and Analysis of A9 Microarchitecture. This article introduces some basic technologies and concepts of modern superscalar out-of-order processors, using the Cortex-A9 processor as an example to analyze which technologies are used to enhance performance.
The road ahead is long and arduous; I will seek knowledge both up and down. I hope we can maintain the original intention of being technology practitioners, do difficult but correct things, and persist in this endeavor. Let us encourage each other!
To be continued, the subsequent series of analyses will be coming soon, stay tuned~