- Notifications
You must be signed in to change notification settings - Fork176
Repository for OpenJDK Mission Control, a production time profiling and diagnostics tools suite.https://openjdk.org/projects/jmc
openjdk/jmc
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Mission Control is an open source production time profiling and diagnostics tool for Java.
Builds of Mission Control can currently be found in the Oracle JDK on supported platforms and in the Eclipse marketplace.
For more information on Mission Control, seehttps://www.oracle.com/missioncontrol.
Binary distributions of JDK Mission Control are provided by different downstream vendors.
- Released version
- EA builds of upcoming release
- Downloadable Eclipse update site archive
- Released version
https://www.azul.com/products/zulu-mission-control
- Released version
- Released version
- Integrated (in-app) update site
- Eclipse update site
https://www.oracle.com/java/technologies/jdk-mission-control.html
- Released version
Red Hat distributes JDK Mission Control in Red Hat Enterprise Linux (RHEL). JMC is available in RHEL 7 as the rh-jmc Software Collection, and is provided in RHEL 8 by the jmc:rhel8 module stream. JMC is also included in the OpenJDKdeveloper builds for Windows.
A framework for hosting various useful Java tools
A tool for visualizing the contents of Java flight recordings, and the results of an automated analysis of the contents
A JMX Console
A tool for heap waste analysis
Core APIs for parsing and processing Java flight recordings
Core API canread recordings from JDK 7 and above
Core API canrun on JDK 8 and above
Core API contains a framework for handling units of measurement and physical quantities
Core API supports headless analysis of Java flight recordings
Example for producing an HTML report from the command line:
java -cp<the built core jars> org.openjdk.jmc.flightrecorder.rules.report.html.JfrHtmlRulesReport<file> [<outputfile>]
Example for finding the standard deviation for the java monitor events in a recording:
importjava.io.File;importorg.openjdk.jmc.common.IDisplayable;importorg.openjdk.jmc.common.item.Aggregators;importorg.openjdk.jmc.common.item.IItemCollection;importorg.openjdk.jmc.common.item.ItemFilters;importorg.openjdk.jmc.common.unit.IQuantity;importorg.openjdk.jmc.flightrecorder.JfrAttributes;importorg.openjdk.jmc.flightrecorder.JfrLoaderToolkit;importorg.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;/** * Finds out the standard deviation for the java monitor enter events. */publicclassLoadRecording {publicstaticvoidmain(String[]args)throwsException {IItemCollectionevents =JfrLoaderToolkit.loadEvents(newFile(args[0]));IQuantityaggregate =events.apply(ItemFilters.type(JdkTypeIDs.MONITOR_ENTER)) .getAggregate(Aggregators.stddev(JfrAttributes.DURATION));System.out.println("The standard deviation for the Java monitor enter events was " +aggregate.displayUsing(IDisplayable.AUTO)); }}
Example for programmatically running the rules:
importjava.io.File;importjava.util.concurrent.RunnableFuture;importorg.example.util.DemoToolkit;importorg.openjdk.jmc.common.item.IItemCollection;importorg.openjdk.jmc.common.util.IPreferenceValueProvider;importorg.openjdk.jmc.flightrecorder.JfrLoaderToolkit;importorg.openjdk.jmc.flightrecorder.rules.IRule;importorg.openjdk.jmc.flightrecorder.rules.Result;importorg.openjdk.jmc.flightrecorder.rules.RuleRegistry;publicclassRunRulesOnFileSimple {publicstaticvoidmain(String[]args)throwsException {Filerecording =DemoToolkit.verifyRecordingArgument(RunRulesOnFileSimple.class,args);IItemCollectionevents =JfrLoaderToolkit.loadEvents(recording);for (IRulerule :RuleRegistry.getRules()) {RunnableFuture<Result>future =rule.evaluate(events,IPreferenceValueProvider.DEFAULT_VALUES);future.run();Resultresult =future.get();if (result.getScore() >50) {System.out.println(String.format("[Score: %3.0f] Rule ID: %s, Rule name: %s, Short description: %s",result.getScore(),result.getRule().getId(),result.getRule().getName(),result.getShortDescription())); } } }}
Example for programmatically running rules in parallel:
importjava.io.File;importjava.util.List;importjava.util.concurrent.ExecutionException;importjava.util.concurrent.Executor;importjava.util.concurrent.Executors;importjava.util.concurrent.RunnableFuture;importjava.util.stream.Collectors;importjava.util.stream.Stream;importorg.openjdk.jmc.common.item.IItemCollection;importorg.openjdk.jmc.common.util.IPreferenceValueProvider;importorg.openjdk.jmc.flightrecorder.JfrLoaderToolkit;importorg.openjdk.jmc.flightrecorder.rules.IRule;importorg.openjdk.jmc.flightrecorder.rules.Result;importorg.openjdk.jmc.flightrecorder.rules.RuleRegistry;/** * Runs the rules on the events in the specified file in parallel, then prints * them in order of descending score. */publicclassRunRulesOnFile {privatefinalstaticExecutorEXECUTOR =Executors .newFixedThreadPool(Runtime.getRuntime().availableProcessors() -1);privatestaticintlimit;publicstaticvoidmain(String[]args)throwsException {if (args.length ==0) {System.out.println("Usage: RunRulesOnFile <recording file> [<limit>]\n\tThe recording file must be a flight recording from JDK 7 or above. The limit, if set, will only report rules triggered with a score higher or equal than the limit.");System.exit(2); }IItemCollectionevents =JfrLoaderToolkit.loadEvents(newFile(args[0]));if (args.length >1) {limit =Integer.parseInt(args[1]); }Stream<RunnableFuture<Result>>resultFutures =RuleRegistry.getRules().stream() .map((IRuler) ->evaluate(r,events));List<Result>results =resultFutures.parallel().map((RunnableFuture<Result>runnable) ->get(runnable)) .collect(Collectors.toList());results.sort((Resultr1,Resultr2) ->Double.compare(r2.getScore(),r1.getScore()));results.stream().forEach(RunRulesOnFile::printResult); }publicstaticRunnableFuture<Result>evaluate(IRulerule,IItemCollectionevents) {RunnableFuture<Result>evaluation =rule.evaluate(events,IPreferenceValueProvider.DEFAULT_VALUES);EXECUTOR.execute(evaluation);returnevaluation; }publicstaticResultget(RunnableFuture<Result>resultFuture) {try {returnresultFuture.get(); }catch (InterruptedException |ExecutionExceptione) {e.printStackTrace(); }returnnull; }privatestaticvoidprintResult(Resultresult) {if (result.getScore() >=limit) {System.out.printf("(%.0f) [%s]: %s\nDetails:\n%s\n============<End of Result>============\n",result.getScore(),result.getRule().getId(),result.getShortDescription(),result.getLongDescription() ==null ?"<no description>" :result.getLongDescription()); } }}
Prerequisites for building Mission Control:
Install a JDK 17 distribution and make sure it is declared in the local maven toolchain
~/.m2/toolchains.xml
Install a JDK 21 distribution and make sure that it too is declared in the local maven toolchain.
Install Maven (version 3.5.x. or above)
On Linux or macOS you can use thebuild.sh
script to build JMC:
usage: call ./build.sh with the following options: --installCore to install the core artifacts --test to run the tests --testUi to run the tests including UI tests --packageJmc to package JMC --clean to run maven clean
Otherwise follow the steps manually.
Here are the individual steps:
Get the third-party dependencies into a localp2 repo and make it available on localhost.
Build and install the core libraries.
Build the JMC application.
First, if on Mac / Linux:
mvn p2:site --file releng/third-party/pom.xml; mvn jetty:run --file releng/third-party/pom.xml
Or, if on Windows:
mvn p2:site --file releng\third-party\pom.xml&& mvn jetty:run --file releng\third-party\pom.xml
Then in another terminal (in the project root):
mvn clean install --file core/pom.xml# Install JMC's flight recorder librariesmvn package# Package JMC
If maven reports a toolchain error, e.g. :
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-toolchains-plugin:3.0.0:toolchain (default) on project missioncontrol: Cannot find matching toolchain definitions for the following toolchain types:[ERROR] jdk [ version='17' ][ERROR] Please make sure you define the required toolchains in your ~/.m2/toolchains.xml file.
Create or amend the local maven toolchain file by pointing to the right/any JDK 17.
~/.m2/toolchains.xml
<?xml version="1.0" encoding="UTF-8"?><toolchains><!-- JDK toolchains--><!-- Declare the JDK 17 toolchain installed on the local machine, make sure the id is : JavaSE-17 Tycho needs this to find the right _execution environment_.--> <toolchain> <type>jdk</type> <provides> <id>JavaSE-17</id> <version>17</version> <vendor>amazon</vendor> </provides> <configuration> <jdkHome>/Users/brice.dutheil/.asdf/installs/java/corretto-17.0.7.7.1</jdkHome> </configuration> </toolchain></toolchains>
Note that you may need to define proxy settings if you happen to be behind a firewall. In your~/.m2/settings.xml
file (if you have none, simply create one), add:
<settings> <proxies> <proxy> <id>http-proxy</id> <active>true</active> <protocol>http</protocol> <host>my.proxy.example.org</host> <port>80</port> <nonProxyHosts>localhost|*.example.org</nonProxyHosts> </proxy> <proxy> <id>https-proxy</id> <active>true</active> <protocol>https</protocol> <host>my.proxy.example.org</host> <port>80</port> <nonProxyHosts>localhost|*.example.org</nonProxyHosts> </proxy> </proxies></settings>
To run the unit tests:
mvn verify
To run the UI tests:
mvn verify -P uitests
Note that the UI tests will take some time to run, and that you need to stop interacting with your computer for the duration of the tests.
Spotbugs can take some time to run. If you are only interested in the test results, you can skip running spotbugs by setting-Dspotbugs.skip=true
.
For example:
mvn verify -P uitests -Dspotbugs.skip=true
Aside from the from the simple -test Maven flag test classes that should be run/not run can be specified by means of the system properties "test.includes" and/or "test.excludes". Multiple patterns can be specified by comma separation.
For example:
mvn verify -Dtest.includes=**/*TestRulesWithJfr*,**/*StacktraceModelTest*
When specifying both test.includes and "test.excludes" the test.excludes takes precedence and filters out tests that also are matched by "test.includes".
For example:
mvn verify -P uitests -Dtest.includes=**/*SystemTabTest*,**/*TestRulesWithJfr*,**/*StacktraceModelTest* -Dtest.excludes=**/*ModelTest*
The above will not runStacktraceModelTest
, as that is also matched bytest.excludes
.
Note that if UI-tests are supposed to be part of the filtered run theuitests
profile needs to be specified as well. Otherwise the UI won't start up and so the tests fail.
docker-compose -f docker/docker-compose.yml run jmc
Once build has finished the results will be in thetarget
directory
The built JMC will end up in thetarget
folder in the root. The launcher is located intarget/products/org.openjdk.jmc/<platform>
. By default whichever JRE is on the pathwill be used. Remember to set it to a JDK (rather than a JRE) if you want the launched mission control to automatically discover locally running JVMs. To override which JVMto use when launching, add-vm
and the path to a directory where a JDK java launcher is located, for example-vm $JAVA_HOME/bin
.
Here is an example for Mac OS X:
# on aarch64 (M1/M2/M3/M4)target/products/org.openjdk.jmc/macosx/cocoa/aarch64/JDK\Mission\Control.app/Contents/MacOS/jmc# on x86_64 (Intel)target/products/org.openjdk.jmc/macosx/cocoa/x86_64/JDK\Mission\Control.app/Contents/MacOS/jmc
Here is an example for Linux:
# on x86_64target/products/org.openjdk.jmc/linux/gtk/x86_64/JDK\Mission\Control/jmc# on aarch64target/products/org.openjdk.jmc/linux/gtk/aarch64/JDK\Mission\Control/jmc
And here is an example for Windows x64:
"target\products\org.openjdk.jmc\win32\win32\x86_64\JDK Mission Control\jmc"
As part of the JMC build, the JMC update sites will be built.
There is one update site for the stand-alone RCP application, providing plug-ins for the stand-alone release of JMC:
application/org.openjdk.jmc.updatesite.rcp/target/
There is another update site for the Eclipse plug-ins, providing plug-ins for running JMC inside of Eclipse:
application/org.openjdk.jmc.updatesite.ide/target/
To install it into Eclipe, simply open Eclipse and select Help | Install New Software... In the dialog, click Add... and then click the Archive... button. Select the built update site, e.g.
application/org.openjdk.jmc.updatesite.ide/target/org.openjdk.jmc.updatesite.ide-9.1.0-SNAPSHOT.zip
Please follow theDeveloper Guide.
For help with frequently asked questions, see theJMC FAQ on the JMC Wiki.
The Mission Control source code is made available under the Universal Permissive License (UPL), Version 1.0 or a BSD-style license, alternatively. The full open source license text is available at license/LICENSE.txt in the JMC project.
Mission Control is an open source project of theOpenJDK.The Mission Control project originated from the JRockit JVM project.
About
Repository for OpenJDK Mission Control, a production time profiling and diagnostics tools suite.https://openjdk.org/projects/jmc