From 3ccca58bb010c1d9b57d7cbf2c016e8ff99de099 Mon Sep 17 00:00:00 2001 From: "Alexander.Likhachev" Date: Tue, 21 Nov 2023 10:02:41 +0100 Subject: [PATCH] [Gradle] Release daemon compile session at a compilation task's finish Before this change, some long-running tasks like `run` might cause the Kotlin daemon to go into the LastSession state and stay in that state until the long-running tasks and therefore the Gradle build are finished. The reason for that behaviour is that if we don't release sessions explicitly, the created "session is alive" marker files are cleaned up by `KotlinGradleFinishBuildHandler.buildFinished` at the end of the build. ^KT-55322 In Progress --- .../kotlin/compilerRunner/GradleKotlinCompilerWork.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt index 291c7515c05..29eb8594874 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt @@ -250,10 +250,11 @@ internal class GradleKotlinCompilerWork @Inject constructor( // TODO: implement a proper logic to avoid remote calls in such cases try { metrics.measure(GradleBuildTime.CLEAR_JAR_CACHE) { - daemon.clearJarCache() + // releasing compile session implies clearing the jar cache + daemon.releaseCompileSession(sessionId) } } catch (e: RemoteException) { - log.warn("Unable to clear jar cache after compilation, maybe daemon is already down: $e") + log.warn("Unable to release compile session, maybe daemon is already down: $e") } } log.logFinish(KotlinCompilerExecutionStrategy.DAEMON)