K2 compiler in production
summary
Meta migrates its Android build pipeline to the K2 compiler over two years, and now 95% of modules for big apps are compiled with it; internal benchmarks show K2 makes front-end work about 20% faster on average, with Instagram and Threads shipping releases built by K2. Migration requires rewriting compiler plugins to FIR, handling KSP/KPT differences, and adding Java 17 support; backend parallelism proved ineffective for this build graph, while the new KSP2 and plugin changes deliver the biggest practical wins.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 1:03K2 compiler in production
- 3:59Investing in K2 compiler
- 6:31K2 compiler history
- 8:44Build types defined
- 11:16Compiler throughput optimizations
- 15:14Optimizations impact on builds
- 16:44K2 architecture complexity
- 19:41K2 reliability challenges
- 21:06Early K2 experiments
- 22:33Migrating plugins to K2
- 24:25Enabling K2 builds
- 26:14Plugin migration challenges
- 28:44Plugin compatibility solutions
- 29:28K2 maturity and v2.0
- 31:35Java 17 support impact
- 32:42K1 to K2 migration plugin
- 33:25Stable K2 compiler benefits
- 34:11Key takeaways and next steps
related talks
26mUpgrading Meta's Kotlin Infrastructure to K2
46mK2 Compiler plugins
23mKotlin
38mHow Kotlin 2.0 Will Evolve Android Development
44mMeta-programming with KSP and Kotlin compiler plugins
33mMeta-programming with KSP and Kotlin compiler plugins
42mMeta-programming with K2 compiler plugins
38mKSP and Plugins. Optimizing Kotlin Multiplatform common code
