How to set up smartphones and PCs. Informational portal
  • home
  • News
  • Which is better dalvik or art. We understand the intricacies of the Art and Dalvik programs

Which is better dalvik or art. We understand the intricacies of the Art and Dalvik programs

With the release of new versions of Android, this OS required more and more random access memory (RAM). The first devices with it had 256 MB of RAM, but today one gigabyte may no longer be enough. However, Google took up optimization and released Android 4.4 KitKat. This version of the operating system is faster, but requires fewer resources. This became possible thanks to the transition from the Dalvik system to ART. Read below about what it is and why smartphones with Android 4.4 will work faster on weak processors.

One of the reasons for the popularity of Google's mobile OS is the relative ease of developing applications for it. Thanks to this, the Google Play software store was quickly filled with utilities. This became possible with the help of the Dalvik virtual machine, which converted application code into something understandable for the processor of a mobile phone or tablet. Programmers write in the way that suits them, and they don’t need to worry about what chipset is in the user’s gadget: from Qualcomm, Intel, Mediatek, nVidia, Samsung or another vendor.

Due to the fact that application code is transformed on the fly into something understandable for the gadget’s hardware, it is very convenient for developers to create their own programs. But because of this intermediary in the form of the Dalvik virtual machine, the device processor has to perform several times more actions: read the code, transform it into something understandable by the hardware, execute it and display the result on the screen. The consequence of this architecture could be observed by almost every owner of an Android device in the form of a sluggish interface. When the smartphone is not loaded with games and calculations, the RAM is free, but simply flipping the screen still causes a second delay.

Google began to fight this problem a long time ago: the first serious step was Project Butter, announced along with Android 4.1 Jelly Bean. Thanks to it, the operating system began to respond somewhat faster to user actions, but overall the problem remained. Therefore, Google has created and is preparing ART - a replacement for the Dalvik virtual machine.

For whatAndroid neededvirtualcar

Any program uses many standard actions: displaying an image on the screen, writing files to memory, transferring files via Bluetooth or Wi-Fi. To make life easier for programmers, the operating system has built-in functions to perform these tasks. The developer only needs to indicate in his application “copy the XXX file to the memory card in the UUU folder.” It doesn't care how it's done or how much system resources it requires.

Programmers also often write “defective” programs that have errors in the code, “lose” memory, and the like. A virtual machine allows you to isolate utilities from each other and from the operating system kernel. Thanks to this, application crashes do not affect the OS and other running programs. Without this, an error in the utility causes the entire system to freeze. Older users may remember how bugs in application software led to the "blue screen of death" in the Windows 95 and 98 desktop operating systems, which did not have similar virtualization mechanisms.

APK files that a user downloads from the Google Play Store or any other server are uncompiled code. No computer can do it because it simply “doesn’t understand.” If the utilities were supplied in a form already compiled and understandable to the hardware, then some of them would work, for example, on devices with a Snapdragon chipset, but would give an error when launched on gadgets with Tegra chips.

Each manufacturer adapts Dalvik to its processor and hardware. Thanks to this, the same program can run on gadgets from almost any manufacturer without editing its source code. And it is for this reason that you cannot simply install a new version of Android on your device, like reinstalling Windows.

What's happenedDalvik and why it requires replacement

The Dalvik virtual machine (named after the Icelandic fishing port of Dalvik) has been present in Android since the launch of this operating system in 2007. Since then, it has undergone only one major change: in Android 2.2 Froyo, the code from the APK was transformed into machine code on the fly immediately after the user launched the utility. Previously, it was processed line by line during program execution on a mobile device. The new approach made it easier to launch utilities and their operation, but this affected the requirements for hardware resources. And today, just one gigabyte of RAM may not be enough for a mobile phone to work quickly.

WhatsuchART andHowshewill helpAndroid

The ART virtual machine (stands for Android RunTime - Android runtime environment) is still in the experimental stage, but you can already try it in Android 4.4 KitKat. Users of devices running this OS version can switch from the default Dalvik to ART.

The main difference between these virtual machines is the compilation approach. If Dalvik converts code in real time immediately after launching the utilities, then ART does this in advance during installation. This means an increase in installation time for utilities and a larger footprint in the device's flash memory. But this also means faster startup and reduced requirements for hardware resources, especially the amount of RAM. That's why Android 4.4 KitKat, according to Google, will be able to run quickly and stably on gadgets with 512 MB of RAM. The new approach to code conversion will also reduce battery consumption.


Compare the volume of the same programs using Dalvik (left) and ART (right)

Dalvik vs.ART - comparison

Overall, the ART virtual machine promises many improvements over the existing Dalvik. The advantages and disadvantages of each can be seen in the table below:

Converts APK files into CPU-readable code on the fly, which requires less flash storage but makes apps take longer to launch

