Thursday, July 19, 2012

Java performance on Raspbian vs Debian

Over the past few weeks I’ve been blogging about my experience of running Apache Cassandra on the Raspberry Pi.  I plan to use the Pi as an educational resource in the University I work in, hopefully giving students the chance to play with large clusters and experiment with configurations, database models and practices in a nosql environment.  Of course performance isn’t great but  for me, it’s a  cheap way of getting lots of nodes and do real network configuration problems. 

A couple of days ago a new Debian based distro for the pi was released called Raspbian “wheezy” was released and is now the official Raspberry Pi Debian distro (I believe).   This is the first OS release for the Pi to take advantage of the Pi’s floating point hardware, which is going to make the OS a lot faster for general use.  I downloaded it for testing in my rig, sadly this is a tale of woe.

Apache Cassandra is a Java application and needs a JRE in order to run.    I’ve always used a  Oracle supplied JVM “Oracle’s java SE for  embedded “

Sadly, it seems this can’t be used on Raspbian.  Trying to run it gives :

Java: error while loading shared libraries: cannot open shared object file: No such file or directory

It seems that this version of Java uses the “soft float ABI (armel) which is incompatible with Raspbian”: (thanks to mpthompson on the Raspberry Pi forum for the information) so it’s looking like it can’t run.  Back to openjdk ?

But wait !  Why did I not use openjdk in the first place ?

That’s simple, performance.  In my experience (and perhaps this is a configuration problem I’m not aware of)  Open JDK is a lot slower than the Oracle version.  And  I mean a lot slower!  I set up a single node Cassandra server image, one with the old Debian image and Oracle Java the other with Raspbian and Open JDk.  I then ran stress tests from a Apple Air (something I’ve done many times !) .  Here’s the results.  The second column is interval_op_rate, you want this to be as high as possible, the third column  is  avg_latency, you want this to be as low as possible.

Raspbian and OpenJDK

>Lifeintheairage:bin Administrator$ ./stress -d -o insert -I DeflateCompressor
Unable to create stress keyspace: Keyspace names must be case-insensitively unique ("Keyspace1" conflicts with "Keyspace1")


Debian Squeze and Java SE for embedded

>lifeintheairage:bin Administrator$ ./stress -d -o insert -I DeflateCompressor
Unable to create stress keyspace: Keyspace names must be case-insensitively unique ("Keyspace1" conflicts with "Keyspace1")

And a graph of interval_op_rate:

(red is Java SE for embedded, blue is OpenJDK)

Java SE for embedded really is a lot faster for Apache Cassandra (and I wouldn’t be surprised for other java apps such as Arduino IDE).  For now I need to stick with the Debian release, I hope it doesn’t become unsupported.  Hopefully someone can  get in touch with Oracle and encourage them to support a official port of Java SE for embedded onto the raspberry which supports the correct Raspbian libraries.


  1. This comment has been removed by the author.

  2. Hi Andy, thanks for the writeup on this issue. Agree that it seems to be 'back to Debian' for now...

    Once you've used an Oracle JRE, its difficult to accept anything else... the figures don't lie!

    Hopefully we can encourage Oracle to produce an armhf compatible JRE binary.


  3. Did you use openjdk's java with the -cacao flag? I'm just starting to experiment with java on the rpi but running a simple benchmark did show an improvement using cacao's jit rather than the stock jvm.

  4. @ksclarke, yes I've experimented with the -cacao flag. There is a small improvement but not great compared to the oracle JRE

  5. hi, i have a problem when i install jdk on debian, i prefer oracle jdk to openjdk. I download jdk from oracle web, i extrac it, create symlink and modify .bashrc, but when i try to use command java, javac etc, the console shows "cannot execute binary file".

    Can help me. thx.

  6. I've not seen that error. Did you download Java SE Embedded 6
    ARMv6/7 Linux - Headless file I think is ejre-1_6_0_32-fcs-b05-linux-arm-vfp-eabi-headless-05_apr_2012.tar.gz ?

    1. Thank very much, at the end, I deleted all and reinstall for fifth time jeje, now it works xD, when I write java -version command in console, shows ->

      java version "1.6.0_32"
      Java(TM) 2 Runtime Environment, Standard Edition for Embedded (build 1.6.0_32-b05, headless)
      Java HotSpot(TM) Embedded Client VM (build 20.7-b02, mixed mode)

      I thought with embedded jdk i could compiler *.java archives, but only is the java command.

      If need javac command, Where or with What could I execute javac command?

  7. @andrea nope the JRE won't compile java programs for you. It's the run time environment. However you can use openjdk on the Pi to compile your code and run it und er the Oracle JRE. You can of course also write and debug on a desktop machine and just deploy the class or jar files to the PI.

    1. @Andy C a lot of thx for all help, I installed openjdk and configured command java with the oracle embedded, i now i can compile :).

      Thank you very much.

  8. Hi Andy. Thanks for clearing this out, this information was exactly was I was looking for! I have been trying the OpenJDK with very bad performance. Is it possible to find a ready-made image for RaspberryPi of the Debian release you are using? Where and how can I find that?

    1. I've asked on the Raspberry pi forum for them to put the Debian image back on line for us java users . If nothing happens contact me on twitter @andycobley

    2. I think the original debian release might be

    3. This comment has been removed by the author.

  9. Andy, I just tweeted you, but just in case, I'll put here the link to all the flavors of Raspi distributions:

    Hope is what you were looking for!



  10. This is very good

  11. The java is infact a powerful tool and its performance is far better than other languages but most common language for the Web Development Services is PHP , as due to its felxiblity and open source.

  12. Now a days java is important and very powerful tool also. Its performace really very fast and better than other languages. There are many web application development company india and web development company india provides this java development options also.Thanks this blog is really very informative and cool also.

  13. Thank you for this post, very helpful for my web development and design. There are lot of tools for web development and as I know Java one of the old one language but very good for web development. keep posting tip for web development please.

  14. Hey nice blog,Thank's for this helpful information come back again for more interesting information…Keep it up!
    Taxi in Agra

  15. JBN Creators is dedicated to provide all-in-one eCommerce websites for your store. Here we are ready to provide you optimum support in terms of improving your business and expanding the horizon. We invite you to make use of our optimum resources so as to meet the business goal at the earliest.
    Web Development