Optimized OpenJDK Build for riscv64!

I wasn’t able to find any optimized builds of the JDK for riscv64 (that specifically don’t use the “Zero VM”), so I went ahead and built one for folks to use.

While debian/ubuntu provide openjdk packages, they are built with the interpreted-only Zero VM. However, JDK 19+, offer native riscv64 optimized HotSpot server VMs, if it’s built with that feature. That’s what my build does – it supports GLIBC 2.5+, so its more compatible with various ubuntu and debian versions. You can check it out here: GitHub - fizzed/nitro: Alternative OpenJDK builds for architectures such as riscv64

It has roughly 4-8 x’ed the performance of the JVM on my VF2 and it’s currently beating my RPi4 in many tests. Would love to know what you think or if there’s any other optimizations folks can think of.

8 Likes

I will try my 2D MMO as soon as I get my board…


How long did it take to compile?

3 Likes

Takes around 3 mins to build on my AMD 7950x – this is x86_64 cross compilation, not compilation on the VF2 itself. If you wanna try it locally yourself, build instructions are here: GitHub - fizzed/nitro: Alternative OpenJDK builds for architectures such as riscv64

3 Likes

That’s amazing…
How does that compare to Temurin openJDK’s builds?

Amazing work! Could we upstream this to debian official apt source?

Temurin does not distribute riscv64 builds – if you are seeing something different than I am, please let me know.

It does distribute nightly builds for testing purposes. I have one from last October.

What are the differences between this and GitHub - riscv-collab/riscv-openjdk?

2 Likes

Tinspin, that OpenJDK collab you posted was the work done to make the JIT (e.g. Hotspot) work well for riscv64. What I posted was a binary build of OpenJDK 19 that activated the JIT (e.g. Hotspot) for riscv64. If you try to install debian’s default “openjdk-19-jdk” package, it’ll contain the “zero vm” which isn’t JIT/hotspot and will run very slow.

1 Like

I think those nightly builds from Temurin are activating JIT/Hotspot/ServerVM, so it’d be the same as what I posted, although I built mine off an established tagged release vs. being nightly.

1 Like

besides, work about jdk has merged to upstream jdk repo. riscv collab repo is not used anymore.

2 Likes

Can somebody check run javac & java inside docker?
I have a crash when run java in docker containers, but its work on host machine. I tested jdk-19.0.1+10, 19.0.2+7 from source, 20-ga, with docker images riscv64/ubuntu:22.04, riscv64/ubuntu:22.10, riscv64/debian, handmade images by debootstrap based ubuntu jammy. All variants had a failure. Docker versions 20.10.12, 20.10.23 from ubuntu\debian ports

Okay. I checked your build. Its has same error. Can’t run inside docker. =\
May you can reproduce it?

root@a79928abbc20:/dk/fizzed19.36-jdk19.0.1-linux_riscv64# ./bin/java --version
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x0000003f7c3efa60, pid=84, tid=85
#
# JRE version:  (19.0.1+10) (build )
# Java VM: OpenJDK 64-Bit Server VM (19.0.1+10, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
# Problematic frame:
# v  ~BufferBlob::native signature handlers 0x0000003f7c3efa60
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /dk/fizzed19.36-jdk19.0.1-linux_riscv64/core.84)
#
# An error report file with more information is saved as:
# /dk/fizzed19.36-jdk19.0.1-linux_riscv64/hs_err_pid84.log

#
#
(core dumped)

root@a79928abbc20:/dk/fizzed19.36-jdk19.0.1-linux_riscv64# ./bin/javac --version
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGILL (0x4) at pc=0x0000003f7c3efa60, pid=92, tid=93
#
# JRE version:  (19.0.1+10) (build )
# Java VM: OpenJDK 64-Bit Server VM (19.0.1+10, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
# Problematic frame:
# v  ~BufferBlob::native signature handlers 0x0000003f7c3efa60
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /dk/fizzed19.36-jdk19.0.1-linux_riscv64/core.92)
#
# An error report file with more information is saved as:
# /dk/fizzed19.36-jdk19.0.1-linux_riscv64/hs_err_pid92.log
#
#

(core dumped)

root@a79928abbc20:/dk/fizzed19.36-jdk19.0.1-linux_riscv64# 
root@a79928abbc20:/dk/fizzed19.36-jdk19.0.1-linux_riscv64# uname -a
Linux a79928abbc20 5.19.0-1005-starfive #7-Ubuntu SMP Sat Oct 15 12:21:57 UTC 2022 riscv64 riscv64 riscv64 GNU/Linux
root@a79928abbc20:/dk/fizzed19.36-jdk19.0.1-linux_riscv64# cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"
root@a79928abbc20:/dk/fizzed19.36-jdk19.0.1-linux_riscv64# 


1 Like