0%

different jvm implementation for Java language

Besides Oracle Java distibution, there are some other vendors provide Java distributions. If you use them to replace Oracle JDK or OpenJDK, make sure they passed JCK. Which can help to check the compatibility for this change.

However, there are some vendors provide enhancement features in the JVM, here are some highlights.

Alibaba Dragonwell

1. Wisp2 - Dragonwell8

corouting implemeted in JVM level, refer: https://github.com/alibaba/dragonwell8/wiki/Wisp-Documentation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.concurrent.*;

public class PingPong {
public static void main(String[] args) throws Exception {
BlockingQueue<Byte> q1, q2;
q1 = new ArrayBlockingQueue<Byte>(1024);
q2 = new ArrayBlockingQueue<Byte>(1024);

ExecutorService pool = Executors.newFixedThreadPool(10);
pool.submit(() -> pingpong(q2, q1));
Future<Long> future = pool.submit(() -> pingpong(q1, q2));
q1.put((byte) 1);
System.out.println(future.get() + " ms");

pool.shutdown();
}

private static long pingpong(BlockingQueue in, BlockingQueue out) throws Exception {
long start = System.currentTimeMillis();
for (int i = 0; i < 1_000_000; i++) {
out.put(in.take());
}
return System.currentTimeMillis() - start;
}
}
1
2
3
4
5
6
7
8
$ java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (Alibaba Dragonwell 8.5.4) (build 1.8.0_272-_2020_11_12_03_10-b00)
OpenJDK 64-Bit Server VM (Alibaba Dragonwell 8.5.4) (build 25.272-b00, mixed mode)
$ java PingPong
23729 ms
$ java -XX:+UnlockExperimentalVMOptions -XX:+UseWisp2 PingPong
4400 ms

2. JWarmup

refer: https://zhuanlan.zhihu.com/p/61817233

Gather pre-Warmup data when executing in Beta environment
And we can start with these warmup data in production envrionment to shorten the JIT warmup period.

1
2
3
$ JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-XX:ReservedCodeCacheSize=512m -XX:CompilationWarmUpLogfile=$PWD/jwarmup.log -XX:+CompilationWarmUpRecording -XX:+CompilationWarmUp -XX:-TieredCompilation -XX:+DeoptimizeBeforeWarmUp -XX:CompilationWarmUpDeoptTime=30 -XX:+PrintCompilationWarmUpDetail" sh bin/catalina.sh start
$
$ JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-XX:ReservedCodeCacheSize=512m -XX:CompilationWarmUpLogfile=$PWD/jwarmup.log -XX:+CompilationWarmUp -XX:-TieredCompilation -XX:+DeoptimizeBeforeWarmUp -XX:CompilationWarmUpDeoptTime=30 -XX:+PrintCompilationWarmUpDetail" sh bin/catalina.sh start

3. JFR

collect diagnostic and profiling data with build-in module in minimal performance overhead.

We can periodly dump or use jcmd command to trigger the dump. The dump file can be used in JMC tool.

1
2
3
4
5
6
$ JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-XX:+EnableJFR -XX:StartFlightRecording=duration=1m,filename=rec.jfr" sh bin/catalina.sh start
$
$ jcmd <PID> JFR.start duration=10s filename=$PWD/rec3.jfr
$
$ jcmd <PID> JFR.start filename=$PWD/rec4.jfr
$ jcmd <PID> JFR.dump name=4 filename=rec4.jfr