jsijsling
07/23/2019, 10:19 AM<http://Dispatchers.IO|Dispatchers.IO>
produced significant garbage overhead. Log snippet:
Background concurrent copying GC freed 1692(904KB) AllocSpace objects, 127(2MB) LOS objects, 49% free, 3MB/7MB, paused 390us total 103.292ms
Background concurrent copying GC freed 1965(1129KB) AllocSpace objects, 163(3MB) LOS objects, 50% free, 3MB/7MB, paused 552us total 118.408ms
Long wait of 8.836ms for Thread[20,tid=16153,Native,Thread*=0xe0c63c00,peer=0x12c40078,"DefaultDispatcher-worker-6"] suspension!
Background concurrent copying GC freed 2006(1273KB) AllocSpace objects, 197(4MB) LOS objects, 50% free, 3MB/7MB, paused 613us total 120.900ms
Background concurrent copying GC freed 2420(1437KB) AllocSpace objects, 216(4MB) LOS objects, 37% free, 10MB/16MB, paused 1.202ms total 256.912ms
Waiting for a blocking GC ProfileSaver
WaitForGcToComplete blocked ProfileSaver on HeapTrim for 29.549ms
Background concurrent copying GC freed 2242(1268KB) AllocSpace objects, 189(4MB) LOS objects, 49% free, 3MB/6MB, paused 520us total 102.964ms
Background concurrent copying GC freed 1782(1071KB) AllocSpace objects, 154(3MB) LOS objects, 49% free, 5MB/10MB, paused 386us total 112.534ms
Any clue why this might be?Marko Mitic
07/23/2019, 10:24 AMjsijsling
07/23/2019, 10:55 AM<http://Dispatchers.IO|Dispatchers.IO>
but I still think the amount of garbage is too much though.
In my test the number of distinct threads spawned for 1000 iterations is 5~6 on IO versus 2 on the default dispatcher.Marko Mitic
07/23/2019, 10:56 AMjsijsling
07/23/2019, 11:00 AMval timeline = mutableListOf<Long>()
repeat(1000) {
val ms = measureTimeMillis {
runBlocking {
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
ApplicationProvider.getApplicationContext<Application>().assets
.open("testAssetFile.json").use { it.reader().readText() }
}
}
}
timeline += ms
}
println("Avg=${timeline.average()}ms, max=${timeline.max()}, min=${timeline.min()}")
<http://Dispatchers.IO|Dispatchers.IO>
I see the GC working overtime.Marko Mitic
07/23/2019, 11:03 AMrunBlocking
around repeat
jsijsling
07/23/2019, 11:03 AMrunBlocking
Marko Mitic
07/23/2019, 11:33 AMjsijsling
07/23/2019, 11:34 AMrunBlocking {
repeat(1000) {
val ms = measureTimeMillis {
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
loadAsset("testAssetFile.json")
}
}
timeline += ms
}
}
Marko Mitic
07/23/2019, 11:34 AMjsijsling
07/23/2019, 11:36 AMrunBlocking {
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
repeat(1000) {
val ms = measureTimeMillis {
loadAsset("testAssetFile.json")
}
timeline += ms
}
}
}
Marko Mitic
07/23/2019, 11:37 AMwithContext
switches?Dominaezzz
07/23/2019, 11:39 AMrunBlocking(Dispatchers.Default)
?jsijsling
07/23/2019, 11:45 AMrunBlocking(Dispatchers.Default) {
repeat(1000) {
val ms = measureTimeMillis {
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
loadAsset("testAssetFile.json")
}
}
timeline += ms
}
}
Produces more overhead than runBlocking withContext(Dispatchers.Default)
but not as much as with just the IO dispatcher.runBlocking(Dispatchers.Default)
. Versus 1~2 concurrent sweeps with runBlocking withContext(Dispatchers.Default)
Dominaezzz
07/23/2019, 11:50 AMjsijsling
07/23/2019, 11:59 AMgildor
07/24/2019, 1:38 AMlouiscad
07/24/2019, 1:57 PMgildor
07/24/2019, 2:34 PM