Skip to content

Commit

Permalink
Stabilize our CI build (Kotlin#3030)
Browse files Browse the repository at this point in the history
* 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 Kotlin#3028
  • Loading branch information
qwwdfsad authored and pablobaxter committed Sep 14, 2022
1 parent 0c24476 commit daf500d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jekyll_version=4.0

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

kotlin.mpp.enableCompatibilityMetadataVariant=true
kotlin.mpp.stability.nowarn=true
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ task jvmLincheckTest(type: Test, dependsOn: compileTestKotlinJvm) {

static void configureJvmForLincheck(task) {
task.minHeapSize = '1g'
task.maxHeapSize = '6g' // we may need more space for building an interleaving tree in the model checking mode
task.maxHeapSize = '4g' // we may need more space for building an interleaving tree in the model checking mode
task.jvmArgs = ['--add-opens', 'java.base/jdk.internal.misc=ALL-UNNAMED', // required for transformation
'--add-exports', 'java.base/jdk.internal.util=ALL-UNNAMED'] // in the model checking mode
task.systemProperty 'kotlinx.coroutines.semaphore.segmentSize', '2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ internal class ConcurrentWeakMap<K : Any, V: Any>(
while (true) {
cleanWeakRef(weakRefQueue.remove() as HashedWeakRef<*>)
}
} catch(e: InterruptedException) {
} catch (e: InterruptedException) {
Thread.currentThread().interrupt()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ internal object DebugProbesImpl {
}

private fun stopWeakRefCleanerThread() {
weakRefCleanerThread?.interrupt()
val thread = weakRefCleanerThread ?: return
weakRefCleanerThread = null
thread.interrupt()
thread.join()
}

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

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class ChannelSendReceiveStressTest(
fun params(): Collection<Array<Any>> =
listOf(1, 2, 10).flatMap { nSenders ->
listOf(1, 10).flatMap { nReceivers ->
TestChannelKind.values().map { arrayOf(it, nSenders, nReceivers) }
TestChannelKind.values()
// Workaround for bug that won't be fixed unless new channel implementation, see #2443
.filter { it != TestChannelKind.LINKED_LIST }
.map { arrayOf(it, nSenders, nReceivers) }
}
}
}
Expand Down

0 comments on commit daf500d

Please sign in to comment.