Skip to content
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

Adjust Gradle memory settings #3464

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
12 changes: 6 additions & 6 deletions build-logic/src/main/kotlin/dokkabuild.java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ java {
tasks.withType<Test>().configureEach {
useJUnitPlatform()

maxParallelForks = if (System.getenv("GITHUB_ACTIONS") != null) {
Runtime.getRuntime().availableProcessors()
} else {
(Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
}

javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(dokkaBuild.testJavaLauncherVersion)
})

maxParallelForks = if (System.getenv("CI") != null) {
Runtime.getRuntime().availableProcessors()
} else {
(Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
}
Comment on lines +27 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
maxParallelForks = if (System.getenv("CI") != null) {
Runtime.getRuntime().availableProcessors()
} else {
(Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
}
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now GHA upgrades to 4-core runners, we can tweak this option a bit.

}

dependencies {
Expand Down
43 changes: 36 additions & 7 deletions build-logic/src/main/kotlin/dokkabuild.test-integration.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ val integrationTestRuntimeOnly: Configuration by configurations.getting {
abstract class NonCacheableIntegrationTest : Test()

val integrationTest by tasks.registering(NonCacheableIntegrationTest::class) {
maxHeapSize = "2G"

// quite high memory because Dokka is a hungry boy
maxHeapSize = "4g"
jvmArgs = listOf(
"-XX:MetaspaceSize=1g",
"-XX:+HeapDumpOnOutOfMemoryError",
)

description = "Runs integration tests."
group = "verification"
testClassesDirs = integrationTestSourceSet.output.classesDirs
Expand All @@ -53,18 +60,40 @@ val integrationTest by tasks.registering(NonCacheableIntegrationTest::class) {
useJUnitPlatform {
if (dokkaBuild.integrationTestUseK2.get()) excludeTags("onlyDescriptors", "onlyDescriptorsMPP")
}
// allow inspecting projects in temporary dirs after a test fails
systemProperty(
// TODO quick hacks - remove this, will be done in a different PR
"junit.jupiter.tempdir.cleanup.mode.default",
if (System.getenv("CI") != null) "ALWAYS" else "ON_SUCCESS",
)

systemProperty("org.jetbrains.dokka.experimental.tryK2", dokkaBuild.integrationTestUseK2.get())

dokkaBuild.integrationTestParallelism.orNull?.let { parallelism ->
maxParallelForks = parallelism
}

environment("isExhaustive", dokkaBuild.integrationTestExhaustive.get())


// TODO quick hacks - remove this, will be done in a different PR
environment("ANDROID_SDK_ROOT",
providers
// first try finding a local.properties file in any parent directory
.provider {
generateSequence(layout.projectDirectory.asFile, File::getParentFile)
.mapNotNull { dir -> dir.resolve("local.properties").takeIf(File::exists) }
.flatMap { file -> file.readLines().filter { it.startsWith("sdk.dir=") } }
.firstOrNull()
?.substringAfter("sdk.dir=")
}
// else try getting pre-installed SDK (e.g. via GitHub step setup-android)
.orElse(providers.environmentVariable("ANDROID_SDK_ROOT"))
.orElse(providers.environmentVariable("ANDROID_HOME"))
.map(::File).get().invariantSeparatorsPath)

testLogging {
exceptionFormat = TestExceptionFormat.FULL
events(TestLogEvent.SKIPPED, TestLogEvent.FAILED)
events(
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.FAILED,
)
showExceptions = true
showCauses = true
showStackTraces = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ abstract class DokkaBuildProperties @Inject constructor(
val kotlinLanguageLevel: Provider<KotlinVersion> =
dokkaProperty("kotlinLanguageLevel", KotlinVersion::fromVersion)

/** Control [org.gradle.api.tasks.testing.Test.maxParallelForks] in integration tests. */
val integrationTestParallelism: Provider<Int> =
dokkaProperty("integration_test.parallelism", String::toInt)

/** Not currently used - should be dropped. */
val integrationTestExhaustive: Provider<Boolean> =
dokkaProperty("integration_test.exhaustive", String::toBoolean)
Expand Down
4 changes: 3 additions & 1 deletion dokka-integration-tests/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ version=2.0.0-SNAPSHOT

org.jetbrains.dokka.javaToolchain.mainCompiler=8
org.jetbrains.dokka.javaToolchain.testLauncher=8
org.jetbrains.dokka.integration_test.parallelism=2

# Gradle settings
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx8g -XX:MaxMetaspaceSize=4g -XX:+HeapDumpOnOutOfMemoryError
1 change: 0 additions & 1 deletion dokka-integration-tests/gradle/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
**/gradle/wrapper/**
gradlew.bat
gradlew
gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
dokka_it_kotlin_version=1.9.22
dokka_it_android_gradle_plugin_version=4.2.2
android.useAndroidX=true

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
#

dokka_it_kotlin_version=1.9.22

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
#

dokka_it_kotlin_version=1.9.22

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
#

dokka_it_kotlin_version=1.9.22

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
dokka_it_kotlin_version=1.9.22
fail_on_warning=false
report_undocumented=false

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@

dokka_it_kotlin_version=1.9.22
react_version=18.2.0-pre.467

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
#

dokka_it_kotlin_version=1.9.22

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
#

dokka_it_kotlin_version=1.9.22

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#
# Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
# Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
#

dokka_it_kotlin_version=1.9.20

org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1g
#kotlin.compiler.execution.strategy=in-process
Binary file not shown.

This file was deleted.

This file was deleted.

Loading
Loading