Skip to content

Commit d79ab18

Browse files
committed
[GR-60018] Revert recent ContextPauseTest#testPauseManyThreads change in order to prevent hangs.
PullRequest: graal/19412
2 parents ad42202 + 5652358 commit d79ab18

File tree

1 file changed

+9
-9
lines changed
  • truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test

1 file changed

+9
-9
lines changed

truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/ContextPauseTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public synchronized void waitUntilCount(long count) {
373373

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

0 commit comments

Comments
 (0)