• Stars
    star
    836
  • Rank 54,534 (Top 2 %)
  • Language
    Java
  • Created over 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Repository for OpenJDK Mission Control, a production time profiling and diagnostics tools suite. https://openjdk.org/projects/jmc

Mission Control

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, see https://www.oracle.com/missioncontrol.

Downloading Builds

Binary distributions of JDK Mission Control are provided by different downstream vendors.

Eclipse Adoptium

  • Released version
  • EA builds of upcoming release
  • Downloadable Eclipse update site archive

https://adoptium.net/jmc

Azul (Zulu Mission Control)

  • Released version

https://www.azul.com/products/zulu-mission-control

Bell-Soft (Liberica Mission Control)

  • Released version

https://bell-sw.com/pages/lmc

Oracle

  • Released version
  • Integrated (in-app) update site
  • Eclipse update site

https://www.oracle.com/java/technologies/jdk-mission-control.html

Red Hat

  • 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 OpenJDK developer builds for Windows.

Mission Control Features

Application Features

  • 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 API Features

  • Core APIs for parsing and processing Java flight recordings

  • Core API can read recordings from JDK 7 and above

  • Core API can run 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

Core API Example

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:

import java.io.File;
 
import org.openjdk.jmc.common.IDisplayable;
import org.openjdk.jmc.common.item.Aggregators;
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.item.ItemFilters;
import org.openjdk.jmc.common.unit.IQuantity;
import org.openjdk.jmc.flightrecorder.JfrAttributes;
import org.openjdk.jmc.flightrecorder.JfrLoaderToolkit;
import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
 
/**
 * Finds out the standard deviation for the java monitor enter events.
 */
