JetBrains/intellij-community / .claude/skills/compose-ui
compose-ui
VerifiedWrite or audit Compose Desktop UI state, effects, and boundaries.
audit/references/lazy-layouts/desktop-scroll-measurement.md
View on GitHub# Desktop Scroll Measurement
Compose Desktop lacks Android's `FrameTimingMetric` and `MacrobenchmarkRule`. Use these
JVM-appropriate techniques to measure lazy-list scroll performance.
## 1. SideEffect logging (per-item recompositions)
```kotlin
LazyColumn {
items(data, key = { it.id }) { item ->
SideEffect { println("[Scroll] ${item.id} recomposed at ${System.currentTimeMillis()}") }
ItemRow(item)
}
}
```
- Scroll slowly. Only newly-visible items should log.
- If already-visible items log repeatedly, you have a recomposition leak.
## 2. CPU sampling during scroll
Attach YourKit, JFR, or async-profiler:
```bash
# JFR — pass JVM flags via JAVA_TOOL_OPTIONS, not --args (--args are application arguments)
JAVA_TOOL_OPTIONS="-XX:+FlightRecorder -XX:StartFlightRecording=duration=60s,filename=scroll.jfr" \
./gradlew run
```
Look for:
- `androidx.compose.runtime.ComposerKt` — recomposition overhead.
- `androidx.compose.ui.layout.LayoutNode` — measurement overhead.
- `androidx.compose.foundation.lazy.LazyListState` — scroll state management.
## 3. Heap check for cache window memory
```bash
# With YourKit: capture heap dump after scrolling the full list
# Compare retained size of LazyListItemNode with and without LazyLayoutCacheWindow
```
If `LazyLayoutCacheWindow` is active, expect higher retained count but smoother scroll.
If retained count is excessive, reduce `ahead`/`behind` values.
## 4. Frame-time estimation (approximate)
Desktop Compose does not expose frame timestamps directly. Approximate by logging
`withFrameNanos` in an effect:
```kotlin
LaunchedEffect(Unit) {
while (isActive) {
val t = withFrameNanos { it }
println("frame $t")
}
}
```
Gaps between frames >16.6ms (60fps) or >8.3ms (120fps) indicate jank.
## What NOT to use
| Android tool | Desktop status |
|-------------|----------------|
| `FrameTimingMetric` | Not available. |
| `MacrobenchmarkRule` | Not available. |
| Layout Inspector recomposition counts | Not available. |
| `@TraceRecomposition` | Not available. |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |