java runtime performance on BeaglePlay

I’ve seen Java being used on a Raspberry Pi and was curious to see how well it worked on my BeaglePlay board. Here are the results.

In this test I created a basic hello world program and used Java to run the script without compiling it first. So basically, Java compiles and then executes, which demonstrates SBC compute speed based on resource availability.

public class HelloWorld {
    public static void main (String[] args) {
        String txt = "Hello World";
        System.out.println(txt);
    }
}

To execute I used:

java Filename.java

My Raspberry Pi 4 board, which uses Java 17, was able to execute in approx. 3 to 4 seconds, while my BeaglePlay board (using Java 11) took approx. 5 to 6 seconds to execute.

As such, I am trying to understand the reasons for the slower performance on the BeaglePlay and whether there’s anything I can tweak on the BeaglePlay to achieve similar results to a Raspberry Pi 4.

Thanks.

Well to start you should really compare the same version of Java. The differences you are seeing might be due to that, rather than the hardware.

1 Like

You must do your experiment in an “apples to apples” state.

Post your setups for both boards including image versions and such.

Your result of 3 to 4 seconds is pretty slow here is c code version for you to test.



#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */
int main(int argc, char** argv) {
    printf("Hello this is test 1");
    return (EXIT_SUCCESS);
}

Run this on all your boards using this line to start it:

:/home/test-delete# time ./test-hello
Hello this is test 1
real    0m0.025s
user    0m0.000s
sys     0m0.021s


That is on a 32 bit SBC.

Here is X86

fred@eng-dev6:~/delete-tests$ time ./test-hello 
Hello this is test 1
real	0m0.001s
user	0m0.001s
sys	0m0.000s

Same source.

Precede your binary with time for the exact run time.

As @benedict.hewson stated the version is very critical. Java was not designed for speed, it is for multiplatform. If you need portability and not speed java is a good solution.

I’ve just update to:
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Debian-1deb11u1, mixed mode, sharing)

This made no discernible impact on the execution time.

I’m specifically testing java.

Yes, with c code and with python I cannot really tell performance apart (between raspberry pi and beagleplay) but with Java it’s quite noticeable.

The thing is, I don’t have any experience with Java so, very much learning by doing (and asking questions).

BeaglePlay spec:
Linux BeaglePlay 5.10.168-ti-arm64-r111 #1bullseye SMP Tue Sep 26 14:22:20 UTC 2023 aarch64 GNU/Linux
Debian GNU/Linux 11 (bullseye)

Raspberry Pi 4 spec:
Linux raspberrypi 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) aarch64 GNU/Linux
Debian GNU/Linux 12 (bookworm)

For me to get into java the license is $1200 per year…We just don’t have a need for it. I did just look at their site and they are upto version 21. If you can get the latest on both machines that would be the best.

Also, buy some books. Plenty of the stuff on the internet is stale and much of it is crazy stuff, its easy to spend hours chasing your tail.

There’s no need to spend a cent/dime/penny if you use openJDK. There is also a helpful “friends of openjdk” site too… https://foojay.io/

That was how I stumbled upon this YouTube video demo… here Java worked instantly… https://www.youtube.com/watch?v=w4AR4hWP3Qk&t=4s

1 Like

For what it’s worth… the delay is caused by the compile process.

Tested using javac HelloWorld.java. This took +6 seconds.

Then it was instant to run the executable java HelloWorld.

No doubt there’s optimisations available to improve this “just-in-time” compilation, but I’ve not found, or better yet… I should just stick with running an java executable.

Debian 11.x and Debian 12.x have a different default version of java… Java - Debian Wiki

Java v11 vs v17, are you comparing both systems with the same major build…

edit, nm, i see you used the v17 build in Debian 11.x

Regards,

Thank you, I will look into that.

I just completed a test, using the verbose flag on my laptop, Raspberry Pi and BeaglePlay. Just a pure guess, but at first glance the slower speed seems to be file read related.

The am62 soc is superior to the pi4 so it must be something in the deb 11 image. Can you go backwards on the pi with a deb 11 image?

I was going to test that on our other boards and the meta-java layer stops at 8. Based upon that, I would say that java is for the most part going extinct on embedded stuff. If many developers are using it they would have a more current version in yocto. It might have some issues that cannot be resolved easily or cost effectively and that might be displayed in your testing.

AM62 is a quad A53, the RPI4 is a quad A72

A53 = Power Efficient, in order…
A72 = Not Power Efficient, out of order. :wink:

Regards,

2 Likes

I reflashed my RPi with bullseye image. So I now have:
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+9-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 17.0.9+9-Debian-1deb11u1, mixed mode, sharing)

It made no perceptive difference to the time it took to compile… in fact, data indicates up to 150ms quicker than Debian 12.

The key differences is the kernel.

Both RPi Debian 11 & Debian 12 images rely on Linux kernel 6.1.x while the BeaglePlay kernel is using 5.10.x.

I suspect the SoC is adding to that too, as @RobertCNelson pointed out the different cores that I did not take into consideration at the time of stating how the good the am62 is.

Kernel config is extremely important too, for example those selling boards using “speed comparisons” as the focal point of their marketing are turning off critical resources of the kernel in order to optimize what ever metric they want to look good. Buy the board, then you have to turn on the features so ip tables and UFW work and the board is now same as everyone else in that class…

Have you performed testing on the Pi 5, I have one here and only thing I did with it was too light it up on Ubuntu 23.

Unfortunately, Santa did not send me a Pi 5 :grinning:

PS (Edit): But I went ahead and ordered a Raspberry Pi Zero 2 W (1GHz quad-core 64-bit Arm Cortex-A53 CPU with 512MB SDRAM) to test and compare.

1 Like

It still surprises me that people think using Java costs money… Would you like to share why you thought this was the case?

From the oracle website content it does.

Here is what I have seen on the oracle site.

I don’t see a version 21 yocto recipe either. They have made everything so confusing its not even funny. Many years ago I was a strong supporter of Sun, Solaris was great and the SPARC hardware was the best we could get at that time. Then the java license issue, I still don’t understand what happened. All I see is $$$$ when on the oracle website.

Here is another screen shot that explicitly states a subscription is required.

java2

Oracle Java and Open JDK are not the same thing… OpenJDK versus Oracle JDK

In Debian we use OpenJDK, good luck even getting a armhf or arm64 build of Java from Oracle Java to run on embedded devices…

Regards,

1 Like

Agree with Robert, Oracle website is the last place you should visit for Java information :wink:

But, have to admit I’m biased, as I contribute to https://foojay.io/ and work for Install Azul Zulu on Debian-based Linux

1 Like