What There Is to Know About Alibaba Dragonwell 8

What Is Alibaba Dragonwell 8

Alibaba Dragonwell 8 is a free distribution version of OpenJDK, which will offer long-term support, including performance enhancements and security fixes, from Alibaba Cloud. Alibaba Dragonwell 8 currently supports the X86–64/Linux platform. The addition of Dragonwell 8 can greatly improve the stability, efficiency, and performance of your large-scale Java application deployments in the data centers. Alibaba Dragonwell 8 is a “friendly fork” under the same licensing terms as the OpenJDK project and is compatible with the Java SE Standard. Users can use Alibaba Dragonwell 8 to develop and run Java applications. The open-source Alibaba Dragonwell 8 is the open-source version of the AJDK, a customized version OpenJDK used internally at Alibaba Group. AJDK is specifically optimized for e-commerce, finance, and logistics based on business scenarios and runs on the ultra large-scale Alibaba data center, housing well over 100,000 servers.

How to Install Alibaba Dragonwell 8

Currently, Alibaba Dragonwell 8 supports Linux x86–64 platform only and provides pre-compiled binary JDK packages. You can follow the two steps to install Alibaba Dragonwell 8.

  1. Download the pre-compiled binary JDK packages from the download page under the Alibaba Dragonwell 8 on GitHub.
  2. Unzip the downloaded tar packages to the installation directory.
JAVA_HOME=/path/to/dragonwell8/installation  sh tomcat/bin/catalina.sh start
JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-showversion" sh tomcat/bin/catalina.sh start

How to use Alibaba Dragonwell 8

This sections discusses how you can use the various features of Alibaba Cloud Dragonwell 8. Currently, the preview view of Dragonwell 8 provides two features that have been in full production mode at Alibaba Group internally: JWarmUp and Java Flight Recorder. For both the features, JEP or patches have been submitted to the upstream OpenJDK community. Before the upstream merge is completed, we hope that Alibaba Dragonwell 8 users can use the two features in advance.

Use JWarmUp to Quickly Warm up Java Applications

To improve the execution efficiency, OpenJDK uses the JIT (just-in-time) compilation technology to dynamically compile Java byte code into highly optimized machine code. However, before this compilation is completed, Java code is run in interpreter mode, which is relatively inefficient.

  1. JWarmUp first runs the Java application on a single machine in the beta environment for a short time and records and collects the metadata of actions made by the JIT compiler during this period of time.
  2. JWarmUp then copies the obtained metadata into each machine/container in production that contains the code of the new version.
  3. Finally, the metadata generated in the beta environment is loaded to machines in production by using the JWarmUp parameter to guide the machines in production to complete the JIT warmup in the process of starting the application.

Collect warmup data

Again, consider Tomcat as an example, the following command line parameter can be added to collect the metadata generated in the beta environment during the JIT compilation, where the -XX:CompilationWarmUpLogfile= parameter specifies the path of the JWarmUp file generated.

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

Use recorded data to warm up Java applications

On machines in production, you can simply use the following parameters to start a new instance of Tomcat by using the previous warmup data. The -XX:CompilationWarmUpLogfile= parameter specifies the path of the JWarmUp file to be loaded. This file should be copied from the beta environment in the previous step to collect warmup data.

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

Use Java Flight Recorder to Analyze Java Application Performance

JFR (Java Flight Recorder) is an event-based performance analysis feature built in JVMs. This commercial feature began to be available starting in Oracle JDK7u4. The feature was made open source for JDK11 in 2018. However, support for JDK8 is not available.

Use JFR to Collect Performance Data

By default, the JFR feature is disabled in Alibaba Dragonwell 8. To enable the JFR feature, the command-line parameter -XX:+EnableJFR must be added. Alibaba Dragonwell 8 provides several options to collect performance data by using JFR.

JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-XX:+EnableJFR -XX:StartFlightRecording=duration=1m,filename=rec.jfr" sh bin/catalina.sh start
JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-XX:+EnableJFR" sh bin/catalina.sh start
$ ps ax | grep tomcat
77522 pts/18 Sl+ 0:08 /home/chuansheng.lcs/dw_test/apache-tomcat-8.5.39/../j2sdk-image/bin/java -Djava.util.logging.config.file=/home/chuansheng.lcs/dw_test/apache-tomcat-8.5.39/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -XX:+EnableJFR -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /home/chuansheng.lcs/dw_test/apache-tomcat-8.5.39/bin/bootstrap.jar:/home/chuansheng.lcs/dw_test/apache-tomcat-8.5.39/bin/tomcat-juli.jar -Dcatalina.base=/home/chuansheng.lcs/dw_test/apache-tomcat-8.5.39 -Dcatalina.home=/home/chuansheng.lcs/dw_test/apache-tomcat-8.5.39 -Djava.io.tmpdir=/home/chuansheng.lcs/dw_test/apache-tomcat-8.5.39/temp org.apache.catalina.startup.Bootstrap start
98451 pts/22 S+ 0:00 grep --color=auto tomcat
$ dragonwell8_home/bin/jcmd 77522 JFR.start duration=10s filename=$PWD/rec3.jfr
77522:
Started recording 3. The result will be written to:
/home/my/workdir/rec3.jfr
$ dragonwell8_home/bin/jcmd 2823 JFR.start filename=$PWD/rec4.jfr
2823:
Started recording 4. No limit specified, using maxsize=250MB as default.
Use JFR.dump name=4 to copy recording data to file.$ dragonwell8_home/bin/jcmd 2823 JFR.dump name=4 filename=rec4.jfr
2823:
Dumped recording "Recording-4", 332.7 kB written to:
/path/to/my/workdir/rec4.jfr

Use JMC for Performance Analysis

JFR records Java application performance data in a binary file. With JMC (Java Mission Control), we can analyze a specific set of performance data in a graphic interface. JMC is an open-source tool. It is not included in Alibaba Dragonwell 8. To use this tool, you can download it at the OpenJDK official website https://jdk.java.net/jmc/

Support for Diagnosis and Debugging

Alibaba Dragonwell 8 also has some convenient and built-in diagnosis features discussed below.

Alerting on the Assignment of Large Objects

The new JVM parameter -XX:ArrayAllocationWarningSize= can be used for this purpose. For example, the following code assigns a relatively large array.

public static void main(String[] args) {
doAlloc(32 * 1024 * 1024 + 1);
}
private static Object doAlloc(int size) {
return new byte[size];
}

Detailed Support for ParNew GC Logs

By default, the CMS (Concurrent Mark Sweep) algorithm is used in Alibaba Dragonwell 8 and the ParNew algorithm is used for the young generation. Therefore, the two built-in enhancements are provided for ParNew GC logs.

  • You can set the PrintYoungGenHistoAfterParNewGC option by using the jinfo tool so that a object type histogram for the young generation can be printed at the end of the next Young GC. To do this, you can use the following command:
jinfo -flag +PrintYoungGenHistoAfterParNewGC <pid>
  • -XX:+PrintGCRootsTraceTime can be used to print details about CPU time for processing each type of GC root sets. The following content is an output example:

Support for streamlined HeapDumps

The jmap tool in Alibaba Dragonwell 8 supports a new dump option — mini, which allows skipping the content of all arrays of original type when generating HeapDumps. This option significantly reduces the size of generated HeapDump files and is especially helpful in scenarios where it is only required to check types and object relationships.

Participate in construction of the Alibaba Dragonwell community

The Alibaba Dragonwell community provides long-term support for JDK versions. You can obtain support, participate in discussions, and raise your opinions through the following channels:

References

[1] Oracle Java 8 official document: https://docs.oracle.com/javase/8/
[2] OpenJDK 8 project homepage: https://openjdk.java.net/projects/jdk8u/
[3] Alibaba Dragonwell 8 project: https://github.com/alibaba/dragonwell8
[4] Alibaba Dragonwell 8 Developer Guide: https://github.com/alibaba/dragonwell8/wiki/Developer-Guide

Original Source

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com