Skip to content

Commit 5b64a1f

Browse files
authored
Merge pull request #3797 from Kotlin/version-1.7.2
Version 1.7.2
2 parents 9c1b3af + 71793d9 commit 5b64a1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+516
-319
lines changed

CHANGES.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change log for kotlinx.coroutines
22

3+
## Version 1.7.2
4+
5+
### Bug fixes and improvements
6+
7+
* Coroutines debugger no longer keeps track of coroutines with empty coroutine context (#3782).
8+
* `CopyableThreadContextElement` now properly copies an element when crossing the coroutine boundary in `flowOn` (#3787). Thanks @wanyingd1996!
9+
* Coroutine timeouts no longer prevent K/N `newSingleThreadContext` from closing (#3768).
10+
* A non-linearizability in `Mutex` during `tryLock`/`unlock` sequence with owners is fixed (#3745).
11+
* Atomicfu version is updated to 0.21.0.
12+
313
## Version 1.7.1
414

515
### Bug fixes and improvements

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Kotlin Stable](https://kotl.in/badges/stable.svg)](https://kotlinlang.org/docs/components-stability.html)
44
[![JetBrains official project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
55
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
6-
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.7.1)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.7.1)
6+
[![Download](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.7.2)](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.7.2)
77
[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
88
[![Slack channel](https://img.shields.io/badge/chat-slack-green.svg?logo=slack)](https://kotlinlang.slack.com/messages/coroutines/)
99

@@ -85,7 +85,7 @@ Add dependencies (you can also add other modules that you need):
8585
<dependency>
8686
<groupId>org.jetbrains.kotlinx</groupId>
8787
<artifactId>kotlinx-coroutines-core</artifactId>
88-
<version>1.7.1</version>
88+
<version>1.7.2</version>
8989
</dependency>
9090
```
9191

@@ -103,7 +103,7 @@ Add dependencies (you can also add other modules that you need):
103103

104104
```kotlin
105105
dependencies {
106-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
106+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
107107
}
108108
```
109109

@@ -133,7 +133,7 @@ Add [`kotlinx-coroutines-android`](ui/kotlinx-coroutines-android)
133133
module as a dependency when using `kotlinx.coroutines` on Android:
134134

135135
```kotlin
136-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
136+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2")
137137
```
138138

139139
This gives you access to the Android [Dispatchers.Main]
@@ -168,7 +168,7 @@ In common code that should get compiled for different platforms, you can add a d
168168
```kotlin
169169
commonMain {
170170
dependencies {
171-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
171+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
172172
}
173173
}
174174
```
@@ -180,7 +180,7 @@ Platform-specific dependencies are recommended to be used only for non-multiplat
180180
#### JS
181181

182182
Kotlin/JS version of `kotlinx.coroutines` is published as
183-
[`kotlinx-coroutines-core-js`](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.7.1)
183+
[`kotlinx-coroutines-core-js`](https://central.sonatype.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-js/1.7.2)
184184
(follow the link to get the dependency declaration snippet) and as [`kotlinx-coroutines-core`](https://www.npmjs.com/package/kotlinx-coroutines-core) NPM package.
185185

186186
#### Native
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package benchmarks.debug
@@ -9,46 +9,24 @@ import kotlinx.coroutines.debug.*
99
import org.openjdk.jmh.annotations.*
1010
import org.openjdk.jmh.annotations.State
1111
import java.util.concurrent.*
12+
import java.util.concurrent.atomic.AtomicInteger
1213

14+
/**
15+
* The benchmark is supposed to show the DebugProbes overhead for a non-concurrent sequence builder.
16+
* The code is actually part of the IDEA codebase, originally reported here: https://github.com/Kotlin/kotlinx.coroutines/issues/3527
17+
*/
1318
@Warmup(iterations = 5, time = 1)
1419
@Measurement(iterations = 5, time = 1)
1520
@Fork(value = 1)
1621
@BenchmarkMode(Mode.AverageTime)
1722
@OutputTimeUnit(TimeUnit.MICROSECONDS)
1823
@State(Scope.Benchmark)
19-
open class DebugProbesConcurrentBenchmark {
20-
21-
@Setup
22-
fun setup() {
23-
DebugProbes.sanitizeStackTraces = false
24-
DebugProbes.enableCreationStackTraces = false
25-
DebugProbes.install()
26-
}
27-
28-
@TearDown
29-
fun tearDown() {
30-
DebugProbes.uninstall()
31-
}
32-
24+
open class DebugSequenceOverheadBenchmark {
3325

34-
@Benchmark
35-
fun run() = runBlocking<Long> {
36-
var sum = 0L
37-
repeat(8) {
38-
launch(Dispatchers.Default) {
39-
val seq = stressSequenceBuilder((1..100).asSequence()) {
40-
(1..it).asSequence()
41-
}
42-
43-
for (i in seq) {
44-
sum += i.toLong()
45-
}
46-
}
47-
}
48-
sum
49-
}
50-
51-
private fun <Node> stressSequenceBuilder(initialSequence: Sequence<Node>, children: (Node) -> Sequence<Node>): Sequence<Node> {
26+
private fun <Node> generateRecursiveSequence(
27+
initialSequence: Sequence<Node>,
28+
children: (Node) -> Sequence<Node>
29+
): Sequence<Node> {
5230
return sequence {
5331
val initialIterator = initialSequence.iterator()
5432
if (!initialIterator.hasNext()) {
@@ -68,4 +46,45 @@ open class DebugProbesConcurrentBenchmark {
6846
}
6947
}
7048
}
49+
50+
@Param("true", "false")
51+
var withDebugger = false
52+
53+
@Setup
54+
fun setup() {
55+
DebugProbes.sanitizeStackTraces = false
56+
DebugProbes.enableCreationStackTraces = false
57+
if (withDebugger) {
58+
DebugProbes.install()
59+
}
60+
}
61+
62+
@TearDown
63+
fun tearDown() {
64+
if (withDebugger) {
65+
DebugProbes.uninstall()
66+
}
67+
}
68+
69+
// Shows the overhead of sequence builder with debugger enabled
70+
@Benchmark
71+
fun runSequenceSingleThread(): Int = runBlocking {
72+
generateRecursiveSequence((1..100).asSequence()) {
73+
(1..it).asSequence()
74+
}.sum()
75+
}
76+
77+
// Shows the overhead of sequence builder with debugger enabled and debugger is concurrently stressed out
78+
@Benchmark
79+
fun runSequenceMultipleThreads(): Int = runBlocking {
80+
val result = AtomicInteger(0)
81+
repeat(Runtime.getRuntime().availableProcessors()) {
82+
launch(Dispatchers.Default) {
83+
result.addAndGet(generateRecursiveSequence((1..100).asSequence()) {
84+
(1..it).asSequence()
85+
}.sum())
86+
}
87+
}
88+
result.get()
89+
}
7190
}

buildSrc/build.gradle.kts

+4-6
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ repositories {
2727
}
2828
}
2929

30-
kotlinDslPluginOptions {
31-
experimentalWarning.set(false)
32-
}
33-
34-
val props = Properties().apply {
30+
val gradleProperties = Properties().apply {
3531
file("../gradle.properties").inputStream().use { load(it) }
3632
}
3733

@@ -41,7 +37,9 @@ fun version(target: String): String {
4137
val snapshotVersion = properties["kotlin_snapshot_version"]
4238
if (snapshotVersion != null) return snapshotVersion.toString()
4339
}
44-
return props.getProperty("${target}_version")
40+
val version = "${target}_version"
41+
// Read from CLI first, used in aggregate builds
42+
return properties[version]?.let{"$it"} ?: gradleProperties.getProperty(version)
4543
}
4644

4745
dependencies {

buildSrc/src/main/kotlin/CommunityProjectsBuild.kt

+26
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,32 @@ private val LOGGER: Logger = Logger.getLogger("Kotlin settings logger")
1818
* are compatible with our libraries (aka "integration testing that substitues lack of unit testing").
1919
*/
2020

21+
/**
22+
* Should be used for running against of non-released Kotlin compiler on a system test level.
23+
*
24+
* @return a Kotlin API version parametrized from command line nor gradle.properties, null otherwise
25+
*/
26+
fun getOverriddenKotlinApiVersion(project: Project): String? {
27+
val apiVersion = project.rootProject.properties["kotlin_api_version"] as? String
28+
if (apiVersion != null) {
29+
LOGGER.info("""Configured Kotlin API version: '$apiVersion' for project $${project.name}""")
30+
}
31+
return apiVersion
32+
}
33+
34+
/**
35+
* Should be used for running against of non-released Kotlin compiler on a system test level
36+
*
37+
* @return a Kotlin Language version parametrized from command line nor gradle.properties, null otherwise
38+
*/
39+
fun getOverriddenKotlinLanguageVersion(project: Project): String? {
40+
val languageVersion = project.rootProject.properties["kotlin_language_version"] as? String
41+
if (languageVersion != null) {
42+
LOGGER.info("""Configured Kotlin Language version: '$languageVersion' for project ${project.name}""")
43+
}
44+
return languageVersion
45+
}
46+
2147
/**
2248
* Should be used for running against of non-released Kotlin compiler on a system test level
2349
* Kotlin compiler artifacts are expected to be downloaded from maven central by default.

buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts

+10-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5-
import org.jetbrains.kotlin.gradle.tasks.*
5+
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
6+
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
67

78
configure(subprojects) {
9+
val project = this
810
if (name in sourceless) return@configure
911
apply(plugin = "kotlinx-atomicfu")
10-
val projectName = name
11-
tasks.withType(KotlinCompile::class).all {
12+
tasks.withType<KotlinCompile<*>>().configureEach {
1213
val isMainTaskName = name == "compileKotlin" || name == "compileKotlinJvm"
1314
kotlinOptions {
14-
if (isMainTaskName) {
15+
languageVersion = getOverriddenKotlinLanguageVersion(project)
16+
apiVersion = getOverriddenKotlinApiVersion(project)
17+
if (isMainTaskName && versionsAreNotOverridden) {
1518
allWarningsAsErrors = true
1619
}
1720
val newOptions =
@@ -23,3 +26,6 @@ configure(subprojects) {
2326
}
2427
}
2528
}
29+
30+
val KotlinCommonOptions.versionsAreNotOverridden: Boolean
31+
get() = languageVersion == null && apiVersion == null

0 commit comments

Comments
 (0)