Tuesday, March 13, 2012

Dalvik Optimization


Dalvik is the process virtual machine  in Google's Android operating system. It is the software that runs the apps on Android devices. Dalvik is thus an integral part of Android, which is typically used on mobile devices such as mobile phones and tablet computers. The DVM  was designed specifically for the Android mobile platform.

Java virtual machine are stack machines, and the  Dalvik virtual machine  is a register-based architecture.

                               Generally, stack-based machines must use instructions to load data on the stack and manipulate that data and thus require more instructions than register machines to implement the same high level code, but the instructions in a register machine must encode the source and destination registers and therefore tend to be larger. This difference is primarily of importance to VM interpreters for which opcode dispatch tends to be expensive along with other factors similarly relevant to just-in-time compilation.


There are two process for dalvik optimization-

1.Optimization through dex:-

                                  A tool called dx is used to convert some Java .class files into the .dex format. Multiple classes are included in a single .dex file. Duplicate strings and other constants used in multiple class files are included only once in the .dex output to conserve space. Java byte code is also converted into an alternative instruction set used by the Dalvik VM. An uncompressed .dex file is typically a few percent smaller in size than a compressed Java Archive derived from the same .class files.

                               The Dalvik executables may be modified again when installed onto a mobile device. In order to gain further optimizations, byte order may be swapped in certain data, simple data structures and function libraries may be linked inline, and empty class objects may be short-circuited.


2.Optimization through zygote:-
                                         During start-up of the Android system the Linux kernel first calls the process "init"."init.device.rc" is device specific, on the virtual device this file is called "init.goldfish.rc".init.rc starts the process "Zygote" via the program system/bin/app_process". Zygote loads the core Java classes and performs initial processing of them. These classes can be reused by Android application and therefore this step makes them faster to start. Once the initial work of Zygote is done, the process listens to a socket and waits for requests.



2 comments:

  1. Can you please let me know if i want to use dalvik in multiprocessor system of or with bulky hardware device will it be accessible.Please provide me code generation step to enhance my knowledge.

    ReplyDelete
  2. yes sure you can use dalvik for any type of system.which having single processor as well as multiprocessor..

    ReplyDelete

Mastering Jetpack Compose: Key Methods for Efficient Android UI Development

Jetpack Compose is a modern toolkit for building native Android UI. It simplifies UI development by providing a declarative approach, making...