Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
169 lines (134 loc) · 6.5 KB
/
Copy pathindex.html
File metadata and controls
169 lines (134 loc) · 6.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="google-site-verification" content="vowmorgCRTJklhsU5gPBzJ6d6pYz52mnuHjOQ6JR-Yk" />
<meta charset="utf-8">
<meta name="viewport" content="width=720">
<title>Java Thread Dump Inspector</title>
<meta name="description" content="Reads Java thread dumps — jstack text or jcmd JSON — in the browser and points at what is wrong: saturated pools, lock contention, deadlocks.">
</head>
<body bgcolor="#E0E0E0" text="#000000" link="#0000EE" vlink="#551A8B">
<!-- Outer table is the hairline border: 1px of grey showing around the white one. -->
<table width="680" align="center" cellpadding="1" cellspacing="0" bgcolor="#999999">
<tr><td>
<table width="100%" cellpadding="22" cellspacing="0" bgcolor="#FFFFFF">
<tr><td>
<h1>Java Thread Dump Inspector</h1>
<p>Reads Java thread dumps — text or JSON — and points at what is wrong.<br>
One HTML file. Runs in your browser.</p>
<p>A service stops responding, a pool takes no new work, two threads deadlock. You take a thread
dump and get thousands of lines. This reads them: which pools are saturated, who holds the lock
everyone is waiting on, where the threads pile up.</p>
<p><font size="+3"><b>[ <a href="thread-inspector.html">Open the inspector</a> ]</b></font></p>
<p>No dump at hand? A sample one is built in — open it and look around.</p>
<table border="1" cellpadding="4" cellspacing="0">
<tr>
<th bgcolor="#CCCCCC">Before using it</th>
<th bgcolor="#CCCCCC">After using it</th>
</tr>
<tr>
<td><img src="media/before.png" alt="A developer at night, head in hands, a raw thread dump on
the screen" width="300" height="302"></td>
<td><img src="media/after.png" alt="The same developer with the inspector open, reporting no
deadlocks" width="300" height="302"></td>
</tr>
</table>
<hr>
<h2>The dump never leaves your machine</h2>
<p>Parsed in the browser. No upload, no backend, no analytics, no external request —
not even a font. Save the page and it works offline.</p>
<hr>
<h2>Which dumps it reads</h2>
<table border="1" cellpadding="4" cellspacing="0">
<tr>
<th bgcolor="#CCCCCC">Taken with</th>
<th bgcolor="#CCCCCC">JDK 8, 17</th>
<th bgcolor="#CCCCCC">JDK 21</th>
<th bgcolor="#CCCCCC">JDK 25–28</th>
</tr>
<tr>
<td><tt>jstack</tt> / <tt>jcmd Thread.print</tt></td>
<td>yes</td><td>yes</td><td>yes</td>
</tr>
<tr>
<td><tt>jcmd Thread.dump_to_file -format=json</tt></td>
<td>no such command</td><td>yes, no states in that format</td><td>yes, full data</td>
</tr>
<tr>
<td><tt>jcmd Thread.dump_to_file -format=plain</tt></td>
<td>no such command</td><td colspan="2">recognised, asks you to re-take as json</td>
</tr>
</table>
<p>Tested on Temurin 17, 21, 25 and 26, Liberica 8, JetBrains Runtime 25, and OpenJDK
early-access 27 and 28.</p>
<p><b>jstack cannot see virtual threads</b> — on any JDK from 21 to 28. Against an
application built on them it shows the carrier threads and nothing of what runs on them. That is
deliberate: <a href="https://openjdk.org/jeps/425">JEP 425</a> says traditional thread dumps will
not be extended to virtual threads, since a flat list does not scale to millions of them.</p>
<p>The dump that does show them is
<tt>jcmd <pid> Thread.dump_to_file -format=json dump.json</tt> — every virtual thread,
grouped by its thread container, and written without pausing the application. Load that file
here.</p>
<p>It is not a superset of <tt>jstack</tt>, though: it lists Java threads, so the JVM's own
— GC, JIT compiler, VM Thread — are missing from it. For a GC or JIT question, take
both.</p>
<hr>
<h2>Tabs</h2>
<table border="1" cellpadding="4" cellspacing="0">
<tr>
<th bgcolor="#CCCCCC" align="left">Tab</th>
<th bgcolor="#CCCCCC" align="left">What it shows</th>
</tr>
<tr><td><b>Findings</b></td><td>What looks wrong, ranked. Start here.</td></tr>
<tr><td><b>Pools</b></td><td>Which pools are saturated, and what their busy threads do.</td></tr>
<tr><td><b>Population</b></td><td>Which thread groups exist and how big they are.</td></tr>
<tr><td><b>Top frame</b></td><td>Where threads sit right now, most crowded first.</td></tr>
<tr><td><b>States</b></td><td>State counts, plus a Thread.State reference.</td></tr>
<tr><td><b>Creation order</b></td><td>Threads in dump order. Leaks show up as a growing tail.</td></tr>
<tr><td><b>Locks</b></td><td>Who waits on which lock, and who holds it.</td></tr>
<tr><td><b>Stack search</b></td><td>Regex over full stacks.</td></tr>
<tr><td><b>Compare</b></td><td>Two dumps: what grew, what went away.</td></tr>
</table>
<hr>
<h2>Findings</h2>
<p>Most checks are generic: a pool with every worker busy, threads piling up in one frame,
several waiters on one lock, a deadlock the JVM reported itself.</p>
<p>Checks that match frames of a specific library carry a <tt>signature:</tt> badge, so a
library-specific guess never reads as a universal truth. Only HikariCP ships built in —
narrower ones are pasteable rules, below.</p>
<hr>
<h2>Custom rules</h2>
<p>Add your own without touching the source. Findings > Custom rules > + New rule.
Write the body of <tt>function (d, helpers)</tt>:</p>
<table width="100%" border="1" cellpadding="8" cellspacing="0" bgcolor="#F0F0F0">
<tr><td>
<pre>var starved = d.threads.filter(function (t) {
return t.state === "BLOCKED" && t.top.indexOf("com.acme.cache.") === 0;
});
if (starved.length < 5) return [];
return [{
level: "alert",
title: nThreads(starved.length) + " blocked on the cache lock",
text: "Find the holder in the Locks tab first.",
items: starved
}];</pre>
</td></tr>
</table>
<p>Return one finding, an array of them, or nothing when the dump does not match.
Every thread field and helper is listed in the editor, under <i>How to write a rule</i>, and in
the <a href="https://github.com/korotinm/java-thread-dump-inspector#writing-a-rule">full
reference</a>.</p>
<p>Rules live in localStorage: your browser only, never sent anywhere. A rule that throws becomes
its own finding card instead of breaking the tab. Ready-made ones for specific libraries are in
<a href="https://github.com/korotinm/java-thread-dump-inspector/tree/main/rules">rules/</a>
— paste a file into the form to use it.</p>
<hr>
<p><a href="https://github.com/korotinm/java-thread-dump-inspector">Source on GitHub</a> |
<a href="https://github.com/korotinm/java-thread-dump-inspector#contributing-a-rule">Contributing a rule</a> |
<a href="https://github.com/korotinm/java-thread-dump-inspector/blob/main/LICENSE">MIT</a></p>
</td></tr>
</table>
</td></tr>
</table>
</body>
</html>