None
NL
How R8 made Kotlin Coroutines on Android 2x faster
[]
Android Developers Blog
Starting from AGP 9.2.0, R8 optimizes most Atomic*FieldUpdater calls into Unsafe variants that perform 2x to 4x better on common operations.
This has a particularly large impact on the kotlinx.atomicfu library that implements atomics for kotlinx.coroutines , making launching and cancelling coroutines up to 2x faster.
As the Compose team started to investigate performance, coroutines were discovered to be a bottleneck for many operations that happen outside of composition.
InstrumentationThe first step is to introduce offset fields alongside the updater field in order to facilitate direct access via the Unsafe call.
When the benchmarks were updated to a new version of R8, we noticed a 2x improvement when launching and cancelling coroutines in LaunchedEffect !