Yang
03/27/2024, 10:51 AMKotlinCompile
totalling 30m 17.942s
-> 46m 7.145s
• KaptGenerateStubsTask
totalling 8m 32.377s
-> 23m 35.496s
• KaptWithoutKotlincTask
totalling 9m 56.293s
-> 11m 14.002s
• KspTaskJvm
totalling 6m 19.561s
-> 22m 56.832s
Looking at the individual modules / tasks the ones that are significant slower with K2 seem quite random. E.g. while some bigger module are 40% faster with K2, many tiny modules’ KotlinCompile tasks are order of magnitude slower with K2 e.g. 0.5s
> 33s
.
I’ll dig a bit more and create an issue on youtrack.tapchicoma
03/27/2024, 11:04 AMJavier
03/27/2024, 11:11 AMtapchicoma
03/27/2024, 11:15 AMtapchicoma
03/27/2024, 11:17 AMtapchicoma
03/27/2024, 11:28 AMYang
03/27/2024, 11:50 AMYang
03/27/2024, 11:53 AMkotlin.daemon.jvmargs
, and also using Parallel GC as it has better throughput.
I just did another run giving kotlin daemon more RAM but not seeing any difference.tapchicoma
03/27/2024, 11:54 AMtapchicoma
03/27/2024, 11:55 AMtapchicoma
03/27/2024, 11:55 AMYang
03/27/2024, 11:58 AMYang
03/27/2024, 11:58 AMtapchicoma
03/27/2024, 12:07 PMtapchicoma
03/27/2024, 12:07 PMKotlinCompile
task compiles?Yang
03/27/2024, 12:07 PMReservedCodeCacheSize
and UseCodeCacheFlushing
as mentioned in the issue aboveYang
03/27/2024, 12:08 PMsemoro
03/27/2024, 12:09 PMJava HotSpot(TM) 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
tapchicoma
03/27/2024, 12:10 PMtapchicoma
03/27/2024, 12:11 PMYang
03/27/2024, 12:18 PMYang
03/27/2024, 12:26 PMbtw how many lines of code yourtask compiles?KotlinCompile
736,914
lines of kotlin code excluding tests in the codebase, the build probably compiles a bit less as a few modules are not part of the buildYang
03/28/2024, 1:13 AMTime metrics:
Total Gradle task time: 6,414.13 s
Spent time before task action: 105.78 s
Task action before worker execution: 46.98 s
Run compilation in Gradle worker: 2,210.44 s
Clear jar cache: 0.01 s
Clear output: 0.01 s
Connect to Kotlin daemon: 4.84 s
Run compilation: 1,944.98 s
Non incremental compilation in daemon: 259.38 s
Incremental compilation in daemon: 1,941.22 s
Update caches: 11.33 s
Sources compilation round: 1,842.27 s
Compiler initialization time: 27.49 s
Compiler code analysis: 1,283.67 s
Compiler code generation: 289.86 s
Compiler IR translation: 239.95 s
Compiler IR lowering: 125.25 s
Compiler IR generation: 164.45 s
Shrink and save current classpath snapshot after compilation: 21.55 s
Shrink current classpath snapshot non-incrementally: 20.52 s
Load current classpath snapshot: 4.24 s
Save shrunk current classpath snapshot: 0.39 s
Start gradle worker: 6.12 s
Classpath entry snapshot transform: 15.76 s
Load classes (paths only): 0.13 s
Snapshot classes: 14.28 s
Load contents of classes: 3.39 s
Snapshot Kotlin classes: 4.22 s
Snapshot Java classes: 3.15 s
Save classpath entry snapshot: 0.77 s
Size metrics:
Total size of the cache directory: 28.8 KB
ABI snapshot size: 22.1 KB
Increase memory usage: 56.6 GB
Total memory usage at the end of build: 2,261.9 GB
Total compiler iteration: 461
Number of lines analyzed: 2872517
Number of lines for code generation: 1660623
Analysis lines per second: 842447
Code generation lines per second: 1481243
Compiler IR translation line number: 1660623
Compiler IR lowering line number: 1660623
Compiler IR generation line number: 1660623
Number of times 'ClasspathEntrySnapshotTransform' ran: 1058
Size of jar classpath entry: 859.1 MB
Size of jar classpath entry's snapshot: 185.2 MB
Size of directory classpath entry's snapshot: 8 B
Number of times classpath snapshot is shrunk and saved after compilation: 461
Number of classpath entries: 51167
Size of classpath snapshot: 4.5 GB
Size of shrunk classpath snapshot: 110.5 MB
Number of times classpath snapshot is loaded: 461
Number of cache hits when loading classpath entry snapshots: 49951
Number of cache misses when loading classpath entry snapshots: 1216
Start time of task action: 35489-01-24T03:32:46
Build attributes:
REBUILD_REASON:
Incremental compilation is not enabled(157)
Unknown Gradle changes(461)
K2
Time metrics:
Total Gradle task time: 9,387.18 s
Spent time before task action: 128.09 s
Task action before worker execution: 722.05 s
Run compilation in Gradle worker: 4,451.58 s
Clear jar cache: 719.40 s
Connect to Kotlin daemon: 558.17 s
Calculate output size: 0.41 s
Run compilation: 863.79 s
Non incremental compilation in daemon: 1,071.88 s
Incremental compilation in daemon: 859.37 s
Update caches: 3.81 s
Sources compilation round: 810.02 s
Compiler initialization time: 8.99 s
Compiler code analysis: 344.75 s
Compiler code generation: 252.20 s
Compiler IR translation: 201.40 s
Compiler IR lowering: 118.02 s
Compiler IR generation: 134.03 s
Write history file: 0.01 s
Shrink and save current classpath snapshot after compilation: 13.69 s
Shrink current classpath snapshot non-incrementally: 13.00 s
Load current classpath snapshot: 3.21 s
Save shrunk current classpath snapshot: 0.26 s
Start gradle worker: 20.65 s
Size metrics:
Total size of the cache directory: 355.7 MB
ABI snapshot size: 15.2 KB
Increase memory usage: -8572176912 B
Total memory usage at the end of build: 1,993.0 GB
Total compiler iteration: 317
Number of lines analyzed: 1682046
Number of lines for code generation: 1682046
Analysis lines per second: 1134781
Code generation lines per second: 1680855
Compiler IR translation line number: 1682046
Compiler IR lowering line number: 1682046
Compiler IR generation line number: 1682046
Number of times classpath snapshot is shrunk and saved after compilation: 317
Number of classpath entries: 32662
Size of classpath snapshot: 2.8 GB
Size of shrunk classpath snapshot: 73.4 MB
Number of times classpath snapshot is loaded: 317
Number of cache hits when loading classpath entry snapshots: 31015
Number of cache misses when loading classpath entry snapshots: 1647
Start time of task action: 35706-01-09T22:38:56
Build attributes:
REBUILD_REASON:
Incremental compilation is not enabled(305)
Unknown Gradle changes(317)
Yang
03/28/2024, 1:16 AMClear jar cache: 719.40 s
Connect to Kotlin daemon: 558.17 s
tapchicoma
03/28/2024, 8:40 AMClear jar cache
issue should be fixed in RC1: https://youtrack.jetbrains.com/issue/KT-66912/Parallel-compilation-slowdown-due-to-synchronizationtapchicoma
03/28/2024, 8:40 AMConnect to Kotlin daemon
is indeed looks suspiciousYang
03/28/2024, 9:34 AM-Xbackend-threads
in K1?tapchicoma
03/28/2024, 9:35 AMYang
03/28/2024, 9:35 AMdniHze
03/28/2024, 11:52 AMorg.gradle.jvmargs=-Xmx12g -XX:MaxMetaspaceSize=1g -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Task measured against;
./gradlew appassembleDebug --no-build-cache --rerun-tasks`
Interesting finding; Task count went down, but configuration time is slightly up, and the whole run takes longer too. I'm attaching measured numbers here:dniHze
03/28/2024, 11:54 AMtapchicoma
03/28/2024, 11:56 AMdniHze
03/28/2024, 11:58 AMdniHze
03/28/2024, 1:16 PMTime metrics:
Total Gradle task time: 1,951.88 s
Spent time before task action: 43.75 s
Task action before worker execution: 66.76 s
Run compilation in Gradle worker: 1,265.35 s
Clear jar cache: 0.37 s
Clear output: 1.08 s
Connect to Kotlin daemon: 20.64 s
Calculate output size: 0.52 s
Run compilation: 701.88 s
Non incremental compilation in daemon: 539.84 s
Incremental compilation in daemon: 690.11 s
Store build info: 0.19 s
Clear outputs on rebuild: 0.15 s
Update caches: 2.40 s
Sources compilation round: 436.16 s
Compiler initialization time: 29.50 s
Compiler code analysis: 210.98 s
Compiler code generation: 102.16 s
Compiler IR translation: 91.21 s
Compiler IR lowering: 37.09 s
Compiler IR generation: 64.80 s
Write history file: 0.09 s
Shrink and save current classpath snapshot after compilation: 10.80 s
Shrink current classpath snapshot non-incrementally: 8.43 s
Load current classpath snapshot: 2.32 s
Save shrunk current classpath snapshot: 1.64 s
Start gradle worker: 0.91 s
Classpath entry snapshot transform: 0.80 s
Load classes (paths only): 0.00 s
Snapshot classes: 0.58 s
Load contents of classes: 0.03 s
Snapshot Kotlin classes: 0.35 s
Snapshot Java classes: 0.02 s
Save classpath entry snapshot: 0.13 s
Size metrics:
Total size of the cache directory: 182.9 KB
ABI snapshot size: 25.5 KB
Increase memory usage: 67.5 GB
Total memory usage at the end of build: 1,438.9 GB
Total compiler iteration: 532
Number of lines analyzed: 372887
Number of lines for code generation: 348003
Analysis lines per second: 792399
Code generation lines per second: 1845299
Compiler IR translation line number: 348003
Compiler IR lowering line number: 348003
Compiler IR generation line number: 348003
Number of times 'ClasspathEntrySnapshotTransform' ran: 117
Size of jar classpath entry: 6.1 MB
Size of jar classpath entry's snapshot: 4.8 MB
Number of times classpath snapshot is shrunk and saved after compilation: 532
Number of classpath entries: 40328
Size of classpath snapshot: 2.4 GB
Size of shrunk classpath snapshot: 56.9 MB
Number of times classpath snapshot is loaded: 532
Number of cache hits when loading classpath entry snapshots: 38604
Number of cache misses when loading classpath entry snapshots: 1724
Start time of task action: 51219-05-29T15:21:28
Build attributes:
REBUILD_REASON:
Incremental compilation is not enabled(376)
Unknown Gradle changes(532)
Total time for Kotlin tasks: 848.11 s (43.4 % of all tasks time)
K2:
Time metrics:
Total Gradle task time: 1,832.97 s
Spent time before task action: 39.77 s
Task action before worker execution: 132.85 s
Run compilation in Gradle worker: 1,150.10 s
Clear jar cache: 98.55 s
Clear output: 0.81 s
Connect to Kotlin daemon: 60.17 s
Calculate output size: 0.67 s
Run compilation: 409.01 s
Non incremental compilation in daemon: 339.85 s
Incremental compilation in daemon: 402.02 s
Store build info: 0.11 s
Clear outputs on rebuild: 0.07 s
Update caches: 0.82 s
Sources compilation round: 295.71 s
Compiler initialization time: 14.49 s
Compiler code analysis: 125.92 s
Compiler code generation: 74.05 s
Compiler IR translation: 78.73 s
Compiler IR lowering: 32.72 s
Compiler IR generation: 41.06 s
Write history file: 0.02 s
Shrink and save current classpath snapshot after compilation: 7.39 s
Shrink current classpath snapshot non-incrementally: 5.90 s
Load current classpath snapshot: 1.70 s
Save shrunk current classpath snapshot: 0.89 s
Start gradle worker: 1.27 s
Size metrics:
Total size of the cache directory: 297.1 MB
ABI snapshot size: 25.5 KB
Increase memory usage: 35.4 GB
Total memory usage at the end of build: 1,664.2 GB
Total compiler iteration: 532
Number of lines analyzed: 378782
Number of lines for code generation: 353898
Analysis lines per second: 1469265
Code generation lines per second: 2615244
Compiler IR translation line number: 353898
Compiler IR lowering line number: 353898
Compiler IR generation line number: 353898
Number of times classpath snapshot is shrunk and saved after compilation: 532
Number of classpath entries: 40328
Size of classpath snapshot: 2.4 GB
Size of shrunk classpath snapshot: 140.4 MB
Number of times classpath snapshot is loaded: 532
Number of cache hits when loading classpath entry snapshots: 39006
Number of cache misses when loading classpath entry snapshots: 1322
Start time of task action: 51219-05-22T06:24:44
Build attributes:
REBUILD_REASON:
Incremental compilation is not enabled(376)
Unknown Gradle changes(532)
Total time for Kotlin tasks: 815.52 s (44.5 % of all tasks time)
tapchicoma
04/03/2024, 5:26 PM2.0.0-RC1
releasedniHze
04/03/2024, 5:58 PMtapchicoma
04/03/2024, 5:59 PMtapchicoma
04/09/2024, 11:48 AMYang
04/09/2024, 12:42 PMYang
04/09/2024, 12:43 PMtapchicoma
04/09/2024, 1:13 PMdniHze
04/09/2024, 1:16 PMtapchicoma
04/09/2024, 1:17 PMkotlin.git
dniHze
04/09/2024, 1:18 PMYang
04/12/2024, 3:08 AM| Task | Kotlin 1.9.23 | Kotlin 2.0.0-Beta5 | Kotlin 2.0.0-RC1 |
|---------------------------|-----------------|--------------------|------------------|
| **KotlinCompile** | 30m 17.942s | 46m 7.145s | 20m 48.478s |
| **KaptGenerateStubsTask** | 8m 32.377s | 23m 35.496s | 18m 14.579s |
| **KaptWithoutKotlincTask**| 9m 56.293s | 11m 14.002s | 12m 12.981s |
| **KspTaskJvm** | 6m 19.561s | 22m 56.832s | 7m 10.953s |
Yang
04/12/2024, 3:10 AMkapt.use.k2=true
Yang
04/12/2024, 3:11 AMTime metrics:
Total Gradle task time: 6,517.78 s
Spent time before task action: 153.94 s
Task action before worker execution: 55.37 s
Run compilation in Gradle worker: 2,323.84 s
Clear jar cache: 0.52 s
Connect to Kotlin daemon: 8.09 s
Calculate output size: 0.45 s
Run compilation: 1,011.91 s
Non incremental compilation in daemon: 1,301.95 s
Incremental compilation in daemon: 1,008.65 s
Clear outputs on rebuild: 0.01 s
Update caches: 4.70 s
Sources compilation round: 953.53 s
Compiler initialization time: 13.59 s
Compiler code analysis: 392.68 s
Compiler code generation: 308.58 s
Compiler IR translation: 235.84 s
Compiler IR lowering: 149.26 s
Compiler IR generation: 159.16 s
Write history file: 0.01 s
Shrink and save current classpath snapshot after compilation: 15.05 s
Shrink current classpath snapshot non-incrementally: 14.10 s
Load current classpath snapshot: 3.02 s
Save shrunk current classpath snapshot: 0.52 s
Start gradle worker: 6.26 s
Size metrics:
Total size of the cache directory: 359.5 MB
ABI snapshot size: 15.4 KB
Increase memory usage: 38.7 GB
Total memory usage at the end of build: 2,220.4 GB
Total compiler iteration: 321
Number of lines analyzed: 1711070
Number of lines for code generation: 1711070
Analysis lines per second: 1041549
Code generation lines per second: 1512965
Compiler IR translation line number: 1711070
Compiler IR lowering line number: 1711070
Compiler IR generation line number: 1711070
Number of times classpath snapshot is shrunk and saved after compilation: 321
Number of classpath entries: 33004
Size of classpath snapshot: 2.9 GB
Size of shrunk classpath snapshot: 75.0 MB
Number of times classpath snapshot is loaded: 321
Number of cache hits when loading classpath entry snapshots: 31884
Number of cache misses when loading classpath entry snapshots: 1120
Start time of task action: 36057-03-25T08:49:43
Build attributes:
REBUILD_REASON:
Incremental compilation is not enabled(307)
Unknown Gradle changes(321)
Total time for Kotlin tasks: 2,256.78 s (34.6 % of all tasks time)
Yang
04/12/2024, 3:17 AMTotal time for Kotlin tasks
(2,256.78 s) is now on par with K1 (2,184.79 s), was 4,082.17 s in Beta5
• clear jar cache
(0.52s) is on par with K1 (0.00s), was 791.4s in Beta5
• Connect to Kotlin daemon
(8.09s) still takes longer than K1 (4.59s), but much improved from Beta5 (558.17s)
• `Non incremental compilation in daemon`: (1,301.95s) is still much longer than K1 (260.73s), and also slightly longer than Beta5 (1,071.88s)Yang
04/12/2024, 3:18 AMtapchicoma
04/12/2024, 6:55 AMkapt stub generation is still taking much longer than K1, I wonder if it’s due to kapt.use.k2=trueIs it clean build?
Yang
04/12/2024, 7:12 AMYang
04/12/2024, 7:17 AMkapt.use.k2
which seems to fix the regression
| Task | 1.9.23 | 2.0.0-RC1 (KAPT K2 On) | 2.0.0-RC1 (KAPT K2 Off) |
|---------------------------|--------------|------------------------|-------------------------|
| **KaptGenerateStubsTask** | 8m 32.377s | 18m 14.579s | 8m 16.309s |
| **KaptWithoutKotlincTask**| 9m 56.293s | 12m 12.981s | 10m 10.441s |
tapchicoma
04/12/2024, 7:19 AMtapchicoma
04/12/2024, 8:48 AMdniHze
04/17/2024, 2:02 PM