ByDaniel Camilo 2019-06-05 2318
After the launch, Huawei's Ark compiler caused a heated debate in the outside world.
So, what exactly is the Ark compiler? In the face of these problems, Huawei finally held a media salon two weeks later, a more detailed interpretation of the Ark compiler.
Before we get to know the Ark compiler, we have to first understand how the compiler works in the Android operating system.
From VirtualXposed\/, it is understood that most applications of the current Android platform are written in the Java language, the CPU can only understand the assembly instructions, can not directly identify the Java language of the virtual machine instructions, in order to allow the CPU to run programs written in the Java language, there are generally two ways:
At the Huawei new product launch conference in Shanghai, in addition to the Huawei P30 series that can shoot the moon, yu also threw out two "bombshells" at the level of software, namely ark compiler and EROFS super file system. Introduce a middle layer, which is responsible for executing Java code, and then compile the middle layer itself into assembly instructions that the CPU can understand, namely the cpu-> middle layer -> Java code. If this middle layer takes the Java language as input directly, understanding a Java statement translates the Java language to let the CPU execute a section, we generally call this pattern "interpreted execution. "There is no doubt that this approach is quite inefficient. Translate the Java language directly into a machine language that CPU can understand. There are two ways to do this: first, compile Java code directly into the machine language before the program runs. This pattern is called AOT(Ahead of time) compilation; Second, once the program is up and running, the Java language is compiled into machine language in real time and executed. This pattern is called JIT(Just in time) compilation. Specifically, on the Android platform, code compilation goes through several stages. Among them, Huawei ark compiler can achieve "architecture-level optimization and significantly improve performance", and can solve the problem of android program "executing while explaining", which is called "android performance revolution" by yu chengdong.
, Android USES the interpreted execution + JIT method to execute Java code.At this stage it was the real "explain and execute" mode, the code was quite inefficient, and with GC(garbage collection), which was also bad, Android was very difficult to use.
, Google launched ART (Android Runtime) to address previous Java code execution efficiency issues. The complete AOT model is used at this stage; When the Android app is installed, all Java code is compiled into machine code in advance. This pattern has two drawbacks:
Installation speed is very slow. Even Qualcomm Dragons 855 it may take a minute to compile a larger application (such as Alipay) in the AOT mode.
And at that time the CPU was not as good as it is now, and it takes a long time to install an app. What's more, the system OTA opens up the opportunity to perform AOT operations on all applications, which can take a long time to boot.
When disk space is consumed, the volume expands dramatically after the Java code is compiled into a machine code. Great improvements have been made to Android 7.0, Google; This improvement is based on the fact that when we use an app, basically everyone uses only a fraction of its functionality, so why compile all the code? So only compile the part of the code that the user often uses OK, In this way, the installation is faster, and when the user starts, the system can know which part of the code is often executed, this part of the code compiled into machine code, the speed of operation is also fast.
So Google introduced JIT, when the execution mode is AOT JIT interpretation execution. In specific terms:
Apps are installed quickly without AOT compilation. The first time an application is used there is no machine code, so only execution can be interpreted. Once an application is running, the system collects information about code that is often run and does two things: 1) compile Java code directly into machine code (JIT) at run time when necessary, and then use machine code execution to improve performance.2) save this "frequently run code information". When the device is idle, the system compiles the "hot code information" saved by the application runtime directly into machine code (AOT).Android 8.0 has improved the interpreter, greatly improving the execution efficiency of the interpretation mode; Android 10.0 provides a way to pre-install hot code so that applications can know that common code will be pre-compiled at the time of installation. As you can see, the current execution mode of the Android platform has reached a good balance between space usage + installation speed + running speed.
In summary, the current Android uses a comprehensive model that explains the JIT AOT that can be executed, but it does not get rid of the premise that the app uses Java code when it is packaged as an APK. In other words, as the APK becomes a user-configurable process, it goes through a compilation process within the Android system, which is a hurdle.
According to Huawei's interpretation in the media salon, this hurdle in the existing Android, known as the virtual Machine, referred to as the VM, it contains translators and compilers, the purpose of which is to convert the Java advanced language into a machine can understand the language- This conversion process results in carton, and the unified collection of memory garbage from the VM will also bring carton.
First, the Ark compiler is a compilation tool built with Huawei's EMUI 9.1 operating system.
According to Huawei, although the Ark compiler was released on April 11, 2019, Huawei began to lay out 5 years ago, and in 2013 launched the self-research compiler HCC,2014-year programming great God Fred Chow joined as chief scientist of Huawei Compiler technology, and in 2016 Huawei became The compiler and programming language Lab, which invested hundreds of of the team of experts, went through a number of attempts to translate the machine code on EMUI 9.1.
According to the code running logic of the Android operating system described above, the biggest advantage of the Huawei compiler is that it bypasses the VM.
Simply put, with a team of hundred experts, the Huawei Ark compiler can turn advanced language (Java) directly into machine code without having to go through the VM compiler built into the Android operating system. According to Huawei, the application compiled by the Ark compiler was completed during the development phase, that is, as long as it is a compiler compiled application, after the application market on the shelves, the user downloads the APK is compiled.
In other words, through the Ark compiler, the developer's app has been converted into machine-recognizable code before downloading, so it can be quickly installed, started, and run on the phone without having to compile through the VM--to some extent, the Ark compiler is bringing the compilation process forward to the application development phase, This significantly reduces the operational burden on smartphones and operating systems.
According to Huawei, after adopting the Huawei compiler, the lifting effect is as follows:
EMUI 9.1 After the Ark compiler was applied to system components only, the system's smooth speed increased by 24% and the system's response speed increased by 44%, while the operational fluency of third-party applications (currently using Sina Weibo Speed edition) increased by 60%. What can not be ignored is that, in fact, in order to achieve the results that Huawei says, it is first necessary for third-party app developers to use the Ark compiler to retrofit their apps ahead of schedule to be able to launch the Huawei App Store, which is why by bringing called on developers to participate actively on April 11.
In addition to code compilation, the Ark compiler also provides a more efficient memory mechanism, which differs from Android memory recycling in that:
Memory management is a key part of program development and operation, and is closely related to system fluency. Android uses a centralized recycling mechanism for memory collection, and it is more important to pause the app when the sound is recycled globally, which is one of the root cause of random carton. The Ark compiler provides a more efficient memory recovery mechanism that eliminates the need to pause applications and recycle them at any time, greatly increasing speed of operation.
In addition, in the compilation Environment of the Ark compiler, the code can also be optimized. Currently, because Android ART's AoT and JIT Dynamic compilation is limited by resources because it is running on the phone, only simple optimization algorithms can be used. The Ark compiler, because it is compiled during the application development phase, allows different applications to be flexible with different compilation optimizations, and because compilation in the development environment is not limited by the performance of the phone, more advanced optimization algorithms can be used to optimize the performance of each application.
|You may also want to read:|
|MIUI 11: List of Xiaomi devices getting MIUI 11 upgrade leaks|
|new Dell XPS 15 (7590): price, specs, features and launch date|
|Redmi K20 Pro AnTuTu Benchmark Score beyond Xiaomi Mi 9|
● Over 300,000 products
● 20 different categories
● 15 local warehosues
● Multiple top brands
● Global payment options: Visa, MasterCard, American Express
● PayPal, Western Union and bank transfer are accepted
● Boleto Bancario via Ebanx (for Brazil)
● Unregistered air mail
● Registered air mail
● Priority line
● Expedited shipping
● 45 day money back guarantee
● 365 day free repair warranty
● 7 day Dead on Arrival guarantee (DOA)