- Install Gradle profiler
- Run
./gradlew createBuild
- Follow the instructions
./gradlew createBuild
generates a medium size Gradle build (120 modules, 121 gradle.kts scripts) under build/profile
.
Gradle profiler runs the build a few times, changing the ABI of a Kotlin class under buildSrc
before each run to ensure all Kotlin scripts need to be recompiled. At the end it should generate a flamegraph under ./build/flamegraph.
The interface between Gradle and the Kotlin script compiler is implemented in KotlinCompiler.kt.
It is worth noting how KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
system property is being used to workaround KT-35394
here. This has a very negative impact on performance, it would be much better to keep the Kotlin compiler environment alive for the duration of the whole build and dispose of it during buildFinished
. Is there some public or internal Kotlin compiler API we can use to accomplish that?