Skip to content

Commit

Permalink
8306703: JFR: Summary views
Browse files Browse the repository at this point in the history
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed May 25, 2023
1 parent 534de6d commit 98acce1
Show file tree
Hide file tree
Showing 64 changed files with 7,651 additions and 71 deletions.
4 changes: 2 additions & 2 deletions make/modules/jdk.jfr/Java.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,5 +24,5 @@
#

DISABLED_WARNINGS_java += exports
COPY := .xsd .xml .dtd
COPY := .xsd .xml .dtd .ini
JAVAC_FLAGS := -XDstringConcat=inline
5 changes: 4 additions & 1 deletion src/hotspot/share/jfr/dcmd/jfrDcmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ bool register_jfr_dcmds() {
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrDumpFlightRecordingDCmd>(full_export, true, false));
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrStartFlightRecordingDCmd>(full_export, true, false));
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrStopFlightRecordingDCmd>(full_export, true, false));
// JFR.query Uncomment when developing new queries for the JFR.view command
// DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrQueryFlightRecordingDCmd>(full_export, true, true));
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrViewFlightRecordingDCmd>(full_export, true, false));
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JfrConfigureFlightRecorderDCmd>(full_export, true, false));
return true;
}
Expand Down Expand Up @@ -318,7 +321,7 @@ static DCmdArgumentInfo* create_info(oop argument, TRAPS) {
read_string_field(argument, "type", THREAD),
read_string_field(argument, "defaultValue", THREAD),
read_boolean_field(argument, "mandatory", THREAD),
true, // a DcmdFramework "option"
read_boolean_field(argument, "option", THREAD),
read_boolean_field(argument, "allowMultiple", THREAD));
}

Expand Down
50 changes: 50 additions & 0 deletions src/hotspot/share/jfr/dcmd/jfrDcmds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,56 @@ class JfrStopFlightRecordingDCmd : public JfrDCmd {
}
};

class JfrViewFlightRecordingDCmd : public JfrDCmd {
public:
JfrViewFlightRecordingDCmd(outputStream* output, bool heap) : JfrDCmd(output, heap, num_arguments()) {}

static const char* name() {
return "JFR.view";
}
static const char* description() {
return "Display event data in predefined views";
}
static const char* impact() {
return "Medium";
}
static const JavaPermission permission() {
JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
return p;
}
virtual const char* javaClass() const {
return "jdk/jfr/internal/dcmd/DCmdView";
}
static int num_arguments() {
return 7;
}
};

class JfrQueryFlightRecordingDCmd : public JfrDCmd {
public:
JfrQueryFlightRecordingDCmd(outputStream* output, bool heap) : JfrDCmd(output, heap, num_arguments()) {}

static const char* name() {
return "JFR.query";
}
static const char* description() {
return "Query and display event data in a tabular form";
}
static const char* impact() {
return "Medium";
}
static const JavaPermission permission() {
JavaPermission p = {"java.lang.management.ManagementPermission", "monitor", NULL};
return p;
}
virtual const char* javaClass() const {
return "jdk/jfr/internal/dcmd/DCmdQuery";
}
static int num_arguments() {
return 5;
}
};

class JfrConfigureFlightRecorderDCmd : public DCmdWithParser {
friend class JfrOptionSet;
protected:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -79,7 +79,7 @@ public static void emit(List<PlatformRecording> recordings, Boolean pathToGcRoot
}
}

private static void emit(long ticks) {
public static void emit(long ticks) {
boolean emitAll = WhiteBox.getWriteAllObjectSamples();
boolean skipBFS = WhiteBox.getSkipBFS();
JVM.getJVM().emitOldObjectSamples(ticks, emitAll, skipBFS);
Expand Down
12 changes: 9 additions & 3 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -420,7 +420,7 @@ private List<PlatformRecording> getRunningRecordings() {
return runningRecordings;
}

private List<RepositoryChunk> makeChunkList(Instant startTime, Instant endTime) {
public List<RepositoryChunk> makeChunkList(Instant startTime, Instant endTime) {
Set<RepositoryChunk> chunkSet = new HashSet<>();
for (PlatformRecording r : getRecordings()) {
chunkSet.addAll(r.getChunks());
Expand All @@ -438,7 +438,7 @@ private List<RepositoryChunk> makeChunkList(Instant startTime, Instant endTime)
return chunks;
}

return Collections.emptyList();
return new ArrayList<>();
}

private void startDiskMonitor() {
Expand All @@ -454,6 +454,8 @@ private void finishChunk(RepositoryChunk chunk, Instant time, PlatformRecording
r.appendChunk(chunk);
}
}
// Decrease initial reference count
chunk.release();
FilePurger.purge();
}

Expand Down Expand Up @@ -659,4 +661,8 @@ public synchronized void migrate(SafePath repo) throws IOException {
rotateDisk();
}
}

public RepositoryChunk getCurrentChunk() {
return currentChunk;
}
}
14 changes: 11 additions & 3 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,7 +33,7 @@

