Quayside Benchmarks: Making Co... Note

Quayside Benchmarks: Making Compose Faster Without Fooling Yourself

This article outlines a "measure-first" approach for senior Android engineers optimizing Compose performance, emphasizing predicting, measuring, and then deciding whether to keep or revert changes. It uses a fictional ferry departure app, Quayside, to illustrate the costs of common Compose optimizations when applied without careful consideration. The examples use Compose Runtime 1.13's computedStateOf and 1.12's keyed SideEffect. The core optimization loop stresses measuring production-like builds on mid-range physical devices. Three tools are introduced for performance analysis: Perfetto system traces for frame timing, composition tracing for Composable-level details, and method tracing for fine-grained Kotlin analysis. For "jump-to-top" buttons, using computedStateOf for scroll position is preferred over derivedStateOf due to faster invalidation. For analytics, SideEffect is recommended over LaunchedEffect for synchronous, non-suspending work to avoid coroutine overhead. Finally, the article discusses the cost of skipping recomposition, highlighting that deep equality checks on large immutable lists can be more expensive than the work they prevent. Solutions include ensuring stable upstream instances or implementing custom, cheaper equality checks.
CdXz5zHNQW_QTnSeRmXH8.webp