swift-performance-optimization
/swift-performance-optimization
Use when profiling slow SwiftUI screens, optimizing lists, reducing main-thread work, improving memory/CPU, or using Instruments Time Profiler or Swift Concurrency tools.
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 22.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Use when profiling slow SwiftUI screens, optimizing lists, reducing main-thread work, improving memory/CPU, or using Instruments Time Profiler or Swift Concurrency tools.
Original author description
Use when profiling slow SwiftUI screens, optimizing lists, reducing main-thread work, improving memory/CPU, or using Instruments Time Profiler or Swift Concurrency tools.
How it works
- Non-negotiables
- Decision tree
- Core patterns
- Instruments
- Pre-finish checklist
SKILL.md preview
---
name: swift-performance-optimization
description: Use when profiling slow SwiftUI screens, optimizing lists, reducing main-thread work, improving memory/CPU, or using Instruments Time Profiler or Swift Concurrency tools.
---
# Swift Performance Optimization
Profile first, then fix the measured hot path.
## Non-negotiables
| ALWAYS | NEVER |
|--------|--------|
| Measure with Instruments before large rewrites | Micro-optimize unmeasured code |
| Keep heavy work off `@MainActor` | Block main actor with parsing/image work |
| Prefer `@Observable` fine-grained updates | Force full-tree invalidation patterns |
| Use lazy stacks/grids for large collections | Eagerly build thousands of heavy subviews |
## Decision tree
- Jank while scrolling? → List/LazyVStack identity, row cost, images
- Hang on action? → Time Profiler; move work off main actor
- Memory climb? → `memory-leak-diagnosis` + Allocations
- Actor wait times? → Swift Concurrency instrument
## Core patterns
```swift
// Large lists: stable identity + light rows
List(items) { item in
ItemRow(item: item) // small view, no heavy work in body
}
.listStyle(.plain)
// Background compute
actor Processor {
func process(_ input: Data) async -> Result { /* heavy */ }
}
@MainActor
@Observable
final class VM {
var result: Result?
private let processor = Processor()
func run(_ data: Data) async {
result = await processor.process(data)
}
}
```
```swift
// AsyncImage with phases; cache if product requires
AsyncImage(url: url) { phase in
switch phase {
case .success(let image): image.resizable().scaledToFill()
case .failure: Image(systemName: "photo")
default: ProgressView()
}
}
```
## Instruments
1. Product → Profile → Time Profiler and/or Swift Concurrency
2. Invert call tree; watch main thread Self time
3. Fix top offenders only; re-measure
## Pre-finish checklist
- [ ] Bottleneck measured
- [ ] Main-actor work minimized
- [ ] Large collections use lazy containers
- [ ] Re-profiled or justified skip
Versions
The database has no other skills named swift-performance-optimization.
Database snapshot: 13.11.2026 · package version 2f1726f1fd86 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100swift-performance-pro
Use when diagnosing or fixing performance — SwiftUI render cost, memory and retain cycles, slow lists, launch time, and using Instruments. - 90Swift Performance Optimization Skill
Use when investigating measured Swift or Apple-platform regressions in CPU, memory, launch, scrolling, animation hitches, image processing, energy, networking, or concurrency, or when designing performance tests and Instruments experiments. Do not use for speculative… - 91performance-profiling
Instruments integration and performance analysis workflows for iOS apps. Use when profiling CPU usage, memory allocation, network activity, or energy consumption. Covers Time Profiler, Allocations, Leaks, Network instruments, and performance optimization strategies. - 95swiftui-performance
Audit and improve SwiftUI runtime performance. Use when diagnosing slow rendering, janky scrolling, high CPU, memory usage, excessive view updates, layout thrash, body evaluation cost, identity churn, view lifetime issues, lazy loading, Instruments profiling guidance, and performance audit requests. - 100swiftui-performance-audit
Diagnose SwiftUI rendering, scrolling, update, CPU, memory, image, layout, and animation performance from code and evidence. Use when a SwiftUI feature is slow, janky, broadly invalidating, memory-heavy, or needs a code-first audit before Instruments capture. - 100swiftui-performance-audit
Audit and improve SwiftUI runtime performance from code review and architecture. Use for requests to diagnose slow rendering, janky scrolling, high CPU/memory usage, excessive view updates, or layout thrash in SwiftUI apps, and to provide guidance for user-run Instruments…