JetBrains/intellij-community / .agents/skills/compose-ui
compose-ui
VerifiedWrite or audit Compose Desktop UI state, effects, and boundaries.
audit/references/subcomposition/desktop-subcomposition-measurement.md
View on GitHub# Desktop Subcomposition Measurement
## Identifying subcomposition overhead
Subcomposition shows up in profiles as:
- `SubcomposeLayoutSubcompositionState` frames
- `BoxWithConstraints` measure/composition cycles
- `SwingPanel` factory calls during resize
## Profiling techniques
### JFR
```bash
# Pass JVM flags via JAVA_TOOL_OPTIONS — --args are application arguments, not JVM arguments
JAVA_TOOL_OPTIONS="-XX:+FlightRecorder -XX:StartFlightRecording=duration=30s,filename=subcomp.jfr" \
./gradlew run
```
Look for:
- `androidx.compose.ui.layout.SubcomposeLayout` in the call stack.
- Repeated `measure` → `subcompose` → `measure` chains.
### YourKit
1. Attach YourKit to the running Desktop app.
2. Capture CPU sampling during window resize.
3. Filter for `SubcomposeLayout` and `BoxWithConstraints`.
### Logging
```kotlin
BoxWithConstraints {
SideEffect {
println("[Subcompose] measure: maxWidth=$maxWidth, time=${System.currentTimeMillis()}")
}
// ...
}
```
If logs appear on every minor resize event, subcomposition is running too frequently.
## Benchmarking subcomposition cost
1. Create a test composable with and without `BoxWithConstraints`.
2. Resize the window rapidly for 10 seconds.
3. Compare CPU samples.
A well-structured layout without subcomposition should show near-zero Compose overhead during
resize; subcomposition-heavy layouts will show sustained `ComposerKt` and `LayoutNode` activity.
## What to measure
| Metric | Good | Bad |
|--------|------|-----|
| `SubcomposeLayout` CPU % during resize | <5% | >20% |
| `BoxWithConstraints` recomposition count per resize | 1-2 | >10 |
| `SwingPanel` factory calls per recomposition | 1 | >1 |
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: 471k | 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: 471k | 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: 471k | 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 |