Last active
July 28, 2023 06:35
-
-
Save franz1981/cd9da11b394adefdeceacf3994915e1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.Executor; | |
import java.util.concurrent.Executors; | |
public class VThreadCreation { | |
private static final int TASKS = 1024; | |
public static void main(String[] args) throws InterruptedException { | |
long rounds = Long.MAX_VALUE; | |
if (args.length == 1) { | |
rounds = Long.parseLong(args[0]); | |
} | |
try (var vExecutor = Executors.newVirtualThreadPerTaskExecutor()) { | |
for (long i = 0; i < rounds; i++) { | |
submitTasksAndWait(vExecutor, TASKS); | |
} | |
} | |
} | |
public static void submitTasksAndWait(Executor executor, int tasks) throws InterruptedException { | |
var done = new CountDownLatch(tasks); | |
for (int i = 0; i < tasks; i++) { | |
executor.execute(done::countDown); | |
} | |
done.await(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment:
Running on a Ryzen [email protected] GHz and
This is a reproducer for 2 types of issues:
Continuation::enterVirtual
)1. JVMTI scalability issue
Run it with:
and report it with
While if I run it with the debugging agent (or any agent attached really):
Which has reported a LOT more events this time:
Running the same application with
just fix the contention issue even with the agent attached.
2. Costy wrong_method_handle
Run it with
and
would show