I've got a JVM process using coroutines 1.0.0 that...
# coroutines
r
I've got a JVM process using coroutines 1.0.0 that has a thread like this that appears to be in a tight loop and using 100% CPU:
Copy code
"DefaultDispatcher-worker-5" - Thread t@95
   java.lang.Thread.State: RUNNABLE
	at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
	at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
	at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93)
	at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
	- locked <1c724d56> (a sun.nio.ch.Util$3)
	- locked <2daa5d57> (a java.util.Collections$UnmodifiableSet)
	- locked <69cba374> (a sun.nio.ch.EPollSelectorImpl)
	at sun.nio.ch.SelectorImpl.selectNow(SelectorImpl.java:105)
	at io.ktor.network.selector.ActorSelectorManager.process(ActorSelectorManager.kt:76)
	at io.ktor.network.selector.ActorSelectorManager$process$1.invokeSuspend(ActorSelectorManager.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)
	at kotlinx.coroutines.DispatchedTask$DefaultImpls.run(Dispatched.kt:235)
	at kotlinx.coroutines.DispatchedContinuation.run(Dispatched.kt:81)
	at kotlinx.coroutines.scheduling.Task.run(Tasks.kt:94)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:732)

   Locked ownable synchronizers:
	- None

"DefaultDispatcher-worker-5" - Thread t@78
   java.lang.Thread.State: TIMED_WAITING
	at sun.misc.Unsafe.park(Native Method)
	at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:338)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.doPark(CoroutineScheduler.kt:835)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.cpuWorkerIdle(CoroutineScheduler.kt:813)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:721)

   Locked ownable synchronizers:
	- None
It isn't executing any application code, just continuously parking/unparking, AFAICT. How can I tell what is going on here and why this has happened?
l
@rocketraman Do you have the same issue on 1.0.1?
r
Haven't tried that yet.
It doesn't happen all the time either, even on 1.0.0, and I don't have a reproducer
v
It is Ktor-specific issue, ActorSelectorManager busy-loops too aggressively , please report it to #kor
r
Thanks
l
#ktor