import jdk.jfr.internal.SecuritySupport.SafePath;

final class RepositoryChunk {
public final class RepositoryChunk {

static final Comparator<RepositoryChunk> END_TIME_COMPARATOR = new Comparator<RepositoryChunk>() {
@Override
Expand All @@ -47,7 +47,7 @@ public int compare(RepositoryChunk c1, RepositoryChunk c2) {

private Instant endTime = null; // unfinished
private Instant startTime;
private int refCount = 0;
private int refCount = 1;
private long size;

RepositoryChunk(SafePath path) throws Exception {
Expand Down Expand Up @@ -166,4 +166,12 @@ public boolean inInterval(Instant startTime, Instant endTime) {
public SafePath getFile() {
return chunkFile;
}

public long getCurrentFileSize() {
try {
return SecuritySupport.getFileSize(chunkFile);
} catch (IOException e) {
return 0L;
}
}
}
11 changes: 10 additions & 1 deletion src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -55,6 +55,7 @@

import jdk.internal.module.Checks;
import jdk.jfr.Event;
import jdk.jfr.EventType;
import jdk.jfr.FlightRecorderPermission;
import jdk.jfr.Recording;
import jdk.jfr.RecordingState;
Expand Down Expand Up @@ -859,4 +860,12 @@ private static void awaitUniqueTimestamp() {
}
}
}

public static String makeSimpleName(EventType type) {
return makeSimpleName(type.getName());
}

public static String makeSimpleName(String qualified) {
return qualified.substring(qualified.lastIndexOf(".") + 1);
}
}
31 changes: 19 additions & 12 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/AbstractDCmd.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -38,6 +38,8 @@
import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
import jdk.jfr.internal.JVM;
import jdk.jfr.internal.util.Output.LinePrinter;
import jdk.jfr.internal.util.Output;
import jdk.jfr.internal.LogLevel;
import jdk.jfr.internal.LogTag;
import jdk.jfr.internal.Logger;
Expand All @@ -50,9 +52,7 @@
*
*/
abstract class AbstractDCmd {

private final StringBuilder currentLine = new StringBuilder(80);
private final List<String> lines = new ArrayList<>();
private final LinePrinter output = new LinePrinter();
private String source;

// Called by native
Expand Down Expand Up @@ -91,16 +91,19 @@ public final String[] execute(String source, String arg, char delimiter) throws
DCmdException e = new DCmdException(iae.getMessage());
e.addSuppressed(iae);
throw e;
}
}
}

protected final Output getOutput() {
return output;
}

protected final FlightRecorder getFlightRecorder() {
return FlightRecorder.getFlightRecorder();
}

protected final String[] getResult() {
return lines.toArray(new String[lines.size()]);
return output.getLines().toArray(new String[0]);
}

protected void logWarning(String message) {
Expand Down Expand Up @@ -181,21 +184,19 @@ static String quoteIfNeeded(String text) {
}

protected final void println() {
lines.add(currentLine.toString());
currentLine.setLength(0);
output.println();
}

protected final void print(String s) {
currentLine.append(s);
output.print(s);
}

protected final void print(String s, Object... args) {
currentLine.append(args.length > 0 ? String.format(s, args) : s);
output.print(s, args);
}

protected final void println(String s, Object... args) {
print(s, args);
println();
output.println(s, args);
}

protected final void printBytes(long bytes) {
Expand All @@ -218,6 +219,12 @@ protected final void printPath(SafePath path) {
}
}

protected final void printHelpText() {
for (String line : printHelp()) {
println(line);
}
}

protected final void printPath(Path path) {
try {
println(path.toAbsolutePath().toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,6 +29,7 @@ record Argument(
String description,
String type,
boolean mandatory,
boolean option,
String defaultValue,
boolean allowMultiple
) { }

1 comment on commit 98acce1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.