Comparing 3 JDKs by Android build time

Thanks to ccache, C/C++ build time has been significantly reduced. Next I want to speed up Java.

This time I tried to compare build time using 3 different JDKs, which are available in Ubuntu.
(Japanese version of this page)

3 JDKs available in Ubuntu

I tried the following 3 JDKs

  • sun-jdk from apt-get
  • JDK downloaded from Oracle site
  • openjdk

I show you how to install these JDKs.

sun-jdk from apt-get

Follow the instruction described at http://source.android.com/source/initializing.html.

$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

java version is “1.6.0_24”.

JDK downloaded from Oracle site

Download jdk-6u25-linux-x64.bin from Oracle’s download site. This file is shell script.

$ cd /usr/lib/jvm
$ sudo sh ~/jdk-6u25-linux-x64.bin

java version is “1.6.0_25”.

openjdk

the most easiest to install.

$ sudo apt-get install openjdk-6-jdk

java version is”1.6.0_20″.

Comparing build time

This time I used ccache (USE_CCACHE=1). See the previous post for the detail of build environment.

To switch JDK, change environment variables by the following script.

$ cat ./env.sh 
#export ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.24
#export ANDROID_JAVA_HOME=/usr/lib/jvm/jdk1.6.0_25
export JAVA_HOME=$ANDROID_JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH

My build machine is Ubuntu 10.04, CPU: Intel Core i7 950 @3.07GHz, RAM 12GB.

sun-jdk from apt-get

$ java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
$ rm -rf out/
$ ./build.sh 

real	8m12.327s
user	64m53.990s
sys	4m5.490s

JDK downloaded from Oracle site

$ java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
$ rm -rf out/
$ ./build.sh 

real	8m21.206s
user	67m55.350s
sys	4m6.490s

openjdk

$ java -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.7) (6b20-1.9.7-0ubuntu1~10.04.1)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
$ rm -rf out/
$ ./build.sh 

real	8m3.132s
user	63m13.720s
sys	4m7.530s

Conclusion

I repeat measuring a couple of times. The results are almost same. Openjdk is the fastest among these three.

The results may vary by build environment and so on. Give it a try and tell me.

I like openjdk, because it is the fastest and the easiest to install.

I posted this article to ‘Android Building’ of Google Groups and got some comments.
Look at this.

P.S.

There is another way to switch java environment.

$ sudo update-alternatives --config java

This command switches the whole system.

I prefer the way changing environment variables as I show in this entry. Because I sometimes build Gingerbread (which requires JDK6) and Froyo (which requires JDK5) in parallel.

Links

“Comparing 3 JDKs by Android build time” at Android Building, Google Groups

Related pages

Using ccache to build Android
Using ccache to build Android(2)
Quick hack to run Android 2.3(Gingerbread) on KZM-A9-Dual board

Advertisements

About tetsu_koba

Engineer.
This entry was posted in Android. Bookmark the permalink.

3 Responses to Comparing 3 JDKs by Android build time

  1. Dominic Binks says:

    We found that increasing the amount of heap available to droiddoc to 1280m reduced build times by around 3 minutes. If you’ve not tried that you may want to give it a go.

    Dominic

  2. Alan says:

    Interesting, I wasn’t sure Android would even build with OpenJDK… I suppose now that Oracle has revoked the distribution license used by Linux distrbutions to include java packages, we should really be looking to switch to OpenJDK.

    Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s