Andrew Louis
02/22/2023, 2:28 PMcompileKotlin
task times -- it takes up to a minimum of 3 minutes each time a Kotlin file is changed in the main sourceset 😢
• Build caching is enabled -- with a Gradle build cache node in use (cache is fresh and definitely getting hits, used the cache debug flag to verify)
• Heap alloc is pretty high
◦ org.gradle.jvmargs=-Xmx8g -Dkotlin.daemon.jvm.options=-Xmx6g
• It's a single module project @ around 80k LOC
Please let me know what some options are to try and troubleshoot the task closer -- I tried using the profile & scan flags, but it didn't really break down what the task was spending its time doingJavier
02/22/2023, 2:35 PMAndrew Louis
02/22/2023, 2:35 PMAndrew Louis
02/22/2023, 2:35 PMcompileKotlin
is the longest running taskAndrew Louis
02/22/2023, 2:36 PMVampire
02/22/2023, 2:49 PMVampire
02/22/2023, 2:50 PMephemient
02/22/2023, 2:51 PMkotlinc
for comparisonephemient
02/22/2023, 2:58 PMAndrew Louis
02/22/2023, 3:11 PMkotlinc
idea is pretty interesting, didn't consider it -- can definitely give it a stab for reference.
That was an interesting thread to read; I have no idea how that author narrowed it down to that method -- he doesn't seem to discuss it there
I just checked, and we don't have any implementations of Comparable that we do ourselvesAdam S
02/22/2023, 3:49 PMtapchicoma
02/22/2023, 4:45 PMif it's a single module, it should be doable to build up a argument list to run the command line kotlinc for comparisonIt is possible to get them from debug logs
tapchicoma
02/22/2023, 4:45 PMtapchicoma
02/22/2023, 4:46 PMtapchicoma
02/22/2023, 4:47 PMtapchicoma
02/22/2023, 4:48 PMAndrew Louis
02/22/2023, 4:52 PMIt is possible to get them from debug logsOh nice, will try it and report back later today Re - build reports - yes, will do! Let me enable it and share shortly Regarding a repro, not sure if this is possible at the moment, but will loop back. Can do an attempt at generate something minimal, but I'm not confident I'll be able to do an open repro (company codebase) 🤔 Will have to look at some options here and get back to you
tapchicoma
02/22/2023, 4:53 PMAndrew Louis
02/22/2023, 5:29 PMbuild_scan
report output:
A couple of weird observations:
• There's something pretty funny there -- Connect to Kotlin daemon: 47365ms
??
• Also, it's flagged as NON_INCREMENTAL
blob thinking upside downtapchicoma
02/22/2023, 5:31 PMNON_INCREMENTAL
could be because you run clean
before or changed build classpathAndrew Louis
02/22/2023, 5:31 PMtapchicoma
02/22/2023, 5:38 PMAndrew Louis
02/22/2023, 5:38 PMAndrew Louis
02/22/2023, 5:39 PMtapchicoma
02/22/2023, 5:39 PMtapchicoma
02/22/2023, 5:41 PMtapchicoma
02/22/2023, 5:42 PMAndrew Louis
02/22/2023, 5:50 PMopenjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment Zulu16.32+15-CA (build 16.0.2+7)
OpenJDK 64-Bit Server VM Zulu16.32+15-CA (build 16.0.2+7, mixed mode)
I believe soAndrew Louis
02/22/2023, 5:51 PMAlexander.Likhachev
02/22/2023, 6:01 PMjava -XshowSettings:properties -version 2> >(grep "os.arch")
in terminal, will it print os.arch = x86_64
or os.arch = aarch64
?Andrew Louis
02/22/2023, 6:01 PMAlexander.Likhachev
02/22/2023, 6:02 PMx86_64
is expected to be slowerAndrew Louis
02/22/2023, 6:02 PMVampire
02/22/2023, 6:04 PM>(grep ...)
instead of | grep ...
?Alexander.Likhachev
02/22/2023, 6:05 PMephemient
02/22/2023, 6:06 PM2>&1 | grep
thenVampire
02/22/2023, 6:06 PM2> >(grep ...)
feeds fd 2 to the subshell?
Interesting.
I would have done 2>&1 | grep ...
.
TIL, thanksephemient
02/22/2023, 6:08 PM>()
process substitution so sometimes its output will be delayed until after the next terminal prompt has already come up :-/Vampire
02/22/2023, 6:09 PMAndrew Louis
02/22/2023, 6:16 PMcompileKotlin
https://scans.gradle.com/s/uajg3nzz2paugAndrew Louis
02/22/2023, 6:26 PM80k LOC
not 80 LOC
😂 in case that threw anyoneVampire
02/22/2023, 6:27 PMephemient
02/22/2023, 6:27 PMVampire
02/22/2023, 6:27 PMAndrew Louis
02/22/2023, 6:30 PMAndrew Louis
02/22/2023, 6:31 PMtapchicoma
02/22/2023, 7:14 PMIs the 2-3 minutes within reason in that light?For clean build I would say yes
rrva
02/22/2023, 8:10 PMval isCiServer = System.getenv().containsKey("CI")
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.useK2 = !isCiServer
}
or in 1.8.20+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
if(!isCiServer) {
languageVersion = "2.0"
}
}
}
• Use the incremental compilation support, it will be default in 1.8.20
https://blog.jetbrains.com/kotlin/2022/07/a-new-approach-to-incremental-compilation-in-kotlin/
• Use the multithreaded compilation mode
-Xbackend-threads=0semoro
02/22/2023, 10:00 PMAndrew Louis [8:16 PM]
@Yahor - with JDK 17, seems like a big boost - 1 minute 30 on the first run ofPlease use JDK built for aarch64, not x86 You are running it through Rosetta, which affects performance noticeablycompileKotlin
Andrew Louis
02/22/2023, 10:02 PMsemoro
02/22/2023, 10:06 PMtapchicoma
02/22/2023, 10:09 PMAndrew Louis
02/22/2023, 10:09 PMKind
column in Activity Monitor shows Apple for my java processesAndrew Louis
02/22/2023, 10:10 PMAndrew Louis
02/23/2023, 12:15 AMtapchicoma
02/23/2023, 9:32 AMtasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask<*>>().configureEach {
compilerOptions.languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
}
Andrew Louis
02/23/2023, 12:19 PMjava.lang.Class<T>
:
OrgSettings.kt:82:226 Argument type mismatch: actual type is java/lang/Class<java/lang/Module> but java/lang/Class<ft<U & Any, U?>>! was expected
tapchicoma
02/23/2023, 1:47 PMAndrew Louis
02/23/2023, 2:09 PM