Skip to content

Commit 28a05ec

Browse files
committed
update: add performance improvements to k2 guide
1 parent e0e7e2d commit 28a05ec

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

docs/topics/k2-compiler-migration-guide.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The new architecture and enriched data structure enables the K2 compiler to prov
1616
* **Improved call resolution and type inference**. The compiler behaves more consistently and understands your code better.
1717
* **Easier introduction of syntactic sugar for new language features**. In the future, you'll be able to use more concise,
1818
readable code when new features are introduced.
19-
* **Faster compilation times**. Compilation times can be significantly faster.
19+
* **Faster compilation times**. Compilation times can be [significantly faster](#performance-improvements).
2020
* **Enhanced IDE performance**. If you enable K2 Kotlin mode in IntelliJ IDEA, then IntelliJ IDEA will use the K2 compiler
2121
frontend to analyze your Kotlin code, bringing stability and performance improvements. For more information,
2222
see [Support in IntelliJ IDEA](#support-in-intellij-idea).
@@ -26,8 +26,6 @@ The new architecture and enriched data structure enables the K2 compiler to prov
2626
>
2727
{type="warning"}
2828

29-
Thanks to the new K2 compiler, we've already made improvements to some [language features](#language-feature-improvements).
30-
3129
This guide:
3230

3331
* Explains the benefits of the new K2 compiler.
@@ -39,6 +37,22 @@ This guide:
3937
>
4038
{type="note"}
4139

40+
## Performance improvements
41+
42+
To evaluate the performance of the K2 compiler, we ran performance tests on two open-source projects: [Anki-Android](https://github.com/ankidroid/Anki-Android)
43+
and [Exposed](https://github.com/JetBrains/Exposed). Here are the key performance improvements that we found:
44+
45+
* The K2 compiler brings up to 94% compilation speed gains. For example, in the Anki-Android project, clean build times
46+
were reduced from 57.7 seconds in Kotlin 1.9.23 to 29.7 seconds in Kotlin 2.0.0.
47+
* The initialization phase is up to 488% faster with the K2 compiler. For example, in the Anki-Android project, the
48+
initialization phase for incremental builds was cut from 0.126 seconds in Kotlin 1.9.23 to just 0.022 seconds in Kotlin 2.0.0.
49+
* The Kotlin K2 compiler is up to 376% quicker in the analysis phase compared to the previous compiler. For example,
50+
in the Anki-Android project, analysis times for incremental builds were slashed from 0.581 seconds in Kotlin 1.9.23 to
51+
only 0.122 seconds in Kotlin 2.0.0.
52+
53+
For more details on these improvements and to learn more about how we analyzed the performance of the K2 compiler, see our
54+
[blog post](https://blog.jetbrains.com/kotlin/2024/04/k2-compiler-performance-benchmarks-and-how-to-measure-them-on-your-projects/).
55+
4256
## Language feature improvements
4357

4458
The Kotlin K2 compiler improves language features related to [smart-casting](#smart-casts) and [Kotlin Multiplatform](#kotlin-multiplatform).

0 commit comments

Comments
 (0)