Skip to content

Commit

Permalink
fixup! Instrumentation for hunting down concurrent reads/writes to by…
Browse files Browse the repository at this point in the history
…te channels
  • Loading branch information
bjhham committed Jan 31, 2025
1 parent 46d4a48 commit a4b7b07
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ktor-io/jvm/src/io/ktor/utils/io/DebugLog.jvm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ private fun Array<StackTraceElement>.getTestName(): String =
} ?: "???"

private val testRegex = Regex("\\w+?[A-Z][a-z]+Test")
private val exemptions = setOf(
private val coroutineExemptions = setOf(
"await-free-space",
"close-write-channel"
)
private val testExemptions = setOf(
"ByteChannelConcurrentTest",
"ByteReadChannelOperationsTest",
)
Expand All @@ -46,7 +50,9 @@ private val invocations = ConcurrentHashMap<Invocation, ThreadDetails>().also {
val byOperationOnInstance = invocations.keys.groupBy { (instance, operation) ->
"$instance-$operation"
}.filterValues { matches ->
matches.size > 1 && invocations[matches.first()]!!.testName !in exemptions
matches.size > 1 &&
matches.all { it.coroutineName.substringBefore('#') !in coroutineExemptions } &&
invocations[matches.first()]!!.testName !in testExemptions
}
appendLine("Total invocations: ${invocations.keys.count()}")
appendLine("Contentious invocations: ${byOperationOnInstance.values.sumOf { it.size }}")
Expand Down

0 comments on commit a4b7b07

Please sign in to comment.