Gotta Go Fast (A Performance and Instruments Talk)
updated 12 months ago; latest suggestion 12 months ago
If you've been working on an iOS app for a while, you may have noticed that over time your once snappy app has started to feel a little sluggish. Your feed limps along with the occasional stall or maybe you're trying to build a camera app but it seems to lag quite a bit behind reality. Contrary to popular opinion, our software is becoming increasingly demanding at a rate that easily exceeds how quickly our devices are improving.
When the day of poor performance inevitably comes upon you, will you be ready to face it? Or will you resign yourself and your users to a subpar experience as you shrug your shoulders and watch your app's performance suffer more with each new feature?
The talk explains how to track overall performance, find performance problems and how to fix a few big ones. Sprinkled throughout are tasteful Sonic references along with 10 Rules for Good Performance. Let me know if I need to list each rule out!
In this talk I cover:
What is Good Performance
There's a difference between overall speed and your app's responsiveness.
Blocking the main thread (the render thread) can cause frames not to be drawn (aka a dropped frame)
Dropped frames are a good indication of when parts of your code are going too slowly and can be improved via concurrency or removing blockers.
You can use a
CADisplayLink to track and log dropped frames along with their timestamps which will allow you to track down their cause later.
How Can I Find and Fix Problems
You can use Time Profiler to find out which methods your code is spending most of its time on as well as zero in on exactly what was happening when your app dropped a particular frame.
Once you've tightened things up as much as you could, you can use the Core Animation Instrument to check for code you may have written that is indirectly slowing your performance by triggering extra GPU work you don't need.
Finally, you can use Activity Trace to measure and monitor particular long running operations across threads and get a visual graph of what is happening in your system.
Finally, I wrap things up by going into some common tough bottlenecks that will slow your app down and give a couple rules for how to avoid these pitfalls.
So that's a fair thought, but this talk is about performance in general.
The reason I focus on "frames" is because in iOS specifically, all the code you write is executed on the Main Thread by default. This happens to also be the render thread, so slow performance can easily manifest itself as "dropped frames" even if the offending code has absolutely nothing to do with "graphics".
The mention of frames hints that this is not about general performance but graphic performance - which is quite a narrow subset of computing. I wonder how this affects the scope of these 10 rules for good performance.
I always feel like I don't know how to use Instruments as well as I should. So a talk like this would be great.
Yep exactly. I'll update the title in here so that's more obvious
So this seems like a performance measuring and Instruments talk..?