-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Not work on single core CPU #288
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
Comments
When I run the coretine on Moto 360 1gen nothing happens.
|
You have to wait for the completion. Example: fun main(args: Array<String>) = runBlocking {
val job = launch {
println("hello")
}
job.join()
} |
I run this actions in activity in methid onCreate(). |
Can you share a self-contained example which allows to reproduce the problem? |
I just create new project with single activity.
And result is:
without launch block |
@JajaComp Do you observe it on the emulate or on the actual device? What Android version does it have? |
I use real device. Is Moto 360 1gen. Android wear version is latest with 23 API. |
@elizarov Я думаю проблема в том, что в данном устройстве одноядерный процессор. Пока нашел костыль и использую проверку на (Runtime.getRuntime().availableProcessors() > 1). Если возвращается единица, делаю через Thread, а если >1 то запускаю launch {} |
@JajaComp If there is some kind of a problem on single-core CPUs, then it should be possible to imitate this problem in emulator of the single-core CPU. |
I can't repeat this trouble on emulator with 1-core (I tested this). But 100% don't work on other Moto 360 1gen (Information from app statistic). |
Any update? |
Ran into the same issue on a provisioned virtual machine with one CPU. Tried spawning an infinite-loop queue-consumer in a coroutine and it worked on my machine but not the limited virtual one. Changing to a |
@mangefox Can you share your test code, please? |
I just hit something possibly similar in a Kubernetes cluster on GKE. A pod with 1000m cpu requested (= 1 vCPU) has issues executing anything in an async coroutine. If I allocate 2000m it executes the coroutines without issue. The underlying host for the 1000m allocation had 2 vCPUs and the 2000m allocation had 4 vCPUs on the host. It's the first time I've attempted to use coroutines so it wouldn't be surprising to me if I've done something a bit silly here. Like the original poster I only hit this after I executed the program somewhere other than my local dev machine (which has 4 cores). The basic structure of the app is:
In Application.start it fires off 4 of roughly the following:
Update: I thought I'd check that other difference, the 2 vCPU host vs the 4 vCPU host. It seems that the 1 vCPU allocation to the Kotlin app on the 2 vCPU host locks, but doesn't on the 4 vCPU host. So the summary on that is: 2 vCPU host. 1 vCPU allocation to Kotlin = locking |
Hi @bradleydwyer Also note that |
Coroutines not work on single core CPU. For example - Moto 360 1st
The text was updated successfully, but these errors were encountered: