Skip to content

Commit

Permalink
[GR-60018] Revert recent ContextPauseTest#testPauseManyThreads change…
Browse files Browse the repository at this point in the history
… in order to prevent hangs.

PullRequest: graal/19412
  • Loading branch information
jchalou committed Nov 25, 2024
2 parents ad42202 + 5652358 commit d79ab18
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public synchronized void waitUntilCount(long count) {

@Test
public void testPauseManyThreads() throws ExecutionException, InterruptedException, IOException {
int nThreads = Runtime.getRuntime().availableProcessors() + 2;
int nThreads = Runtime.getRuntime().availableProcessors() + 1;
ExecutorService executorService = threadPool(nThreads, vthreads);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Engine.Builder engineBuilder = Engine.newBuilder().allowExperimentalOptions(true).option("engine.SynchronousThreadLocalActionMaxWait", "1").out(outputStream).err(outputStream);
Expand Down Expand Up @@ -462,7 +462,7 @@ public void onReturnExceptional(EventContext c, VirtualFrame frame, Throwable ex
Assert.assertFalse(pauseFuture1.isCancelled());
// The one thread executing context1 is now paused
/*
* Execute the same code in context2 in availableProcessors + 1 (nThreads - 1) threads.
* Execute the same code in context2 in availableProcessors (nThreads - 1) threads.
*/
for (int i = 1; i < nThreads; i++) {
executorService.submit(() -> {
Expand All @@ -484,13 +484,13 @@ public void onReturnExceptional(EventContext c, VirtualFrame frame, Throwable ex
* the synchronous pause thread local action may not reach the synchronization point in
* case virtual threads are used and is automatically cancelled. The reason for not
* reaching the synchronization point is that when availableProcessors of these threads
* are pinned and then the waiting for the start sync of the pause thread local action
* using LockSupport.parkNanos, the (availableProcessors + 1)-th thread cannot run
* because the parallelism of the default virtual thread scheduler is only
* availableProcessors and none of the "parked" threads, though waiting, can be
* compensated for due to the pinning. Also, the timeout for the pause thread local
* action sync is pretty small (one second) so the cancellation might occur even for
* platform threads in case some unusual slowdown.
* are pinned and waiting for the start sync of the pause thread local action using
* LockSupport.parkNanos (or already paused in case of the already paused context1
* thread), the (availableProcessors + 1)-th thread cannot run because the parallelism
* of the default virtual thread scheduler is only availableProcessors and none of the
* "parked" threads, though waiting, can be compensated for due to the pinning. Also,
* the timeout for the pause thread local action sync is pretty small (one second) so
* the cancellation might occur even for platform threads in case some unusual slowdown.
*/
boolean pause2Cancelled = pauseFuture2.isCancelled();
// If context2 pausing is cancelled, new thread in context2 should not be paused even
Expand Down

0 comments on commit d79ab18

Please sign in to comment.