Skip to content
Skills Library
Programming · Analysis

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.

Repository
pstuart ↗
Licence
MIT
Last repository change
22.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 22.10.2026, without references to retired models or APIs.

Licence

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

  1. Non-negotiables
  2. Decision tree
  3. Core patterns
  4. Instruments
  5. Pre-finish checklist
Original SKILL.md headings · 71 lines, 272 words
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…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.