当前位置:网站首页>Open package evaluation of Longjing

Open package evaluation of Longjing

2020-12-07 19:15:25 Aliyun yunqi

1

Alibaba has the most abundant Java Application scenarios , Covers electricity , Finance , Logistics and many other fields , It's the biggest in the world Java One of the users . 2019 year 3 month 21 Japan , Alibaba officially announced open source at Alibaba cloud summit in Beijing Alibaba Dragonwell 8 product , And set up Alibaba Dragonwell Community for the world Java user , Especially in the Chinese community Java Users provide long-term support JDK product . Since the announcement of open source ,Alibaba Dragonwell 8 By the domestic and foreign Java Developers' concerns , Today's article will explain in detail Alibaba Dragonwell8 Fast installation and use of , At the same time, it lists several ways to participate in community construction , Expect for those who are about to install and use Alibaba Dragonwell 8 For reference .

Alibaba Dragonwell 8 Introduce

Alibaba Dragonwell 8 It's a free one  OpenJDK  Distribution version . It provides long-term support , Including performance enhancements and security fixes .Alibaba Dragonwell 8  At present, we support X86-64/Linux platform , On a large scale in the data center Java In case of application deployment , It can greatly improve the stability 、 Efficiency and performance .Alibaba Dragonwell 8 yes OpenJDK Downstream of (friendly fork), Used and OpenJDK Same licensing.Alibaba Dragonwell 8 And Java SE Standard compatible , Users can use  Alibaba Dragonwell 8 Development and operation Java Applications . Open source Alibaba Dragonwell 8 It's inside Alibaba OpenJDK Customized version AJDK Open source version of , AJDK For online e-commerce , Finance , Logistics is optimized in combination with business scenarios , Running on a very large scale ,100,000+ Alibaba data center of server .

install Alibaba Dragonwell 8

at present Alibaba Dragonwell 8 Only support Linux x86-64 platform , And it provides precompiling of binaries JDK package , You can install it in two simple steps Alibaba Dragonwell 8.

  • from Github above Alibaba Dragonwell 8 The project's download page downloads the precompiled binary JDK package .
    Download page links  https://github.com/alibaba/dragonwell8/releases 
  • Will download the tar Extract the package to the target installation directory .

After installation , You just need to apply the reference Of JAVA_HOME Point to Alibaba Dragonwell 8 You can use the installation directory of . We use Tomcat8.5.39 Version as an example , In order to make Tomcat Running on the Alibaba Dragonwell 8 above , Just start it up Tomcat Use the following command when :

JAVA_HOME=/path/to/dragonwell8/installation  sh tomcat/bin/catalina.sh start

To confirm that it is running in Alibaba Dragonwell 8 above , We can go further by giving java Command addition  -showversion  Parameters to print JDK Version information to judge .

JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-showversion" sh tomcat/bin/catalina.sh start

After the start-up, it will be in tomcat/logs/catalina.out Beginning of file , You can see  Alibaba Dragonwell 8 Version information for .

Use  Alibaba Dragonwell 8 Proprietary features

stay 8.0-preview In this version , Alibaba Dragonwell 8 Provides two features that have been widely validated in Alibaba's production environment :JWarmUp and Java Flight Recorder. Both features are already upstream OpenJDK The community submitted JEP or patch, Before the upstream merger is completed , We want to make  Alibaba  Dragonwell 8 You can use both features ahead of time .

JWarmUp Fast preheating Java application

OpenJDK Used JIT(Just-in-time)  Just in time compilation technology , You can dynamically put Java Highly coded into byte code , Improve execution efficiency , But before compiling ,Java Code is executed in relatively inefficient interpreter mode .

After the application is started 、 The business flow just came in a short time , It's easy to see a lot of Java Methods are beginning to be JIT compile , At the same time, business requests are executed by slower interpreter patterns , The end result is that the system load is skyrocketing , May cause many user requests to time out . To solve this problem , Many of the previous practices were to use simulated traffic to warm up the application in advance ,JWarmUp Features offer a new choice , Is the use Java The previous execution of the virtual machine compiled records to warm up the execution of this application .

JWarmUp The principle is shown in the figure below :

