[Explained] ART Runtime in Android 4.4(kitkat)

Search This thread

Razvan

Retired Forum Moderator
  • Like
Reactions: #Henkate

JavaScout

Senior Member
Apr 3, 2012
681
275
Btw, additional 'contra' of art is - increased memory (ram) occupation. Can someone confirm or is it just me?
 
  • Like
Reactions: #Henkate

Top Liked Posts

  • There are no posts matching your filters.
  • 166
    What is ART?
    ART stands for Android runtime which is a new runtime like Dalvik which is introduced experimentally in the 4.4 release. This is a preview of work in progress in KitKat that can be turned on in Settings > developer option.n 4.4 both runtimes are now available, Dalvik runtime (libdvm.so) and the ART (libart.so).The user can choose it from developer options.

    Difference between Dalvik and ART

    Dalvik
    Dalvik runtime uses JIT(Just-In-Time) compilation to interpret Bytecode
    Now lets understand the technical info and terms in the above sentence.

    Compiler
    A compiler is a program or set of programs that transforms source code written in a programming language (the source language) into another computer language

    Bytecode
    Bytecode also known as p-code (portable code), is a form of instruction set designed for efficient execution by a software interpreter

    Interpreter
    Interpreter is a program which translates the source code into computer/machine language[/quote]

    JIT compliation
    JIT (Just-In-Time) compliation interprets the bytecode into machine language at it's runtime (at the time when the apps are executed).



    Now summing up all these Dalvik runtime does everything when the apps are executed. Now this is where we must discuss odexed and deodexed ROM. usually all stock ROMs released by OEMs are only odexed only due to this reason. odex means a part of the app is already compiled and it is written into dalvik VM(VM=Virtual Machine). and it runs at boot so while execution of apps JIT has to compile only the remaining part of the code when the apps is executed, this is why odexed ROM is faster than deodexed ROM.

    But the disadvantage of odexed ROM is it cannot be edited/themed easily as a part of code is seperated in a separate file, and deodexing means the odex part of the file is put back into the apk/jar itself which makes editing/theming easy since the full code is packed inside a single file but it decreases speed because JIT has to compile full code when the app is executed


    ART

    ART uses AOT compilation to interpret bytecode.

    I hope you can refer to dalvik paragraph to know about these technical terms. :p

    what is AOT compilation
    AOT (Ahead-Of-Time) is a method of compilation which compiles the code into machine language when the app is installed itself, means no compilation is done at the time of execution of app. This makes the apps launch speed amazingly fast.[/quote]


    Advantages of ART over Dalvik

    1. The apps launch speed is amazingly fast in case of ART since nothing is compiled at execution.
    2. Boot speed is faster than dalvik since nothing is execued from dalvik partition as in case of odexed ROM in dalvik
    3. Increases battery backup by reducing CPU work due to absence of compilation work on apps execution.
    4. And finally it is a great reward to developers because most of developers are worried that odexed ROMs are faster than deodexed ROMs but they will deodex their ROMs since they heavily theme it. In case of ART whether the ROM is odexed or deodexed it doesn't matter, it compiles the full code into machine language on installation of apps. so even deodexed ROMs are as fast as odexed in ART

    Some disadvantages of ART

    1. Since ART precompiles apps on installation, it takes 10-20% more space upon installation than dalvik. But this can be simply solved by using apps like apps2sd/link2sd/gl2sd when your apps storage partition is full
    2. One more is since it is only experimental feature now some apps are incompatible in ART which will be made compatible soon on their updates.

    Here is the list of apps which are compatible and incompatible in ART.
    http://www.androidruntime.com/list

    Finally ART is one of the best feature that google brought up in android 4.4 (kitkat)
    11
    Good job on creating a great informative thread.

    I want to point out some things to avoid confusion for new people in android:

    *Odexed roms and Deodexed roms have exactly the same opening speed, booting time and performance, .
    The only thing that is changed is the speed of the 1st boot time. Nothing else.
    A deodexed rom having lower performance than an odexed is just placebo. The difference is just the odexes location of system apps.

    To elaborate more on this matter, a fully odexed rom, the 1st time it will boot it will be very fast (like a normal reboot).
    And normally the dalvik-cache folder will be empty because all odex files are near their source.

    On a deodexed rom, the 1st time you power that device it will take a lot of time based on the cpu speed.
    After creating the bootclass apps' odexes, you will see the screen that says how many remaining apps android is optimizing.
    So after this is done, the performance, opening speed, boot time and everything is exactly the same as the odexed rom.

    *The reason that OEMs put odexed roms is for 2 reasons, save storage space and zero to small extra time on 1st boot (or factory reset).

    *And lastly, the only reason ART is faster on booting, is that it has faster app start up code and faster overall performance (because no interpreting to machine code is needed for every class/function/calculation etc, on app start up and while it's running).

    Thanks again for making this guide
    6
    How can it be that none of the stock apps such as Google play, gallery, phone, etc work? Also, how come the time of compilation makes a difference in the compatibility of the apps? In the end the apps are all in machine code when they're run anyways?

    Sent from my GT-I9300 using Tapatalk

    Because some apps use specific Dalvik things, and they don't work when they are compiled before the app is run, when the app needs something that it's on memory (for example) when compiled in Dalvik, but it doesn't have it in ART as when it was compiled there was nothing, and...

    Problems.


    Anyway, that's why Dalvik is a not only Dalvik, but Dalvik VM

    Virtual Machines, they translate specific code instructions to a optimized code for your CPU architecture. This has been always intended.

    When Android 1.0 came out, Google used a very obvious but brilliant way to make the OS to gain market share.

    Since Dalvik is a Virtual Machine (hence, Dalvik VM), you could throw any CPU on the device, and Dalvik WILL translate whatever you put in there, to a code that the CPU can understand.

    And therefore, JIT (Just-in-time) compilation. If the code wasn't translated, the code would be utterly slow, because it will need to be reinterpreted for every instruction, that are not ordered, that are not correct, and that the CPU could possibly understand wrong.

    So, by using JIT, the code will be translated instantly by Dalvik to a single instruction (instead of multiple ones) that will be executed once. It is FAST, but it's not optimal, because Dalvik also consumes CPU.


    That ensured cross-platform compatibility for Android. Now, time has passed since Android 1.0 has come, and now that ARM has been consolidated as the de facto CPU platform for mobile phones. Android Runtime came...

    So, instead of compiling CPU instructions on-the-fly that also consume CPU resources, when your APP is installed, it's automatically translated as a whole to ART (that's why it takes that much time), and when RUN, it will run with FULL CPU power, because there is no Dalvik VM running now.
    5
    What is ART?


    Difference between Dalvik and ART







    Now summing up all these Dalvik runtime does everything when the apps are executed. Now this is where we must discuss odexed and deodexed ROM. usually all stock ROMs released by OEMs are only odexed only due to this reason. odex means a part of the app is already compiled and it is written into dalvik VM(VM=Virtual Machine). and it runs at boot so while execution of apps JIT has to compile only the remaining part of the code when the apps is executed, this is why odexed ROM is faster than deodexed ROM.

    But the disadvantage of odexed ROM is it cannot be edited/themed easily as a part of code is seperated in a separate file, and deodexing means the odex part of the file is put back into the apk/jar itself which makes editing/theming easy since the full code is packed inside a single file but it decreases speed because JIT has to compile full code when the app is executed








    Here is the list of apps which are compatible and incompatible in ART.
    http://www.androidruntime.com/list

    Finally ART is one of the best feature that google brought up in android 4.4 (kitkat)

    Thanks Bro! For Info ! :)
    4
    Please always post in English here guys.
    If you're going to post in a different language, always provide an English translation in your post.

    Thanks