Skip to content

Commit 1f65fde

Browse files
committedNov 27, 2024
Merge loom into fibers
2 parents 107915b + e171b9a commit 1f65fde

File tree

4 files changed

+34
-28
lines changed

4 files changed

+34
-28
lines changed
 

‎src/hotspot/share/services/diagnosticCommand.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,8 @@ class VThreadSchedulerDCmd : public DCmd {
943943
return "Thread.vthread_scheduler";
944944
}
945945
static const char* description() {
946-
return "Print the virtual thread scheduler.";
946+
return "Print the virtual thread scheduler, and the delayed task schedulers that support "
947+
"virtual threads doing timed operations.";
947948
}
948949
static const char* impact() { return "Low"; }
949950
virtual void execute(DCmdSource source, TRAPS);
@@ -956,7 +957,7 @@ class VThreadPollersDCmd : public DCmd {
956957
return "Thread.vthread_pollers";
957958
}
958959
static const char* description() {
959-
return "Print the virtual thread I/O pollers.";
960+
return "Print the I/O pollers that support virtual threads doing blocking network I/O operations.";
960961
}
961962
static const char* impact() { return "Low"; }
962963
virtual void execute(DCmdSource source, TRAPS);

‎src/java.base/share/classes/jdk/internal/vm/JcmdVThreadCommands.java

+26-22
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
import sun.nio.ch.Poller;
3333

3434
/**
35-
* The implementation for the jcmd Thread.vthread_* diagnostic commands.
35+
* The implementation for the jcmd Thread.vthread_* diagnostic commands. These methods are
36+
* called from the "Attach Listener" thread.
3637
*/
3738
public class JcmdVThreadCommands {
3839
private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
@@ -47,22 +48,21 @@ private static byte[] printScheduler() {
4748

4849
// virtual thread scheduler
4950
sb.append(JLA.virtualThreadDefaultScheduler())
50-
.append(System.lineSeparator());
51+
.append(System.lineSeparator());
5152

5253
// break
5354
sb.append(System.lineSeparator());
5455

5556
// delayed task schedulers
57+
sb.append("Delayed task schedulers:").append(System.lineSeparator());
5658
var delayedTaskSchedulers = JLA.virtualThreadDelayedTaskSchedulers().toList();
57-
sb.append("Delayed task schedulers:")
58-
.append(System.lineSeparator());
59-
for (int i = 0; i < delayedTaskSchedulers.size(); i++) {
60-
sb.append('[')
61-
.append(i)
62-
.append("] ")
63-
.append(delayedTaskSchedulers.get(i))
64-
.append(System.lineSeparator());
65-
}
59+
IntStream.range(0, delayedTaskSchedulers.size())
60+
.forEach(i -> sb.append('[')
61+
.append(i)
62+
.append("] ")
63+
.append(delayedTaskSchedulers.get(i))
64+
.append(System.lineSeparator()));
65+
6666
return sb.toString().getBytes(StandardCharsets.UTF_8);
6767
}
6868

@@ -78,30 +78,34 @@ private static byte[] printPollers() {
7878

7979
if (masterPoller != null) {
8080
sb.append("Master I/O poller:")
81-
.append(System.lineSeparator())
82-
.append(masterPoller)
83-
.append(System.lineSeparator());
81+
.append(System.lineSeparator())
82+
.append(masterPoller)
83+
.append(System.lineSeparator());
84+
85+
// break
8486
sb.append(System.lineSeparator());
8587
}
8688

8789
sb.append("Read I/O pollers:");
8890
sb.append(System.lineSeparator());
8991
IntStream.range(0, readPollers.size())
9092
.forEach(i -> sb.append('[')
91-
.append(i)
92-
.append("] ")
93-
.append(readPollers.get(i))
94-
.append(System.lineSeparator()));
93+
.append(i)
94+
.append("] ")
95+
.append(readPollers.get(i))
96+
.append(System.lineSeparator()));
97+
98+
// break
9599
sb.append(System.lineSeparator());
96100

97101
sb.append("Write I/O pollers:");
98102
sb.append(System.lineSeparator());
99103
IntStream.range(0, writePollers.size())
100104
.forEach(i -> sb.append('[')
101-
.append(i)
102-
.append("] ")
103-
.append(writePollers.get(i))
104-
.append(System.lineSeparator()));
105+
.append(i)
106+
.append("] ")
107+
.append(writePollers.get(i))
108+
.append(System.lineSeparator()));
105109

106110
return sb.toString().getBytes(StandardCharsets.UTF_8);
107111
}

‎src/jdk.jcmd/share/man/jcmd.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,13 @@ The following commands are available:
738738
- `-l`: (Optional) Prints `java.util.concurrent` locks (BOOLEAN, false)
739739

740740
`Thread.vthread_scheduler`
741-
: Print the virtual thread scheduler.
741+
: Print the virtual thread scheduler, and the delayed task schedulers that support
742+
virtual threads doing timed operations.
742743

743744
Impact: Low
744745

745746
`Thread.vthread_pollers`
746-
: Print the virtual thread I/O pollers.
747+
: Print the I/O pollers that support virtual threads doing blocking network I/O operations.
747748

748749
Impact: Low
749750

‎test/hotspot/jtreg/serviceability/dcmd/thread/VThreadCommandsTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ void testVThreadPollers() throws Exception {
7979
try (var listener = new ServerSocket()) {
8080
InetAddress lb = InetAddress.getLoopbackAddress();
8181
listener.bind(new InetSocketAddress(lb, 0));
82-
listener.setSoTimeout(1000);
82+
listener.setSoTimeout(200);
8383
try (Socket s = listener.accept()) {
84-
fail("Connection from " + s.getRemoteSocketAddress());
84+
System.err.format("Connection from %s ??%n", s.getRemoteSocketAddress());
8585
} catch (SocketTimeoutException e) {
8686
// expected
8787
}

0 commit comments

Comments
 (0)
Please sign in to comment.