-
Notifications
You must be signed in to change notification settings - Fork 729
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
Update !vthread command to use GC continuation list #17093
Conversation
c492fec
to
3345bdb
Compare
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/VirtualThreadsCommand.java
Outdated
Show resolved
Hide resolved
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/VirtualThreadsCommand.java
Outdated
Show resolved
Hide resolved
3345bdb
to
82d024e
Compare
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/VirtualThreadsCommand.java
Outdated
Show resolved
Hide resolved
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/VirtualThreadsCommand.java
Outdated
Show resolved
Hide resolved
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/VirtualThreadsCommand.java
Outdated
Show resolved
Hide resolved
82d024e
to
8d7686b
Compare
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/VirtualThreadsCommand.java
Outdated
Show resolved
Hide resolved
debugtools/DDR_VM/src/com/ibm/j9ddr/vm29/tools/ddrinteractive/VirtualThreadsCommand.java
Outdated
Show resolved
Hide resolved
8d7686b
to
9ddc49a
Compare
I created the test program below to see how well this works. A significant issue is that only virtual threads created before a GC cycle are displayed, for example running
yields a core file that claims only 4 virtual threads exist. import java.util.ArrayList;
import java.util.List;
public class TestVirtual {
private static final class Helper {
private static void sayHi(int id) {
sleep(id * 10 + 250);
System.out.format("Virtual thread #%d says 'Hi'.%n", id);
sleep(500);
}
private final Thread.Builder builder;
private final List<Thread> threads;
@SuppressWarnings("preview")
Helper() {
super();
builder = Thread.ofVirtual();
threads = new ArrayList<>();
}
void addThreads(int count) {
int base = threads.size();
for (int i = 0; i < count; ++i) {
int id = base + i;
threads.add(builder.name("greeter#" + id).unstarted(() -> sayHi(id)));
}
}
void joinThreads() {
for (Thread thread : threads) {
try {
thread.join();
} catch (InterruptedException e) {
// ignore
}
}
}
void startThreads() {
for (Thread thread : threads) {
thread.start();
}
}
}
public static void main(String[] args) {
int beforeGC = (args.length > 0) ? Integer.parseInt(args[0]) : 10;
int afterGC = (args.length > 1) ? Integer.parseInt(args[1]) : 0;
if ((beforeGC < 0) || (afterGC < 0)) {
System.out.println("Thread counts must be non-negative.");
return;
} else if ((beforeGC == 0) && (afterGC == 0)) {
System.out.println("Total thread count must be positive.");
return;
}
Helper helper = new Helper();
System.out.println("Creating threads...");
if (beforeGC > 0) {
helper.addThreads(beforeGC);
sleep(100);
System.out.println("Collecting garbage...");
System.gc();
}
if (afterGC > 0) {
if (beforeGC > 0) {
System.out.println("Creating more threads...");
}
helper.addThreads(afterGC);
sleep(100);
}
System.out.println("Starting threads...");
helper.startThreads();
com.ibm.jvm.Dump.systemDumpToFile();
System.out.println("Joining threads...");
helper.joinThreads();
System.out.println("Done.");
}
private static void sleep(long ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
// ignore
}
}
} |
The virtual threads after the GC don't show up because most likely the nonAllocationCaches are not flushed before core generation. Ref: #17084 (comment)
There may be code-paths where the nonAllocationCaches are not flushed before core generation. @dmitripivkine Can you please point us to existing locations where the nonAllocationCaches are flushed before core generation? |
There is the place I have in mind: openj9/runtime/rasdump/trigger.c Line 683 in 4075b02
So it is required And it is not |
@dmitripivkine Is some form of synchronization needed to call |
Yes, it is. It should be safe to call if Please note that the way how Virtual Threads list (currently in GC) is organized is going to be re-worked very soon. It means current implementation is going to be replaced to different one in nearest feature which requires new DDR code any way. So, if we need short term temporary solution, my suggestion is to make improvement by calling |
Is there an issue related to that upcoming work? |
I don't think we have formalized issue opened yet |
Fixes eclipse-openj9#17084 Signed-off-by: Gengchen Tuo <gengchen.tuo@ibm.com>
9ddc49a
to
5d0db8b
Compare
With the new change and test from #17093 (comment), are all virtual threads seen in the core file? |
Unfortunately we're still only seeing four threads. |
Yes, but only if the test is changed to call com.ibm.jvm.Dump.setDumpOptions("system:request=exclusive+prepwalk"); before triggering the system dump or the test is run with Perhaps that is sufficient for now. @dmitripivkine Please create that issue so we can discuss those plans and ensure that this limitation is removed. |
Jenkins test sanity alinux64 jdk19 |
Pls cherry pick this change and open a PR against https://github.com/eclipse-openj9/openj9/tree/v0.37.0-release |
This DDR command was not initially included in that branch. Do we still want to back-port? |
What's involved, what other PR is needed? If it's just DDR code there is no reason not to backport. |
#15679 is the original PR, it's just DDR code and a helper. |
|
Fixes #17084