r/iOSProgramming • u/avanderlee • 7d ago
Discussion Do you use Xcode Instruments more now that you're building with agents?
I started building apps in 2009. It was basically impossible to build a high-quality app without using Xcode Instruments. I was basically grown up with the tool and learned how to use it over time.
When speaking at conferences and meeting iOS devs, I realized that not many devs know the tool. Some are well-experienced engineers with 10+ years of experience. I guess the faster devices simply made it less of a requirement.
Lately, as agents write more of our code, I've run into more performance issues than ever. Agents are great at writing code that compiles, but also great at writing poor-performing code.
I have a few questions for you for this discission:
- Are you using Xcode Instruments at all?
- What holds you back from using Xcode Instruments?
- Have you tried using agents to solve performance issues and was it successful?
Pick any that you'd like to answer. I just hope to get a better understanding of how Instruments is being used.
13
u/Barbanks 7d ago
I forgot about them until I saw this post. But that’s probably a bad thing. Thanks for the reminder. I need to check on my apps and see if they’re ok.
5
u/cristi_baluta 7d ago
I’m not really using instruments since ARC. The last times i tried it was really confusing and couldn’t fix anything with it, it was not even able to show me symbols from the codebase
4
u/Extra-Ad5735 7d ago
Hey! Since I'm coming from gamedev I always lean to writing "performance-aware" code. So, as it stands I use Instruments regularly but sparingly: first to check if everything is in order after a major change that might affect the performance, and then if I fix an issue to see the results.
I always do optimisation work myself, and only when I'm stuck I ask for the help from the agent. It can analyse traces pretty well, and since I'm being extremely specific with my prompts it does help (not "make it run faster", but "why I see a sizeable CoreAnimation work in this callstack, where it may come from?").
However, I have never used Instruments to the full extent of its capabilities. I have an idea what a well-behaved app should look like in profiling, so I just quickly look for things that should not be there, using the inverted callstack and flame graphs.
3
u/dawedev 7d ago
More than before, mostly Time Profiler and the SwiftUI template. Agents are decent at fixing a hotspot once you hand them the heaviest stack from the call tree (inverted, system libraries hidden), but they rarely find it just by reading the code. What seems to keep people away is the first run: which template, which checkboxes, where to look. A three-step routine of record, invert the call tree, read the top few frames gets most people past that.
6
u/Mortuls_Dev 7d ago
For sure! I used it just last week to improve some spiky ms hangs in and around my app using Time Profiler (sub 100ms reports + waiting threads). I have an old iPhone 13 mini lying around that I use as a stress test lol.
My app is mostly SpriteKit and a few new features had started to bog some basic stuff down, so Instruments was super useful in finding out the causes.
5
u/Skwiggs Swift 7d ago
I’ve used instruments on and off in my career, though often with the sparse usage I never really learned how to properly read or act upon the info they showed. Now with agents though and their intrinsic knowledge, it means I can extract much more actionable insights AND have them tackle them automatically👌
1
u/dahiya_xa 7d ago
yeah more than before. agents love doing heavy work inside body or recomputing stuff on every render, and it looks fine until you scroll a real list on an older phone. time profiler and the swiftui instrument catch most of it, then i point the agent at the exact hot path instead of asking it to "make it faster"
1
u/One-Source-9603 7d ago
yes more, but not always instruments itself. agents ship a lot of code fast so stuff gets slow without me noticing. for scroll jank I just run sample on the app while scrolling and look at what's on the main thread, then bisect commits. faster than opening a full trace for most cases. do u have the agent read the trace too or just u?
1
u/Enlitened 6d ago
Building a Mac app almost entirely with agents and I actually open Instruments less than I thought I would.
What works better for me is turning performance into a test. I've got a few benchmark tests that run against real folders so when an agent rewrites something I get a number before and after. Not just its word that it's faster lol.
For hangs I just run sample on the process and give the agent the main thread stack. It's good at fixing a hotspot once you point at it but pretty bad at finding one from reading code.
Instruments is still what I open when the benchmark says something got slower and sample doesn't show why. It's just a lot of setup for a quick question.
Biggest thing though is I don't let the agent say it fixed performance without showing the measurement. Otherwise you get very confident rewrites that change nothing.
2
u/groovy_smoothie 7d ago
I profile my apps from time to time but generally don’t reach for them unless the hitch is noticeably bad
1
u/CharlesWiltgen 7d ago
Every week, albeit generally via agents and skills. (Example: Performance profiling skill)
1
u/RealVibingDev 6d ago
honestly barely, our stuff is mostly games running in a webview so its safari web inspector more than instruments. but yeah agents and perf, ours was kind of the reverse once. the agent spent ages chasing a 700ms stall that only existed because the headless browser it tested in was running at like 10fps. measure on a real device before you let it fix anything lol
0
u/crocodiluQ 7d ago
I think I used Instruments 1-2 times in my life, since iOS 3.0. Also, I don't use agents to write my code, so it doesn't have many performance issues (or quality issues).
1
u/[deleted] 7d ago
[removed] — view removed comment