Skip to content

Commit

Permalink
Merge pull request #3797 from Kotlin/version-1.7.2
Browse files Browse the repository at this point in the history
Version 1.7.2
  • Loading branch information
qwwdfsad committed Jun 29, 2023
2 parents 9c1b3af + 71793d9 commit 5b64a1f
Show file tree
Hide file tree
Showing 41 changed files with 516 additions and 319 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
@@ -1,5 +1,15 @@
# Change log for kotlinx.coroutines

## Version 1.7.2

### Bug fixes and improvements

* Coroutines debugger no longer keeps track of coroutines with empty coroutine context (#3782).
* `CopyableThreadContextElement` now properly copies an element when crossing the coroutine boundary in `flowOn` (#3787). Thanks @wanyingd1996!
* Coroutine timeouts no longer prevent K/N `newSingleThreadContext` from closing (#3768).
* A non-linearizability in `Mutex` during `tryLock`/`unlock` sequence with owners is fixed (#3745).
* Atomicfu version is updated to 0.21.0.

## Version 1.7.1

### Bug fixes and improvements
Expand Down
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -3,7 +3,7 @@
[![Kotlin Stable](https://kotl.in/badges/stable.svg)](https://kotlinlang.org/docs/components-stability.html)
[![JetBrains official project](https://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
[![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)
[![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)
[![Kotlin](https://img.shields.io/badge/kotlin-1.8.20-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Slack channel](https://img.shields.io/badge/chat-slack-green.svg?logo=slack)](https://kotlinlang.slack.com/messages/coroutines/)

Expand Down Expand Up @@ -85,7 +85,7 @@ Add dependencies (you can also add other modules that you need):
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>1.7.1</version>
<version>1.7.2</version>
</dependency>
```

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

```kotlin
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
}
```

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

```kotlin
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2")
```

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

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

#### Native
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
* Copyright 2016-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

package benchmarks.debug
Expand All @@ -9,46 +9,24 @@ import kotlinx.coroutines.debug.*
import org.openjdk.jmh.annotations.*
import org.openjdk.jmh.annotations.State
import java.util.concurrent.*
import java.util.concurrent.atomic.AtomicInteger

/**
* The benchmark is supposed to show the DebugProbes overhead for a non-concurrent sequence builder.
* The code is actually part of the IDEA codebase, originally reported here: https://github.com/Kotlin/kotlinx.coroutines/issues/3527
*/
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(value = 1)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@State(Scope.Benchmark)
open class DebugProbesConcurrentBenchmark {

@Setup
fun setup() {
DebugProbes.sanitizeStackTraces = false
DebugProbes.enableCreationStackTraces = false
DebugProbes.install()
}

@TearDown
fun tearDown() {
DebugProbes.uninstall()
}

open class DebugSequenceOverheadBenchmark {

@Benchmark
fun run() = runBlocking<Long> {
var sum = 0L
repeat(8) {
launch(Dispatchers.Default) {
val seq = stressSequenceBuilder((1..100).asSequence()) {
(1..it).asSequence()
}

for (i in seq) {
sum += i.toLong()
}
}
}
sum
}

private fun <Node> stressSequenceBuilder(initialSequence: Sequence<Node>, children: (Node) -> Sequence<Node>): Sequence<Node> {
private fun <Node> generateRecursiveSequence(
initialSequence: Sequence<Node>,
children: (Node) -> Sequence<Node>
): Sequence<Node> {
return sequence {
val initialIterator = initialSequence.iterator()
if (!initialIterator.hasNext()) {
Expand All @@ -68,4 +46,45 @@ open class DebugProbesConcurrentBenchmark {
}
}
}

@Param("true", "false")
var withDebugger = false

@Setup
fun setup() {
DebugProbes.sanitizeStackTraces = false
DebugProbes.enableCreationStackTraces = false
if (withDebugger) {
DebugProbes.install()
}
}

@TearDown
fun tearDown() {
if (withDebugger) {
DebugProbes.uninstall()
}
}

// Shows the overhead of sequence builder with debugger enabled
@Benchmark
fun runSequenceSingleThread(): Int = runBlocking {
generateRecursiveSequence((1..100).asSequence()) {
(1..it).asSequence()
}.sum()
}

// Shows the overhead of sequence builder with debugger enabled and debugger is concurrently stressed out
@Benchmark
fun runSequenceMultipleThreads(): Int = runBlocking {
val result = AtomicInteger(0)
repeat(Runtime.getRuntime().availableProcessors()) {
launch(Dispatchers.Default) {
result.addAndGet(generateRecursiveSequence((1..100).asSequence()) {
(1..it).asSequence()
}.sum())
}
}
result.get()
}
}
10 changes: 4 additions & 6 deletions buildSrc/build.gradle.kts
Expand Up @@ -27,11 +27,7 @@ repositories {
}
}

kotlinDslPluginOptions {
experimentalWarning.set(false)
}

val props = Properties().apply {
val gradleProperties = Properties().apply {
file("../gradle.properties").inputStream().use { load(it) }
}

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

dependencies {
Expand Down
26 changes: 26 additions & 0 deletions buildSrc/src/main/kotlin/CommunityProjectsBuild.kt
Expand Up @@ -18,6 +18,32 @@ private val LOGGER: Logger = Logger.getLogger("Kotlin settings logger")
* are compatible with our libraries (aka "integration testing that substitues lack of unit testing").
*/

/**
* Should be used for running against of non-released Kotlin compiler on a system test level.
*
* @return a Kotlin API version parametrized from command line nor gradle.properties, null otherwise
*/
fun getOverriddenKotlinApiVersion(project: Project): String? {
val apiVersion = project.rootProject.properties["kotlin_api_version"] as? String
if (apiVersion != null) {
LOGGER.info("""Configured Kotlin API version: '$apiVersion' for project $${project.name}""")
}
return apiVersion
}

/**
* Should be used for running against of non-released Kotlin compiler on a system test level
*
* @return a Kotlin Language version parametrized from command line nor gradle.properties, null otherwise
*/
fun getOverriddenKotlinLanguageVersion(project: Project): String? {
val languageVersion = project.rootProject.properties["kotlin_language_version"] as? String
if (languageVersion != null) {
LOGGER.info("""Configured Kotlin Language version: '$languageVersion' for project ${project.name}""")
}
return languageVersion
}

/**
* Should be used for running against of non-released Kotlin compiler on a system test level
* Kotlin compiler artifacts are expected to be downloaded from maven central by default.
Expand Down
Expand Up @@ -2,16 +2,19 @@
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.jetbrains.kotlin.gradle.tasks.*
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions

configure(subprojects) {
val project = this
if (name in sourceless) return@configure
apply(plugin = "kotlinx-atomicfu")
val projectName = name
tasks.withType(KotlinCompile::class).all {
tasks.withType<KotlinCompile<*>>().configureEach {
val isMainTaskName = name == "compileKotlin" || name == "compileKotlinJvm"
kotlinOptions {
if (isMainTaskName) {
languageVersion = getOverriddenKotlinLanguageVersion(project)
apiVersion = getOverriddenKotlinApiVersion(project)
if (isMainTaskName && versionsAreNotOverridden) {
allWarningsAsErrors = true
}
val newOptions =
Expand All @@ -23,3 +26,6 @@ configure(subprojects) {
}
}
}

val KotlinCommonOptions.versionsAreNotOverridden: Boolean
get() = languageVersion == null && apiVersion == null

0 comments on commit 5b64a1f

Please sign in to comment.