-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8356870: HotSpotDiagnosticMXBean.dumpThreads and jcmd Thread.dump_to_file updates #25429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pr/25425
Are you sure you want to change the base?
Conversation
👋 Welcome back alanb! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@AlanBateman The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
/label remove hotspot |
@AlanBateman |
@AlanBateman |
@AlanBateman |
Webrevs
|
src/java.base/share/classes/jdk/internal/vm/ThreadSnapshot.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/jdk/internal/vm/ThreadSnapshot.java
Outdated
Show resolved
Hide resolved
* text or JSON format. | ||
* This class defines static methods to support the Thread.dump_to_file diagnostic command | ||
* and the HotSpotDiagnosticMXBean.dumpThreads API. It defines methods to generate a | ||
* thread dump to a file or byte array in plain text or JSON format. | ||
*/ | ||
public class ThreadDumper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class ThreadDumper { | |
public final class ThreadDumper { |
sb.append(String.format("\\u%04x", c)); | ||
} else { | ||
sb.append(c); | ||
private static class JsonWriter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static class JsonWriter { | |
private static final class JsonWriter { | |
private static final class Node { |
StringBuffer sb = new StringBuffer(); | ||
sb.append(System.currentTimeMillis()); | ||
String s = sb.toString(); | ||
ref.set(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringBuffer sb = new StringBuffer(); | |
sb.append(System.currentTimeMillis()); | |
String s = sb.toString(); | |
ref.set(s); | |
ref.set( | |
new StringBuffer() | |
.append(System.currentTimeMillis()) | |
.toString()); |
sb.append(","); | ||
sb.append(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sb.append(","); | |
sb.append(name); | |
sb.append(",") | |
.append(name); |
src/java.base/share/classes/jdk/internal/vm/ThreadSnapshot.java
Outdated
Show resolved
Hide resolved
Instant now = Instant.now(); | ||
Thread.State state = snapshot.threadState(); | ||
writer.println("#" + thread.threadId() + " \"" + snapshot.threadName() | ||
+ "\" " + (thread.isVirtual() ? "virtual " : "") + state + " " + now); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ "\" " + (thread.isVirtual() ? "virtual " : "") + state + " " + now); | |
+ "\" " + (thread.isVirtual() ? "virtual " : "") + state + " " + now); |
Updates the thread dump generated by HotSpotDiagnosticMXBean.dumpThreads and jcmd Thread.dump_to_file to include thread state and lock information. Also update the HotSpotDiagnosticMXBean.dumpThreads API description to link to a description of the JSON format dump as that format is intended to be parseable/read by tools.
This PR is dependent on pull/25425. As noted in that PR, the changes accumulated in the loom repo, and have been split up to make it easier to review.
The changes include some re-implementation of ThreadDumper. This is because it used PrintStream and didn't fail if there was an I/O error, e.g. file system full. Furthermore, the indentation to pretty print the json was fragile and hard to maintain so this is changed to use a supporting writer class to do this.
Test coverage is significantly expanded, including updating the test library that is used by several tests to parse the thread dump.
Testing: tier1-6
Progress
Integration blocker
Issues
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25429/head:pull/25429
$ git checkout pull/25429
Update a local copy of the PR:
$ git checkout pull/25429
$ git pull https://git.openjdk.org/jdk.git pull/25429/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25429
View PR using the GUI difftool:
$ git pr show -t 25429
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25429.diff
Using Webrev
Link to Webrev Comment