Converts APK files into CPU-readable code before they are installed. This requires less CPU resources at startup and reduces program startup time

Over time, the machine code is cached, which leads to faster loading of the mobile phone

The machine code cache is created when the mobile phone is first booted, which is why it takes much longer to turn on

Better suited for devices with low-capacity flash storage as the machine code cache takes up less space

Consumes significantly more flash memory (10-20%), since in addition to APK files it stores the compiled machine code of each program

Stable and time-tested

New and experimental, unexpected errors and shortcomings may appear

Try experimentalART

The new compiler is under development and research, but users can already try it. It is available to owners of devices running Android 4.4 KitKat and based on the Snapdragon chipset. Those who decide to try the new product should remember that the new virtual machine may make some utilities inoperable. In addition, after a reboot, the smartphone may take up to half an hour to start - this is the time ART will need to create an application cache.

To enable ART instead of Dalvik, you need to enter the developer menu. To activate the latter, you need to open the smartphone settings and go to the “About phone” section. There you need to click on the “Version Number” button many times until the OS reports the availability of the new menu. After this, you need to select the virtual machine to use and reboot the device.

Overall, tests from users who switched to ART show an overall speedup of approximately 50% and an increase in battery life of up to 30%.

So far we have been able to find such information on the website Youhtc.ru
"
Over the past few years, an important part of the work of Android creators has been the fight against the main congenital “disease” of the system - lags in interface animation. The first serious step in this direction was Project Butter, announced along with Android 4.1 Jelly Bean and really “speeded up” the system, but did not completely solve the problem. Google realizes this, so they are preparing ART - a replacement for the Dalvik virtual machine.

Even now, in the age of multi-core powerful processors, under certain circumstances you can notice that animation in Android is not drawn perfectly, and there are visible delays between some actions. The problem is complex, so many steps had to be taken to solve it - one of them was to replace Dalvik with the ART precompiler.

Now Android code runs in a Java engine created by Google specifically for mobile devices, and it is converted “on the fly” into hardware code (Just-In-Time Compilation). This mechanism allows the application developer to be practically untied to a specific architecture or hardware, but causes serious damage to performance by loading the processor during compilation. Of course, after the first very slow launch of the program, part of the resulting “native” code is stored in the cache, but this does not completely solve the problem of lags.

ART is an AOT (Ahead-Of-Time) compiler that converts Java code into “native” code during the application installation process. That is, the user runs the program already compiled, which significantly speeds up its opening and execution. It’s doubly interesting that ART is already built into Android 4.4 KitKat and can be activated in the developer menu. After switching to libart.so (compiler library), the device reboots and compiles all already installed applications. The guys from Android Police, who carefully studied ART, claim that this should not be done on custom firmware from AOSP yet - problems may arise with the software package from Google.

Even taking into account the incomplete state of ART, switching to it significantly affects the speed of execution of resource-intensive tasks and the smoothness of the interface, and also allows multi-core processors to turn off unused cores more often, which gives a gain in battery life of the device. The new compilation system has disadvantages, although they can hardly be called significant: longer installation time and an increase in the final size of the program by 10-20%. True, only the code part grows in size, which often takes up less than half of the application - multimedia (pictures, sound, video) and other data do not change in size.

It turns out that Google has been working on ART for several years now, and its inclusion in KitKat is an absolutely deliberate decision, allowing the system creators to conduct serious testing, and application developers to prepare for the upcoming “departure” of Dalvik. It is not yet clear how much the new compiler was influenced by the developers from FlexyCore, which Google bought in October of this year, but the project began within the search giant itself.

Google has not yet said how soon ART will replace Dalvik, but nothing prevents the corporation from doing this in the next version of the system. Interestingly, like Project Butter, the compiler does not require effort from application developers - they will still write code in a well-known language, using proven practices.
"

I don’t have a device running Android 4.4 to try the new technology myself, but a system image from Google is already available, which you can “touch” in the emulator.

I still have questions about whether this feature will be available on other non-Google Android 4.4 devices: Samsung, HTC, etc. Will all application functions work correctly after transferring to the new platform?

There is very little information, please write in the comments where it can be found in a larger size.

So far we have been able to find such information on the website Youhtc.ru
"
Over the past few years, an important part of the work of Android creators has been the fight against the main congenital “disease” of the system - lags in interface animation. The first serious step in this direction was Project Butter, announced along with Android 4.1 Jelly Bean and really “speeded up” the system, but did not completely solve the problem. Google realizes this, so they are preparing ART - a replacement for the Dalvik virtual machine.

Even now, in the age of multi-core powerful processors, under certain circumstances you can notice that animation in Android is not drawn perfectly, and there are visible delays between some actions. The problem is complex, so many steps had to be taken to solve it - one of them was to replace Dalvik with the ART precompiler.

