Replace reflection-based compiler arguments copying with generated code

Using of Kotlin reflection for simple operations like bean management is very slow

First time initialization time: 261 ms for `copyBean(K2JVMCompilerArguments())`
Subsequent calls of `copyBean(K2JVMCompilerArguments())` take 1.7 ms per call

Unfortunately compiler argument handling is also used in Kotlin IntelliJ plugin
to parse facet settings. Big projects may have thousands of Kotlin facets

The same `ArgumentUtilsKt.copyProperties` frame is seen across various freezes:
IDEA-252440 2-3 minutes freeze on Kotlin project reimporting in last 203 eap
IDEA-253107 A lot of short freezes (1-3 sec) during Kotlin project development
KTIJ-23501 Make main run configuration detection lighter
KTIJ-22435 Unresponsive UI with 100% cpu

Reflection issue:
KT-56358 KClasses.getMemberProperties takes too much time

This commit replaces all reflection stuff with a simple code generation
Now `K2JVMCompilerArguments().clone()` goes to hard-to-measure time
This commit is contained in:
Leonid Shalupov
2023-03-08 18:20:51 +01:00
parent 56557fb8ff
commit 7480befe32
34 changed files with 744 additions and 75 deletions
+3
View File
@@ -78,6 +78,7 @@ dependencies {
testImplementation(projectTests(":compiler:tests-common-new"))
testImplementation(projectTests(":js:js.tests"))
testImplementation(project(":kotlin-gradle-compiler-types"))
testImplementation(project(":jps:jps-common"))
testApiJUnit5()
if (Ide.IJ()) {
@@ -91,6 +92,8 @@ projectTest(parallel = true) {
workingDir = rootDir
}
val generateCompilerArgumentsCopy by generator("org.jetbrains.kotlin.generators.arguments.GenerateCompilerArgumentsCopyKt")
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateTestsKt") {
dependsOn(":generators:analysis-api-generator:generateFrontendApiTests")
}