Xcode Instruments is a powerful tool that ships with Xcode and lets you analyze, debug, and optimize your code, including Swift Concurrency. It comes with so-called templates that consist of multiple instruments. After running your app through Xcode Instruments, you’ll get a detailed overview of the performance of your app.
I started developing apps in 2009, when devices weren’t as fast as they are today. Xcode Instruments were basically a requirement to make your app functional at all. Unfortunately, nowadays we’ve become a bit lazy about using Xcode Instruments. It feels less needed because apps run pretty fast by default due to optimized tooling and devices. Yet, agentic development reintroduces the risk of low-performance applications, as the generated code might not perform as expected. This article will demonstrate how you can use Xcode Instruments to optimize a piece of Swift Concurrency code.
New to Instruments? Start with my Xcode Instruments guide for recording, Time Profiler, and verifying your fix.
Video: Using Xcode Instruments to improve Swift Concurrency Code
This article is based on the following YouTube video, which I highly recommend watching. Xcode Instruments is complex and challenging, and best explained using a video tutorial:
Why you should profile your Swift Concurrency code
I want to start by explaining the importance of Xcode Instruments. While debugging, many of our apps are not in their most advanced state. It’s very likely that you just installed the app and that it doesn’t contain much data. Real users might be using your apps for a longer time, slowly growing its data usage.
Optimizing your apps for real-world scenarios means zooming in on the details. In the above video, I demonstrate an application that’s already fast during debugging. However, the essential point is that I’m using only 100 wallpapers, which should always perform quickly! What if a user ends up with 10,000 wallpapers?
If you zoom in on a piece of code using Instruments, you change the scale and surface potential performance issues that would only become visible at a larger scale. Being lazy and assuming good performance will sooner or later bite you back.
Understanding the difference between templates and instruments
When using Xcode Instruments, it’s essential to know the difference between templates and instruments. It’s a small detail, but it helped me better understand why the Time Profiler showed up in pretty much every template.
When opening the app, you’ll get a default selection of templates to use:

In the above screenshot, I’ve selected the Swift Concurrency template, which is described as:
Track statistics from the Swift Concurrency runtime, visualize the state of Swift Tasks, graph relationships for Structured Concurrency, monitor Swift Actor contention, and show how Swift Tasks execute on the CPU.
It explains what you can do with the template and already hints at several individual instruments. Because if we open the template, we’ll notice a selection of instruments:

In this template, we’ll get four different instruments:
- Swift Tasks
Tracks task lifetime and state changes - Swift Actors
Shows actor execution and queue size - Time Profiler
Shows where time is spent in your code - Hangs
Detects when the main thread is blocked
Each instrument has its own purpose, and you might not always use each. The above video demonstrates each of these along the way.
Finding Swift Concurrency issues with RocketTrace
The Swift Concurrency template gives you a lot of data: task states, actor queues, and hangs next to each other. Knowing which of it matters is the hard part. RocketTrace analyzes the same recording for you. Record the template in Instruments and import the trace, or record straight from RocketTrace.

In the screenshot above, RocketTrace found that four independent analysis tasks ran one after another for 1.2 seconds. It also points to the suspected method, and it’s clear about what that is: timing evidence, not proof of cause. A similar problem is an actor backlog, where multiple tasks queue behind one actor and turn work that should overlap into a serial line. I wrote more about that in Swift Concurrency actor contention.
Every finding comes with an Agent Prompt, so you can paste the evidence into your coding agent and start a grounded investigation. Or install the rockettrace CLI and Agent Skill, and let your agent record and read the results itself.
Frequently asked questions
It tracks statistics from the Swift Concurrency runtime, visualizes the state of Swift Tasks, graphs relationships for structured concurrency, monitors actor contention, and shows how tasks execute on the CPU. The template consists of four instruments: Swift Tasks, Swift Actors, Time Profiler, and Hangs.
An instrument collects one kind of data, like Time Profiler or Hangs. A template combines several instruments for a specific goal. That is why the Time Profiler shows up in pretty much every template.
While debugging, your app usually contains little data. Real users might use it for a longer time and slowly grow its data usage. Zooming in with Instruments surfaces issues that only become visible at a larger scale, like going from 100 to 10,000 wallpapers.
Import the trace into RocketTrace. It ranks the findings of the recording by measured impact, including Swift Concurrency findings like an actor backlog, and every finding comes with an Agent Prompt you can paste into your coding agent.
Code & Read along Tutorial
The above video is great, but I can totally understand that you want to read along at your own pace, or access the code example and try it out yourself.
I’m happy to invite you to my detailed Swift Concurrency Course, which comes with a dedicated module on performance. It includes all the materials from the video and text-based lessons that go over each performance improvement step in detail.
Check out swiftconcurrencycourse.com for more details.
Thanks!