Now Android code runs in a Java engine created by Google specifically for mobile devices, and it is converted “on the fly” into hardware code (Just-In-Time Compilation). This mechanism allows the application developer to be practically untied to a specific architecture or hardware, but causes serious damage to performance by loading the processor during compilation. Of course, after the first very slow launch of the program, part of the resulting “native” code is stored in the cache, but this does not completely solve the problem of lags.

ART is an AOT (Ahead-Of-Time) compiler that converts Java code into “native” code during the application installation process. That is, the user runs the program already compiled, which significantly speeds up its opening and execution. It’s doubly interesting that ART is already built into Android 4.4 KitKat and can be activated in the developer menu. After switching to libart.so (compiler library), the device reboots and compiles all already installed applications. The guys from Android Police, who carefully studied ART, claim that this should not be done on custom firmware from AOSP yet - problems may arise with the software package from Google.

Even taking into account the incomplete state of ART, switching to it significantly affects the speed of execution of resource-intensive tasks and the smoothness of the interface, and also allows multi-core processors to turn off unused cores more often, which gives a gain in battery life of the device. The new compilation system has disadvantages, although they can hardly be called significant: longer installation time and an increase in the final size of the program by 10-20%. True, only the code part grows in size, which often takes up less than half of the application - multimedia (pictures, sound, video) and other data do not change in size.

It turns out that Google has been working on ART for several years now, and its inclusion in KitKat is an absolutely deliberate decision, allowing the system creators to conduct serious testing, and application developers to prepare for the upcoming “departure” of Dalvik. It is not yet clear how much the new compiler was influenced by the developers from FlexyCore, which Google bought in October of this year, but the project began within the search giant itself.

Google has not yet said how soon ART will replace Dalvik, but nothing prevents the corporation from doing this in the next version of the system. Interestingly, like Project Butter, the compiler does not require effort from application developers - they will still write code in a well-known language, using proven practices.
"

I don’t have a device running Android 4.4 to try the new technology myself, but a system image from Google is already available, which you can “touch” in the emulator.

I still have questions about whether this feature will be available on other non-Google Android 4.4 devices: Samsung, HTC, etc. Will all application functions work correctly after transferring to the new platform?

There is very little information, please write in the comments where it can be found in a larger size.

Dalvik has a competitor in KitKat in the form of ART. So, what is it and what benefits will Android users expect in the near future?

ART (an abbreviation for Android Runtime) is a new application runtime written in C/C++, which differs from Android's existing Dalvik virtual machine in that all applications on the system are already compiled, which means there is no need for a JIT compiler . Thus, ART allows you to run applications on different hardware (wiz. ARM, x86) without preliminary adaptation by developers. In addition, it takes half as much time to launch applications in new conditions. There are some drawbacks, one of which is related to the principle of operation in ART conditions. This environment leads to the fact that all the necessary information is translated into a machine-oriented language during the installation of applications (AOT compilation), and this requires additional time, which is why the entire installation process is very drawn out, and applications take up more space, so how they are compiled all the time. Although ART is present in Android 4.4 KitKat, it still uses the Dalvik virtual machine by default. ART is still under development, but anyone can already activate the new technology: Settings -> Developer options -> Select runtime.

If you decide to test a new environment, then do not forget that the first boot can last up to 20 minutes, or even more: the system will take a lot of time to switch to the new principles of operation. The libdvm.so library will be replaced with libart.so, and the ODEX files with OAT. Please note that switching to ART in the case of custom ROMs is not recommended, as there may be a problem of incompatibility with the current version of Gapps applications, which will lead to errors, system crashes and make it impossible to work on the device. Since in Android 4.4 KitKat we are only dealing with a prototype of a new application runtime, it is too early to draw conclusions based on the current practical results. ART has not yet been optimized at all, but we can already say that in the new conditions, applications will be faster, animations will be smoother, and the response to touching the touchscreen will improve. In addition, ART will be able to reduce the load on the processor: most processes will need to use only a portion of the cores. This will lead to more efficient use of the big.LITTLE ARM architecture, which means that the power consumption of Android devices will be reduced and operating time will be increased. In fact, ART includes two backend compilers. Both the first and the second are AOT (Ahead-of-Time) compilers, and one of them is used to recognize machine code and work with GCC, cl.exe (LLVM compiler).

Oddly enough, the transition to ART should not affect the creation of applications. The specificity of the new environment is such that ART reads bytecode for Dalvik, which means there is no need to acquire new knowledge and skills. The work will be carried out using the same Java bytecode. On the other hand, AOT compilation has one drawback: errors that occur on different hardware. Due to this, developers will have to test their applications on more Android devices. At the same time, precompilation will reduce the possible amount of work, and it will be possible to create applications with ART in any language with an LLVM frontend. Separately, it is worth noting access to machine code: developers will have more opportunities, but in case of an error, the finished product can harm the Android device. The last important point relates to the use of JNI - a standard mechanism for running code under the control of the Java virtual machine, which is associated with ensuring binary compatibility.

