From 69bf28cc23d4ab816a9b49c4a2d4a1a8a818ce30 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Thu, 24 Aug 2017 15:03:19 +0300 Subject: [PATCH] v0.3.1 preparations. (#806) --- CHANGELOG.md | 10 +++++ RELEASE_NOTES.md | 9 +++-- RELEASE_PROCESS.md | 50 +++++++++++++++++++++++++ backend.native/bc.frontend/build.gradle | 23 ------------ gradle.properties | 2 +- samples/build.sh | 1 + samples/workers/README.md | 41 ++++++++++++++++++++ samples/workers/Workers.kt | 35 +++++++++++++++++ samples/workers/build.sh | 28 ++++++++++++++ 9 files changed, 171 insertions(+), 28 deletions(-) create mode 100644 RELEASE_PROCESS.md delete mode 100644 backend.native/bc.frontend/build.gradle create mode 100644 samples/workers/README.md create mode 100644 samples/workers/Workers.kt create mode 100755 samples/workers/build.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b0640d3e9f..013ca91b3e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## v0.3.1 (Aug 2017) ## + * Improvements in C interop tools (function pointers, bitfields, bugfixes) + * Improvements to Gradle plugin and dependency downloader + * Support for immutable data linked into an executable via ImmutableDataBlob class + * Kotlin 1.1.4 supported + * Basic variable inspection support in the debugger + * Some performance improvements ("for" loops, memory management) + * .klib improvements (keep options from .def file, faster inline handling) + * experimental workers API added (see [`sample`](https://github.com/JetBrains/kotlin-native/blob/master/samples/workers)) + ## v0.3 (Jun 2017) ## * Preliminary support for x86-64 Windows hosts and targets * Support for producing native activities on 32- and 64-bit Android targets diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5ba22018d76..9a61f796a6c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -34,12 +34,12 @@ the following platforms: To run _Kotlin/Native_ JDK8 for the host platform has to be installed. Note that Java 9 not yet supported. -The language and library version supported by this EAP release mostly match Kotlin 1.1. +The language and library version supported by this EAP release mostly match Kotlin 1.1.4. However, there are certain limitations, see section [Known Limitations](#limitations). Currently _Kotlin/Native_ uses reference counting based memory management scheme with a cycle -collection algorithm. Multiple threads could be used, but no objects shared -between threads are allowed. +collection algorithm. Multiple threads could be used, but objects must be explicitly transferred +between threads, and same object couldn't be accessed by two threads concurrently. _Kotlin/Native_ provides efficient interoperability with libraries written in C, and supports automatic generation of Kotlin bindings from a C header file. @@ -100,4 +100,5 @@ Notice that property delegation (including lazy properties) *does* work. b kfun:main(kotlin.Array) to set breakpoint in main function of your application. Single stepping and step into shall work, -variable inspection does not work yet. See [`DEBUGGING.md`](https://github.com/JetBrains/kotlin-native/blob/master/DEBUGGING.md) \ No newline at end of file +variable inspection partially works (not on val's, var's only). +See [`DEBUGGING.md`](https://github.com/JetBrains/kotlin-native/blob/master/DEBUGGING.md) \ No newline at end of file diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md new file mode 100644 index 00000000000..86ffd3c2bb9 --- /dev/null +++ b/RELEASE_PROCESS.md @@ -0,0 +1,50 @@ +## Making release of Kotlin/Native ## + +### Move version up in the repository ### + + * Increment `konanVersion` in topmost `gradle.properties`. + * Create entry for new release in CHANGELOG.md file (consult git history for features included) + * Update RELEASE_NOTES.md with actual information on the released bits + +### Create tagged release branch ### + + git checkout -b v0.X-fixes + git tag -a v0.X -m "version 0.X" + git push --set-upstream origin origin v0.X-fixes --tags + +### Build for all supported platforms ### + +Repeat those steps for Mac OS X, Linux x86-64 and Windows x64 machines/VMs: + + git pull + git checkout -b v0.X-fixes origin/v0.X-fixes + ./gradlew clean bundle + +Make sure all samples are buildable from the bundle with both Gradle and shell script builds. + +### Create GitHub release ### + + Create release at [`GitHub release page`](https://github.com/JetBrains/kotlin-native/releases). +We usually mark 0.X releases as pre-releases. + + Upload builds created on the previous step to the GitHub release page. + + +### Upload builds ### + + Upload build to CDN at upload.cds.intellij.net/kotlin/native. +Bundles are available at http://download.jetbrains.com/kotlin/native/ +in few minutes after upload. + + Upload Gradle plugin to BinTray + + BINTRAY_USER=... BINTRAY_KEY=... ./gradlew :tools:gradle-plugin:bintrayUpload + +### Blog post ### + + Notify #kotlin-native channel on public slack. + + Write a meaningfully sized blog post describing new release at https://blog.jetbrains.com. +Login at https://blog.jetbrains.com/kotlin/wp-login.php. Synchronize with @abreslav and @yole. +Publish and enjoy! + \ No newline at end of file diff --git a/backend.native/bc.frontend/build.gradle b/backend.native/bc.frontend/build.gradle deleted file mode 100644 index c07a62ed0b9..00000000000 --- a/backend.native/bc.frontend/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -buildscript { - ext.kotlin_version = '1.0.3' - - apply from: "$rootDir/gradle/kotlinGradlePlugin.gradle" -} -apply plugin: 'java' -apply plugin: 'kotlin' \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 32e649dce65..8e7192a2ca8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,5 +24,5 @@ kotlinCompilerRepo=https://dl.bintray.com/jetbrains/kotlin-native-dependencies #kotlinCompilerRepo=http://oss.sonatype.org/content/repositories/snapshots #kotlinCompilerRepo=http://dl.bintray.com/kotlin/kotlin-dev kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20170818.205557-805 -konanVersion=0.3 +konanVersion=0.3.1 org.gradle.jvmargs='-Dfile.encoding=UTF-8' diff --git a/samples/build.sh b/samples/build.sh index bf214650b65..68e23e48676 100755 --- a/samples/build.sh +++ b/samples/build.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash EXCLUDE=() BUILD_SCRIPT="build.sh" diff --git a/samples/workers/README.md b/samples/workers/README.md new file mode 100644 index 00000000000..1c21ae9fc29 --- /dev/null +++ b/samples/workers/README.md @@ -0,0 +1,41 @@ +# Workers + + This example shows how one could implement computation offload to other workers +(usually mapped to OS threads) and transfer data back and forth between workers. +Idea of workers is to avoid most common problems with concurrent programming, related +to simultaneous computations on the same data. Instead, each object belongs to +one or other worker's object graph, but could be disconnected from one worker +and connected to other worker. This relies on fact that memory management +engine can ensure, that one worker doesn't keep references to certain object and +whatever it refers to, and so the object could be safely transferred to another worker. + +Workers do not share any state (i.e. globals and Kotlin static objects have different +values in different workers), but share executable code of the program and some +immutable data, such as immutable binary blobs. But Kotlin objects can be transferred +between workers, as long, as they do not refer to objects, having external references. + +The transfer is implemented with the function `schedule()` having the following signature + + fun + schedule(mode: TransferMode, + producer: () -> T1, + @VolatileLambda job: (T1) -> T2): Future + + Kotlin/Native runtime invokes `producer()` function, and makes sure object it produces +have a property, that no external references to subgraph rooted by this object, exists. +If property doesn't hold, either (depending on `mode` argument) exception is being thrown +or program may crash unexpectedly. + Then, pointer to stateless lambda `job` along with the stable pointer to parameter object +is being added to the target worker's queue, and `Future` object matching to the query +is being created. Once worker peeks the job from the queue, it executes stateless lambda +with object provided, and stores stable pointer to result in future's data. Whenever +future is being consumed, object is passed to the consumer's callback. + + This particular example starts several workers, and gives them some computational jobs. +Then it continues execution, and waits on future objects encapsulating the +computation results. Afterwards, worker execution termination is requested with the +`requestTermination()` operation. + +To build use `./build.sh`. + +To run use `./build/konan/bin/Worker.kexe` diff --git a/samples/workers/Workers.kt b/samples/workers/Workers.kt new file mode 100644 index 00000000000..cce4be4d6f8 --- /dev/null +++ b/samples/workers/Workers.kt @@ -0,0 +1,35 @@ +import konan.worker.* + +data class WorkerArgument(val intParam: Int, val stringParam: String) +data class WorkerResult(val intResult: Int, val stringResult: String) + +fun main(args: Array) { + val COUNT = 5 + val workers = Array(COUNT, { _ -> startWorker()}) + + for (attempt in 1 .. 3) { + val futures = Array(workers.size, { workerIndex -> workers[workerIndex].schedule(TransferMode.CHECKED, { + WorkerArgument(workerIndex, "attempt $attempt") }) { input -> + var sum = 0 + for (i in 0..input.intParam * 1000) { + sum += i + } + WorkerResult(sum, input.stringParam + " result") + } + }) + val futureSet = futures.toSet() + var consumed = 0 + while (consumed < futureSet.size) { + val ready = futureSet.waitForMultipleFutures(10000) + ready.forEach { + it.consume { result -> + if (result.stringResult != "attempt $attempt result") throw Error("Unexpected $result") + consumed++ } + } + } + } + workers.forEach { + it.requestTermination().consume { _ -> } + } + println("OK") +} diff --git a/samples/workers/build.sh b/samples/workers/build.sh new file mode 100755 index 00000000000..02f827fd7ec --- /dev/null +++ b/samples/workers/build.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +DIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd ) +PATH=$DIR/../../dist/bin:$DIR/../../bin:$PATH + +SUFFIX=kexe +if [ x$TARGET == x ]; then +case "$OSTYPE" in + darwin*) TARGET=macbook ;; + linux*) TARGET=linux ;; + msys*) TARGET=mingw; SUFFIX=exe ;; + *) echo "unknown: $OSTYPE" && exit 1;; +esac +fi + +var=CFLAGS_${TARGET} +CFLAGS=${!var} +var=LINKER_ARGS_${TARGET} +LINKER_ARGS=${!var} +var=COMPILER_ARGS_${TARGET} +COMPILER_ARGS=${!var} # add -opt for an optimized build. + +mkdir -p $DIR/build/bin/ + +konanc $COMPILER_ARGS -target $TARGET $DIR/Workers.kt \ + -o $DIR/build/bin/Workers || exit 1 + +echo "Artifact could be found at $DIR/build/bin/Workers.$SUFFIX"