Skip to content

Speedup integration testing pipeline #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ benchmark {
```

### Kotlin/JVM
| Option | Description | Possible Values | Default Value |
|---------------------------------------------|------------------------------------------------------------|----------------------------------------|----------------|
| `advanced("jvmForks", value)` | Specifies the number of times the harness should fork. | Non-negative Integer, `"definedByJmh"` | `1` |
| Option | Description | Possible Values | Default Value |
|---------------------------------------------|----------------------------------------------------------------------------|----------------------------------------|---------------|
| `advanced("jvmForks", value)` | Specifies the number of times the harness should fork. | Non-negative Integer, `"definedByJmh"` | `1` |
| `advanced("jmhIgnoreLock", value)` | Sets a value of the `jmh.ignoreLock` property during benchmarks execution. | `true`, `false` | unset |

**Notes on "jvmForks":**
- **0** - "no fork", i.e., no subprocesses are forked to run benchmarks.
Expand Down
5 changes: 5 additions & 0 deletions integration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ tasks.test {
}
systemProperty("minSupportedGradleVersion", libs.versions.minSupportedGradle.get())
systemProperty("minSupportedKotlinVersion", libs.versions.minSupportedKotlin.get())

val forks = project.providers.gradleProperty("testing.max.forks").orNull?.toInt()
?: (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)

maxParallelForks = forks
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package kotlinx.benchmark.integration

import kotlin.test.*

class AnnotationsValidationTest : GradleTest() {
abstract class AnnotationsValidationTest : GradleTest() {

private val platformBenchmarkTask = "nativeBenchmark"
protected val platformBenchmarkTask = "nativeBenchmark"

private fun executeBenchmark(
protected fun executeBenchmark(
benchmarkFunction: String? = null,
setupFunction: String? = null,
teardownFunction: String? = null,
Expand All @@ -26,7 +26,7 @@ class AnnotationsValidationTest : GradleTest() {
runJvmBenchmark(runner, jvmSpecificError)
}

private fun runPlatformBenchmark(runner: Runner, error: String?) {
protected fun runPlatformBenchmark(runner: Runner, error: String?) {
if (error != null) {
runner.runAndFail(platformBenchmarkTask) {
assertOutputContains(error)
Expand All @@ -38,7 +38,7 @@ class AnnotationsValidationTest : GradleTest() {
}
}

private fun runJvmBenchmark(runner: Runner, jvmSpecificError: String?) {
protected fun runJvmBenchmark(runner: Runner, jvmSpecificError: String?) {
if (jvmSpecificError != null) {
runner.runAndFail("jvmBenchmark") {
assertOutputContains(jvmSpecificError)
Expand All @@ -49,7 +49,9 @@ class AnnotationsValidationTest : GradleTest() {
}
}
}
}

class ParamAnnotationsValidationTest : AnnotationsValidationTest() {
// @Param

@Test
Expand Down Expand Up @@ -142,7 +144,9 @@ class AnnotationsValidationTest : GradleTest() {
jvmSpecificError = "@Param can only be placed over the annotation-compatible types: primitives, primitive wrappers, Strings, or enums."
)
}
}

class BenchmarkAnnotationsValidationTest : AnnotationsValidationTest() {
// @Benchmark

@Test
Expand Down Expand Up @@ -204,7 +208,9 @@ class AnnotationsValidationTest : GradleTest() {
jvmSpecificError = "Method parameters should be either @State classes"
)
}
}

class SetupAnnotationsValidationTest : AnnotationsValidationTest() {
// @Setup

@Test
Expand Down Expand Up @@ -271,7 +277,9 @@ class AnnotationsValidationTest : GradleTest() {
jvmSpecificError = "Method parameters should be either @State classes"
)
}
}

class TearDownAnnotationsValidationTest : AnnotationsValidationTest() {
// TearDown

@Test
Expand Down Expand Up @@ -338,7 +346,9 @@ class AnnotationsValidationTest : GradleTest() {
jvmSpecificError = "Method parameters should be either @State classes"
)
}
}

class MixedAnnotationsValidationTest : AnnotationsValidationTest() {
// Mix

@Test
Expand All @@ -365,4 +375,4 @@ class AnnotationsValidationTest : GradleTest() {
teardownFunction = "plainFunction"
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ConfigurationCacheTest : GradleTest() {
iterations = 1
iterationTime = 100
iterationTimeUnit = "ms"
advanced("jmhIgnoreLock", true)
}
}

Expand All @@ -36,7 +37,7 @@ class ConfigurationCacheTest : GradleTest() {
fun testConfigurationCacheNative() = runConfigurationCacheTest(
"kotlin-multiplatform",
listOf(":nativeBenchmark"),
listOf(":compileKotlinNative", ":nativeBenchmarkGenerate", ":compileNativeBenchmarkKotlinNative", ":linkNativeBenchmarkReleaseExecutableNative")
listOf(":compileKotlinNative", ":nativeBenchmarkGenerate", ":compileNativeBenchmarkKotlinNative", ":linkNativeBenchmarkDebugExecutableNative")
)

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class OptionsOverrideAnnotationsTest : GradleTest() {
@Test
fun testOutputTimeUnit() {
val expectedOutputTimeUnit = "ns"
val expectedCount = /*warmups*/3 + /*iterations*/5 + /*Success:*/1 + /*summary*/1
val expectedCount = /*warmups*/2 + /*iterations*/1 + /*Success:*/1 + /*summary*/1

testConfiguration(
setupBlock = {
Expand All @@ -110,7 +110,7 @@ class OptionsOverrideAnnotationsTest : GradleTest() {
@Test
fun testMode() {
val expectedMode = "avgt"
val expectedCount = /*warmups*/3 + /*iterations*/5 + /*Success:*/1 + /*summary*/1
val expectedCount = /*warmups*/2 + /*iterations*/1 + /*Success:*/1 + /*summary*/1

testConfiguration(
setupBlock = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ class OptionsValidationTest : GradleTest() {
iterationTimeUnit = "ms"
advanced("jsUseBridge", "x")
}

configuration("invalidJmhIgnoreLock") {
iterations = 1
iterationTime = 100
iterationTimeUnit = "ms"
advanced("jmhIgnoreLock", "x")
}
}

runner.runAndFail("blankAdvancedConfigNameBenchmark") {
Expand All @@ -260,6 +267,9 @@ class OptionsValidationTest : GradleTest() {
runner.runAndFail("invalidJsUseBridgeBenchmark") {
assertOutputContains("Invalid value for 'jsUseBridge': 'x'. Expected a Boolean value.")
}
runner.runAndFail("invalidJmhIgnoreLock") {
assertOutputContains("Invalid value for 'jmhIgnoreLock': 'x'. Expected a Boolean value.")
}
}
}

Expand All @@ -274,4 +284,4 @@ private object ValidOptions {
)
val modes = setOf("thrpt", "avgt", "Throughput", "AverageTime")
val nativeForks = setOf("perBenchmark", "perIteration")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ReportFormatTest : GradleTest() {
iterationTime = 100
iterationTimeUnit = "ms"
reportFormat = format
advanced("jmhIgnoreLock", true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class SourceSetAsBenchmarkTargetTest : GradleTest() {
iterationTime = 100
iterationTimeUnit = "ms"
reportFormat = "csv"
advanced("jmhIgnoreLock", true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SuiteSourceGeneratorTest : GradleTest() {
}
},
checkBlock = {
val parameters = "iterations = 12, warmups = 5, iterationTime = IterationTime\\(200, BenchmarkTimeUnit.MILLISECONDS\\)"
val parameters = "iterations = 12, warmups = 2, iterationTime = IterationTime\\(200, BenchmarkTimeUnit.MILLISECONDS\\)"
assertGeneratedDescriptorContainsCode(parameters)
}
)
Expand All @@ -44,7 +44,7 @@ class SuiteSourceGeneratorTest : GradleTest() {
},
checkBlock = {
// time and timeUnit of @Warmup are ignored: https://github.com/Kotlin/kotlinx-benchmark/issues/74
val parameters = "iterations = 3, warmups = 12, iterationTime = IterationTime\\(1, BenchmarkTimeUnit.SECONDS\\)"
val parameters = "iterations = 1, warmups = 12, iterationTime = IterationTime\\(1, BenchmarkTimeUnit.SECONDS\\)"
assertGeneratedDescriptorContainsCode(parameters)
}
)
Expand Down Expand Up @@ -183,4 +183,4 @@ class SuiteSourceGeneratorTest : GradleTest() {
runner.runAndSucceed(":compile${capitalizedTarget}BenchmarkKotlin${capitalizedTarget}")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.konan.target.HostManager

Expand All @@ -17,6 +18,15 @@ benchmark {
register("jvm")
register("js")
register("wasmJs")
register("native")
register("native") {
// don't optimize binaries to speedup test execution
buildType = NativeBuildType.DEBUG
}
}

configurations {
main {
advanced("jmhIgnoreLock", true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import kotlinx.benchmark.*
import kotlin.math.*

@State(Scope.Benchmark)
@Measurement(iterations = 3, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS)
@Warmup(iterations = 5, time = 500, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Measurement(iterations = 1, time = 1500, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 500, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.Throughput)
open class CommonBenchmark {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.konan.target.HostManager

Expand All @@ -17,6 +18,15 @@ benchmark {
register("jvm")
register("js")
register("wasmJs")
register("native")
register("native") {
// don't optimize binaries to speedup test execution
buildType = NativeBuildType.DEBUG
}
}

configurations {
main {
advanced("jmhIgnoreLock", true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import kotlinx.benchmark.*
import kotlin.math.*

@State(Scope.Benchmark)
@Measurement(iterations = 3, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS)
@Warmup(iterations = 5, time = 500, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Measurement(iterations = 1, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS)
@Warmup(iterations = 2, time = 500, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.Throughput)
open class CommonBenchmark {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import kotlinx.benchmark.*
import kotlin.math.*

@State(Scope.Benchmark)
@Measurement(iterations = 3, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS)
@Measurement(iterations = 1, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS)
@Warmup(iterations = 1, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS)
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.Throughput)
open class CommonBenchmark {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ benchmark {
targets {
register("jvm")
}

configurations {
main {
advanced("jmhIgnoreLock", true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ benchmark {
targets {
register("jvm")
}

configurations {
main {
advanced("jmhIgnoreLock", true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ benchmark {
register("jvmCustom")
register("jsCustom")
}

configurations {
main {
advanced("jmhIgnoreLock", true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import kotlinx.benchmark.*
import kotlin.math.*

@State(Scope.Benchmark)
@Warmup(iterations = 2, time = 100, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Measurement(iterations = 3, time = 200, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Measurement(iterations = 1, time = 200, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS)
open class JsCustomBenchmark {
@Benchmark
open fun hashCodeBenchmark(): Int {
val value = log(sqrt(3.0) * cos(3.0), 2.0)
return JsTestData(CommonTestData(value)).hashCode()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import kotlinx.benchmark.*
import kotlin.math.*

@State(Scope.Benchmark)
@Warmup(iterations = 2, time = 100, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Measurement(iterations = 3, time = 200, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Warmup(iterations = 1, time = 100, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@Measurement(iterations = 1, time = 200, timeUnit = BenchmarkTimeUnit.MILLISECONDS)
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS)
open class JvmCustomBenchmark {
@Benchmark
open fun hashCodeBenchmark(): Int {
val value = log(sqrt(3.0) * cos(3.0), 2.0)
return JvmTestData(CommonTestData(value)).hashCode()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.konan.target.KonanTarget
import org.jetbrains.kotlin.konan.target.HostManager

Expand All @@ -17,6 +18,15 @@ benchmark {
register("jvm")
register("js")
register("wasmJs")
register("native")
register("native") {
// don't optimize binaries to speedup test execution
buildType = NativeBuildType.DEBUG
}
}

configurations {
main {
advanced("jmhIgnoreLock", true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kotlinx.benchmark.*
import kotlin.math.*

@State(Scope.Benchmark)
@Measurement(iterations = 3, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS)
@Measurement(iterations = 1, time = 1, timeUnit = BenchmarkTimeUnit.SECONDS)
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS)
@BenchmarkMode(Mode.Throughput)
open class CommonBenchmark {
Expand Down
Loading