Conclusion Switching to ART will lead to an increase in the performance of Android devices and a decrease in the number of lags. The main disadvantages of Dalvik compared to ART Dalvik is slower, like other virtual machines. The JIT compiler is additional code, which means an additional headache for some developers. Main disadvantages of ART compared to Dalvik Increased volume of applications. Increased installation time

In the modern world of technology and abbreviations, no one is surprised by new names and abbreviations. However, there is a problem: ordinary users are not always fully aware of what their gadget has learned after the update. Developers rarely delight us with detailed descriptions of innovations and new technologies, and it is extremely rare to find any clear explanation on the official website - at best, the user will find only a brief description with even more incomprehensible expressions.

We always try to help users understand new devices and technologies, so we decided to tell you, our readers, about ART technology in more detail, and also make a small comparison with the familiar Dalvik virtual machine.

What is an application runtime (virtual machine)?

Discussion of Dalvik and ART is impossible without understanding the basics, so first let's talk about the virtual machine as such. An application runtime is a set of instructions executed to translate application code into code that a computer can understand. The virtual machine is used without even being part of the main program. In general, all "managed" computer languages ​​(Java in Android, C# in Windows Phone, ECMAScript in browsers) require such an environment to understand the language in which the application is written.

Android uses a virtual machine to execute DEX files (similar to EXE in Windows), which are contained in the APK archive of the Android application. There are two advantages of such a solution. First, each application runs on a system isolated from the OS kernel, so the latter feels more or less safe. Secondly, using a virtual machine opens the way for cross-platform applications, that is, the application can run on an ARM smartphone, MIPS tablet or x86 computer.

“As you know, all this time Android used the Dalvik virtual machine, which everyone who has delved even a little into the features of the OS has probably encountered.”


Why use an application runtime at all?

We have already answered this question above. There is no doubt that using a virtual machine slows down the execution of applications, but it has several advantages that sway the choice in its favor.

  • The virtual machine runs third-party application code in an isolated environment. Consequently, code that can harm the OS kernel will not be able to directly interact with system files, which will protect the system. A huge advantage of using a virtual machine is the more stable and reliable operation of the main system.
  • Through the Google Play Store and other sources, the developer distributes an APK file of his program, which contains uncompiled instructions that will be “assembled” by a virtual machine before execution. This solution provides greater compatibility; otherwise, code compiled for Snapdragon-based devices will not be able to run on Atom devices. Therefore, the virtual machine solves the problem with the compilation destination.

What is Dalvik and what is its problem?

That's the main question. Dalvik has been used in Android since the first version of the OS, since 2007, and during all this time there has been practically one major change - the appearance of “on-the-fly compilation” in Froyo, better known as JIT. Its main feature is that the application is fully compiled when the user opens or runs the corresponding instructions. This is a very useful fix, since before 2.2 all applications were compiled step by step, which reduced the speed; The only disadvantage of this solution is that when the program starts, there is a serious load on the processor.

To avoid additional work when running the program again, the system collects together all the instructions compiled while using the application and sends them to a cache, which is stored in the file system with the *.ODEX (Optimized Dalvik EXecutable) extension. As soon as you launch the application for the second time, Dalvik will no longer compile, but will load data already optimized for your device into memory. However, calling an application function that has not been used before will cause the instructions to be compiled anew. If at this moment the system is carrying out third-party work (for example, listening to music or updating applications), then due to overload of the processor and input/output subsystems, noticeable jerks and brakes can be observed in the memory. This is where ART comes in.

What is ART and how will it save the world?

ART, or Android RunTime (a very crooked name) is a new virtual machine that Google introduced in Android 4.4 as one of the developer tools (Dalvik is used by default). The main difference between the new application execution environment is the use of Ahead-Of-Time technology (AOT, “ahead of time”). ART compiles all application instructions before it starts, during the installation process. The time of the latter increases, as well as the amount of permanent memory occupied by the program, but the virtual machine no longer compiles the current application during its execution, which improves comfort when actively using multitasking. However, it is advisable to have more RAM, since ART will load into it even those application instructions that you may never use.

Dalvik vs. ART


Let's briefly compare the two virtual machines


ART is still an experiment

Of course, at the moment ART is only being tested and is available only for devices running Android 4.4 and chipsets from Qualcomm. However, you can now switch from Dalvik to ART through hidden developer tools (the menu opens after a few taps on the build number in the device information). Please note that not all applications will be able to work in ART without additional updates; By the way, the first launch in ART mode can take up to 30 minutes.

Google has made ART available to developers now, setting the stage for a full transition to this virtual machine in the future. This does not mean that ART is stable now. This is an experiment and the new virtual machine may not be ready for everyday use.

Best articles on the topic