public class LoadRecording {
    public static void main(String[] args) throws Exception {         
        IItemCollection events = JfrLoaderToolkit.loadEvents(new File(args[0]));
        IQuantity aggregate = 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:

import java.io.File;
import java.util.concurrent.RunnableFuture;
 
import org.example.util.DemoToolkit;
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.util.IPreferenceValueProvider;
import org.openjdk.jmc.flightrecorder.JfrLoaderToolkit;
import org.openjdk.jmc.flightrecorder.rules.IRule;
import org.openjdk.jmc.flightrecorder.rules.Result;
import org.openjdk.jmc.flightrecorder.rules.RuleRegistry;
 
public class RunRulesOnFileSimple {
    public static void main(String[] args) throws Exception {
        File recording = DemoToolkit.verifyRecordingArgument(RunRulesOnFileSimple.class, args);
        IItemCollection events = JfrLoaderToolkit.loadEvents(recording);
         
        for (IRule rule : RuleRegistry.getRules()) {
            RunnableFuture<Result> future = rule.evaluate(events, IPreferenceValueProvider.DEFAULT_VALUES);
            future.run();
            Result result = 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:

import java.io.File;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.RunnableFuture;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
import org.openjdk.jmc.common.item.IItemCollection;
import org.openjdk.jmc.common.util.IPreferenceValueProvider;
import org.openjdk.jmc.flightrecorder.JfrLoaderToolkit;
import org.openjdk.jmc.flightrecorder.rules.IRule;
import org.openjdk.jmc.flightrecorder.rules.Result;
import org.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.
 */
public class RunRulesOnFile {
    private final static Executor EXECUTOR = Executors
            .newFixedThreadPool(Runtime.getRuntime().availableProcessors() - 1);
    private static int limit;
 
    public static void main(String[] args) throws Exception {
        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);
        }
        IItemCollection events = JfrLoaderToolkit.loadEvents(new File(args[0]));
        if (args.length > 1) {
            limit = Integer.parseInt(args[1]);
        }
        Stream<RunnableFuture<Result>> resultFutures = RuleRegistry.getRules().stream()
                .map((IRule r) -> evaluate(r, events));
        List<Result> results = resultFutures.parallel().map((RunnableFuture<Result> runnable) -> get(runnable))
                .collect(Collectors.toList());
        results.sort((Result r1, Result r2) -> Double.compare(r2.getScore(), r1.getScore()));
        results.stream().forEach(RunRulesOnFile::printResult);
    }
 
    public static RunnableFuture<Result> evaluate(IRule rule, IItemCollection events) {
        RunnableFuture<Result> evaluation = rule.evaluate(events, IPreferenceValueProvider.DEFAULT_VALUES);
        EXECUTOR.execute(evaluation);
        return evaluation;
    }
 
    public static Result get(RunnableFuture<Result> resultFuture) {
        try {
            return resultFuture.get();
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
        return null;
    }
 
    private static void printResult(Result result) {
        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());
        }
    }
}

Building Mission Control from Source

Prerequisites for building Mission Control:

  1. Install a JDK 17 distribution and make sure it is declared in the local maven toolchain ~/.m2/toolchains.xml

  2. Install Maven (version 3.5.x. or above)

On Linux or macOS you can use the build.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:

First get third party dependencies into a local p2 repo and make it available on localhost:

cd missioncontrol-folder # where you just cloned the sources
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 libraries
mvn 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 JDK (here any JDK 17).

~/.m2/toolchains.xml
<?xml version="1.0" encoding="UTF-8"?>
<toolchains>
  <!-- JDK toolchains -->
  <toolchain>
    <type>jdk</type>
    <provides>
      <id>JavaSE-11</id>
      <version>11</version>
      <vendor>amazon</vendor>
    </provides>
    <configuration>
	    <jdkHome>/Library/Java/JavaVirtualMachines/corretto-11.jdk/Contents/Home</jdkHome>
    </configuration>
  </toolchain>

  <!-- 
    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>

Running Tests

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

Filtering Test Runs

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 run StacktraceModelTest, as that is also matched by test.excludes.

Note that if UI-tests are supposed to be part of the filtered run the uitests profile needs to be specified as well. Otherwise the UI won't start up and so the tests fail.

Building using docker and docker-compose

docker-compose -f docker/docker-compose.yml run jmc

Once build has finished the results will be in the target directory

Running the Locally Built JMC

The built JMC will end up in the target folder in the root. The launcher is located in target/products/org.openjdk.jmc/<platform>. By default whichever JRE is on the path will 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 JVM to 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 x86_64
target/products/org.openjdk.jmc/macosx/cocoa/x86_64/JDK\ Mission\ Control.app/Contents/MacOS/jmc

# on M1
target/products/org.openjdk.jmc/macosx/cocoa/aarch64/JDK\ Mission\ Control.app/Contents/MacOS/jmc

Here is an example for Linux:

target/products/org.openjdk.jmc/linux/gtk/x86_64/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"

Using the Built JMC Update Site in Eclipse

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.0.0-SNAPSHOT.zip

Setting up Development Environment

Please follow the Developer Guide.

FAQ

For help with frequently asked questions, see the JMC FAQ on the JMC Wiki.

License

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.

About

Mission Control is an open source project of the OpenJDK. The Mission Control project originated from the JRockit JVM project.

More Repositories

1

jdk

JDK main-line development https://openjdk.org/projects/jdk
Java
17,577
star
2

jfx

JavaFX mainline development
C++
2,700
star
3

loom

https://openjdk.org/projects/loom
Java
1,873
star
4

jmh

https://openjdk.org/projects/code-tools/jmh
Java
1,857
star
5

jol

https://openjdk.org/projects/code-tools/jol
Java
810
star
6

valhalla

https://openjdk.org/projects/valhalla
Java
538
star
7

nashorn

https://openjdk.org/projects/nashorn
Java
399
star
8

jcstress

https://openjdk.org/projects/code-tools/jcstress
Java
368
star
9

panama-foreign

https://openjdk.org/projects/panama
Java
291
star
10

jextract

https://openjdk.org/projects/code-tools
Java
237
star
11

skara

https://openjdk.org/projects/skara
Java
203
star
12

jdk8u

https://wiki.openjdk.org/display/jdk8u
Java
187
star
13

wakefield

https://openjdk.org/projects/wakefield
Java
186
star
14

amber

https://openjdk.org/projects/amber
Java
181
star
15

crac

https://openjdk.org/projects/crac
Java
175
star
16

jdk17

https://openjdk.org/projects/jdk/17 released 2021-09-14
Java
164
star
17

zgc

The Z Garbage Collector https://wiki.openjdk.org/display/zgc
Java
164
star
18

amber-docs

https://openjdk.org/projects/amber
HTML
144
star
19

mobile

https://openjdk.org/projects/mobile
Java
134
star
20

jdk11u

https://openjdk.org/projects/jdk-updates
Java
130
star
21

shenandoah

https://openjdk.org/projects/shenandoah
Java
117
star
22

leyden

https://openjdk.org/projects/leyden
Java
97
star
23

panama-vector

https://openjdk.org/projects/panama
Java
82
star
24

shenandoah-visualizer

https://openjdk.org/projects/shenandoah
Java
78
star
25

jdk17u

https://wiki.openjdk.org/display/JDKUpdates/JDK+17u
Java
76
star
26

aarch64-port

Port: AArch64 Project
Java
71
star
27

babylon

https://openjdk.org/projects/babylon
Java
69
star
28

asmtools

https://wiki.openjdk.org/display/CodeTools/asmtools
Java
66
star
29

jdk21

https://openjdk.org/projects/jdk/21 released 2023-09-19
Java
65
star
30

valhalla-docs

https://openjdk.org/projects/valhalla
CSS
59
star
31

jdk-sandbox

JDK Committers Sandbox
Java
59
star
32

guide

OpenJDK Developers' Guide https://openjdk.org/guide
Makefile
58
star
33

jdk16

https://openjdk.org/projects/jdk/16 released 2021-03-16
Java
57
star
34

jtreg

https://openjdk.org/projects/code-tools/jtreg
Java
56
star
35

jdk11u-dev

https://openjdk.org/projects/jdk-updates
Java
54
star
36

lilliput

https://openjdk.org/projects/lilliput
Java
50
star
37

riscv-port

https://openjdk.org/projects/riscv-port
Java
46
star
38

jdk8

https://openjdk.org/projects/jdk8 released 2014-03-18
Java
40
star
39

jdk8u-dev

https://wiki.openjdk.org/display/jdk8u
Java
40
star
40

jdk15

https://openjdk.org/projects/jdk/15 released 2020-09-15
Java
39
star
41

jdk19

https://openjdk.org/projects/jdk/19 released 2022-09-20
Java
39
star
42

jmh-jdk-microbenchmarks

https://openjdk.org/projects/code-tools/jmh-jdk-microbenchmarks
Java
38
star
43

jdk17u-dev

https://openjdk.org/projects/jdk-updates
Java
32
star
44

jdk13

https://openjdk.org/projects/jdk/13 released 2019-09-17
Java
32
star
45

jdk21u

https://openjdk.org/projects/jdk-updates
Java
30
star
46

jdk16u

https://openjdk.org/projects/jdk-updates last released 2021-07-20
Java
26
star
47

lanai

https://openjdk.org/projects/lanai
Java
26
star
48

tsan

https://openjdk.org/projects/tsan
Java
25
star
49

portola

https://openjdk.org/projects/portola
Java
24
star
50

jdk18

https://openjdk.org/projects/jdk/18 released 2022-03-22
Java
23
star
51

duke

https://openjdk.org/projects/duke
Mathematica
21
star
52

jdk19u

https://openjdk.org/projects/jdk-updates last released 2023-01-17
Java
20
star
53

jdk11

https://openjdk.org/projects/jdk/11 released 2018-09-25
20
star
54

jdk20

https://openjdk.org/projects/jdk/20 released 2023-03-21
Java
20
star
55

jdk13u-dev

https://openjdk.org/projects/jdk-updates development (identical to jdk13u)
Java
17
star
56

jcov

https://wiki.openjdk.org/display/CodeTools/jcov
Java
17
star
57

jdk14u

https://openjdk.org/projects/jdk-updates last released 2020-07-14
Java
16
star
58

jdk12u

https://openjdk.org/projects/jdk-updates last released 2019-07-16
Java
16
star
59

metropolis

https://openjdk.org/projects/metropolis
Java
16
star
60

jdk20u

https://openjdk.org/projects/jdk-updates last released 2023-07-18
Java
15
star
61

jdk14

https://openjdk.org/projects/jdk/14 released 2020-03-17
Java
15
star
62

galahad

https://openjdk.org/projects/galahad
Java
15
star
63

jfx-sandbox

OpenJFX Committers Sandbox
C++
14
star
64

jdk6

https://openjdk.org/projects/jdk6
Java
14
star
65

jtharness

https://wiki.openjdk.org/display/CodeTools/JT+Harness
Java
13
star
66

jdk7u

https://wiki.openjdk.org/display/jdk7u last released 2022-07-19
Java
12
star
67

jfx11u

JavaFX 11 updates development
C++
12
star
68

jmc7

https://openjdk.org/projects/jmc
Java
12
star
69

jdk15u

https://wiki.openjdk.org/display/JDKUpdates/JDK+15u last released 2023-01-18
Java
11
star
70

jemmy-v2

UI test automation library - v2
Java
11
star
71

jfx20u

JavaFX 20.x: last released 2023-07-18
C++
10
star
72

jdk7

https://openjdk.org/projects/jdk7 released 2011-07-28
Java
10
star
73

jdk12

https://openjdk.org/projects/jdk/12 released 2019-03-19
8
star
74

webrevs

Automatically generated JSON files for webrevs
8
star
75

jdk15u-dev

https://openjdk.org/projects/jdk-updates development (identical to jdk15u)
Java
8
star
76

jfx21u

JavaFX 21 updates development
C++
7
star
77

jdk13u

https://wiki.openjdk.org/display/JDKUpdates/JDK+13u last released 2023-01-18
Java
7
star
78

client

JDK 16 era Client Libraries development
Java
7
star
79

jfx17u

JavaFX 17 updates development
C++
6
star
80

jdk18u

https://openjdk.org/projects/jdk-updates last released 2022-08-18
Java
6
star
81

playground

Repository for experimenting. May be synced and/or reset at any time without notice.
Java
6
star
82

lilliput-jdk17u

https://openjdk.org/projects/lilliput
Java
6
star
83

cr

https://openjdk.org/projects/skara
HTML
6
star
84

jdk22

https://openjdk.org/projects/jdk/22
Java
6
star
85

riscv-port-jdk17u

https://openjdk.org/projects/riscv-port
Java
6
star
86

sigtest

https://wiki.openjdk.org/display/CodeTools/sigtest
Java
5
star
87

shenandoah-jdk8u

https://openjdk.org/projects/shenandoah
Java
5
star
88

friday-stats

https://openjdk.org/projects/code-tools/friday-stats
Java
4
star
89

jdk9

https://openjdk.org/projects/jdk9 released 2017-09-21
Java
4
star
90

aarch32-port-jdk8u

https://openjdk.org/projects/aarch32-port
Java
4
star
91

jdk11u-ri

JSR 384 Reference Implementation (Java SE 11) [not for production use]
Java
4
star
92

jdk9u

https://openjdk.org/projects/jdk-updates last released 2018-01-16
Java
3
star
93

jfx12

JavaFX 12.x : last released 2019-07-19
C++
3
star
94

jfx13

JavaFX 13.x : last released 2020-01-15
C++
3
star
95

jmc-graphics

https://openjdk.org/projects/jmc
3
star
96

jdk10u

https://openjdk.org/projects/jdk-updates last released 2018-07-17
3
star
97

jemmy-v3

UI test automation library - v3
Java
2
star
98

webrev

https://openjdk.org/projects/code-tools/webrev
Shell
2
star
99

riscv-port-jdk11u

https://openjdk.org/projects/riscv-port
Java
2
star
100

lilliput-jdk21u

https://openjdk.org/projects/lilliput
Java
2
star