Skip to content

Commit 9d1be50

Browse files
authored
Stabilize our CI build (#3030)
* Try to trim memory usage of Dokka and Lincheck * Disable failing test * Do avoid concurrent-unsafe Collections.toList for working with ConcurrentWeakMap.keySet * Do join weakRefCleanerThread in DebugProbes.uninstall Otherwise, multiple pairs of install + uninstall may leave multiple cleanup threads in the state when the map is already cleaned up, but its size is not Fixes #3028
1 parent 9c3f59f commit 9d1be50

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jekyll_version=4.0
5353

5454
# JS IR backend sometimes crashes with out-of-memory
5555
# TODO: Remove once KT-37187 is fixed
56-
org.gradle.jvmargs=-Xmx4g
56+
org.gradle.jvmargs=-Xmx3g
5757

5858
kotlin.mpp.enableCompatibilityMetadataVariant=true
5959
kotlin.mpp.stability.nowarn=true

kotlinx-coroutines-core/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ task jvmLincheckTest(type: Test, dependsOn: compileTestKotlinJvm) {
266266

267267
static void configureJvmForLincheck(task) {
268268
task.minHeapSize = '1g'
269-
task.maxHeapSize = '6g' // we may need more space for building an interleaving tree in the model checking mode
269+
task.maxHeapSize = '4g' // we may need more space for building an interleaving tree in the model checking mode
270270
task.jvmArgs = ['--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED', // required for transformation
271271
'--add-exports', 'java.base/jdk.internal.util=ALL-UNNAMED'] // in the model checking mode
272272
task.systemProperty 'kotlinx.coroutines.semaphore.segmentSize', '2'

kotlinx-coroutines-core/jvm/src/debug/internal/ConcurrentWeakMap.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal class ConcurrentWeakMap<K : Any, V: Any>(
7373
while (true) {
7474
cleanWeakRef(weakRefQueue.remove() as HashedWeakRef<*>)
7575
}
76-
} catch(e: InterruptedException) {
76+
} catch (e: InterruptedException) {
7777
Thread.currentThread().interrupt()
7878
}
7979
}

kotlinx-coroutines-core/jvm/src/debug/internal/DebugProbesImpl.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ internal object DebugProbesImpl {
102102
}
103103

104104
private fun stopWeakRefCleanerThread() {
105-
weakRefCleanerThread?.interrupt()
105+
val thread = weakRefCleanerThread ?: return
106106
weakRefCleanerThread = null
107+
thread.interrupt()
108+
thread.join()
107109
}
108110

109111
public fun hierarchyToString(job: Job): String = coroutineStateLock.write {
@@ -148,18 +150,19 @@ internal object DebugProbesImpl {
148150
* Private method that dumps coroutines so that different public-facing method can use
149151
* to produce different result types.
150152
*/
151-
private inline fun <R : Any> dumpCoroutinesInfoImpl(create: (CoroutineOwner<*>, CoroutineContext) -> R): List<R> =
153+
private inline fun <R : Any> dumpCoroutinesInfoImpl(crossinline create: (CoroutineOwner<*>, CoroutineContext) -> R): List<R> =
152154
coroutineStateLock.write {
153155
check(isInstalled) { "Debug probes are not installed" }
154156
capturedCoroutines
157+
.asSequence()
155158
// Stable ordering of coroutines by their sequence number
156159
.sortedBy { it.info.sequenceNumber }
157160
// Leave in the dump only the coroutines that were not collected while we were dumping them
158161
.mapNotNull { owner ->
159162
// Fuse map and filter into one operation to save an inline
160163
if (owner.isFinished()) null
161164
else owner.info.context?.let { context -> create(owner, context) }
162-
}
165+
}.toList()
163166
}
164167

165168
/*

kotlinx-coroutines-core/jvm/test/channels/ChannelSendReceiveStressTest.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ class ChannelSendReceiveStressTest(
2525
fun params(): Collection<Array<Any>> =
2626
listOf(1, 2, 10).flatMap { nSenders ->
2727
listOf(1, 10).flatMap { nReceivers ->
28-
TestChannelKind.values().map { arrayOf(it, nSenders, nReceivers) }
28+
TestChannelKind.values()
29+
// Workaround for bug that won't be fixed unless new channel implementation, see #2443
30+
.filter { it != TestChannelKind.LINKED_LIST }
31+
.map { arrayOf(it, nSenders, nReceivers) }
2932
}
3033
}
3134
}

0 commit comments

Comments
 (0)