A typical application scenario is when an application needs to release a new version ,

  • First JWarmUp stay Beta Environmental Science ( There's a production environment or something like that ) On a single machine Java application , And record 、 In this period of time JIT Some metadata about what the compiler does .
  • The metadata is then copied to every machine in the production environment that contains the new version of the code / Inside the container .
  • Finally, in the production environment machine through JWarmUp Parameter loading beta Environment generated metadata , The machine that guides the production environment is done in the process of starting the application JIT preheating .

So when the user requests access , The application will be in the peak state of the highest performance .

Collect warm-up data

Also with Tomcat Application, for example , You can add the following command line parameters to beta Collect in the environment JIT Metadata generated at compile time , The parameter  -XX:CompilationWarmUpLogfile=  What is specified is generated JWarmUp Path to file .

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

After it is generated, the file can be passed through OSS、SFTP Transfer to the machine in the production environment .

Use the recorded data to warm up Java application

On machines in the production environment , Just use the following parameters , You can use the previous warm-up data to start a new one Tomcat example , The parameter   -XX:CompilationWarmUpLogfile=  What is made is what needs to be loaded JWarmUp File path , This file should be from the previous step of collecting warm-up data from beta It's copied from the environment .

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 analysis Java application performance

JFR(Java Flight Recorder) yes JVM Built in event based performance analysis features , This is a Oracle JDK7u4 The commercial features that the version begins to offer ,2018 It was in JDK11 Open source this feature on , But it has never been directed at JDK8 Version support .

Alibaba and RedHat、Azul、Amazon Wait for the company to work together and try to port this feature back JDK8 On , But it's time to patch It hasn't been merged back yet OpenJDK8u Warehouse , We are  Alibaba Dragonwell 8 Provided in Alibaba Transplanted JFR edition , It is used to help users get support in advance .

JFR Is very simple to use , Or use command line parameters jcmd Command control HotSpot Output performance data to a file , And then you can use open source jmc The tool opens in a graphical interface 、 Analysis of the generated data file .

Use JFR Collect performance data

stay  Alibaba Dragonwell 8 in , By default JFR Features are off , Command line parameters must be added  -XX:+EnableJFR  To allow the use of JFR characteristic . Alibaba Dragonwell 8 Provides different ways to use JFR Collect performance data .

Applications can be specified with command line arguments JFR After restart, data collection will be started immediately , This will be helpful in diagnosing problems during the startup phase . The following example command will be in Java Process JFR After the module is initialized, the collection begins JFR data , For one minute , And output all the data to the name rec.jfr In the file of .

JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-XX:+EnableJFR -XX:StartFlightRecording=duration=1m,filename=rec.jfr" sh bin/catalina.sh start

Applications can also just add  -XX:+EnableJFR , And then through  jcmd  The command starts to collect data at any time point after the application is started , This situation is more flexible and controllable , It can meet the needs of analysis anytime, anywhere .
With Tomcat For example , start-up Tomcat The order can be :

JAVA_HOME=/path/to/dragonwell8/installation JAVA_OPTS="-XX:+EnableJFR" sh bin/catalina.sh start

When you need to collect data for analysis , Just use the target Tomcat Process PID To execute JFR Corresponding jcmd Command is enough . With Tomcat For example , If you need to start collecting at a given time 10 Second data , So the trigger command is as follows :

$ 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

10 Seconds later, you can see the generation JFR Data files /home/my/workdir/rec3.jfr, Use JMC You can analyze .

You can also not specify the time of data collection , Direct start JFR collect , And manually put all generated data at one time when needed dump To the file ,

$ 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 Analysis performance

JFR Record Java  The output of application performance data is a binary file , We rely on JMC(Java Mission Control) Tools can analyze specific performance data in a graphical interface . This tool is an open source product , Not included in  Alibaba Dragonwell 8 Inside , Need to OpenJDK Download and use the official website of ,https://jdk.java.net/jmc/.

Please note that , Alibaba Dragonwell8 Generated JFR Data files need 7.0 Or later JMC Tools to analyze .

open JMC after , You can click the detailed category on the left to analyze the various events that occurred during the sampling period .

Diagnostic debugging support

 Alibaba Dragonwell 8 There are also some convenient diagnostic features built in , It mainly includes

Large object assignment alarms

It can be done through the new JVM Parameters "-XX:ArrayAllocationWarningSize=", For example, the following code allocates a larger array

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

If you add  ArrayAllocationWarningSize The assigned array will be printed Java Stack

The details of the ParNew GC Log support

 Alibaba Dragonwell 8 Default used CMS (Concurrent Mark Sweep) Algorithm , The new generation used ParNew Algorithm , So built in two for ParNew GC Log enhancement

  • Can pass jinfo Tool settings PrintYoungGenHistoAfterParNewGC The option comes next time Young GC At the end, print the next generation object type histogram . The order is as follows
  •  
jinfo -flag +PrintYoungGenHistoAfterParNewGC <pid>

After printing , This option will be reset back to false state , Prevent too much output , A typical output example is as follows :

  • Can pass -XX:+PrintGCRootsTraceTime To print and process each category GC The details of the root set cost CPU Time , The output example is as follows :

Lite version HeapDump Support

 Alibaba Dragonwell 8 Of jmap The tool supports a new dump Options “mini” You can do it heapdump Skip all the contents of the original type array , This greatly reduces the amount of heapdump file size , This is for the type of screening that only needs to be done 、 Object relationship scenarios are helpful .

The example command is as follows :


Link to the original text
This article is the original content of yunqi community , No reprint without permission .

版权声明
本文为[Aliyun yunqi]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/11/20201112221016663l.html