# Concurrency & performance

Language: en
Canonical: [Concurrency & performance](<https://allluckly.cn/en/journal/topics/concurrency-performance/>)
中文：[中文 HTML](<https://allluckly.cn/journal/topics/concurrency-performance/>)
English: [English HTML](<https://allluckly.cn/en/journal/topics/concurrency-performance/>)

DEVELOPMENT NOTES · 7 articles

These notes ask where a task runs and why an interface stalls. They cover threading fundamentals, RunLoop and diagnostic techniques. Sketch the possible execution order before returning to the code.

## How to read this collection

1. Read the three threading articles in order. Distinguish tasks, queues, threads and synchronous waits; write out possible execution orders for nested calls.
2. Next, examine RunLoop and thread lifetime. Ask when a thread waits and what wakes it, rather than treating a persistent thread as a universal fix.
3. Relate stall detection and UIKit tuning to a real workload. Define what you measure, then compare timing, call stacks and screen behaviour. Historical measurements are not conclusions about current devices.

These notes date from 2015–2017. Their examples have not been rerun for this archive update. Check the dates and version notes before applying the ideas to a current project.

## Articles in this topic

7 articles · newest first

- 2017-03-27 

  ### [Detecting iOS Main-Thread Stalls](<https://allluckly.cn/en/journal/2017-03-27-detecting-ios-main-thread-stalls/>)

   

  Detects stalls by monitoring the main thread's RunLoop state and wait timeouts. It then introduces retrieving thread stack frames, walking call stacks, and symbolication to capture useful diagnostic context while an app is running.

   

  SindriLin RunLoop · stall detection · call stacks
- 2016-07-26 

  ### [RunLoop and Keeping iOS Threads Alive](<https://allluckly.cn/en/journal/2016-07-26-runloop-and-keeping-ios-threads-alive/>)

   

  Uses the networking thread in AFNetworking 2.x to examine RunLoop-based thread lifetimes. It explains how copied run-loop code can retain objects or prevent threads from exiting, then explores more controlled lifecycle handling through examples.

   

  bestswifter RunLoop · NSThread · AFNetworking
- 2016-04-25 

  ### [Optimising UITableViewCell height calculation in Swift](<https://allluckly.cn/en/journal/2016-04-25-optimising-uitableviewcell-height-calculation-in-swift/>)

   

  Addresses repeated cell-height calculation by drawing on FDTemplateLayoutCell's template measurement and height-caching approach. A Swift wrapper reduces repeated work during table-view scrolling.

   

  大石头布 UITableViewCell · row-height caching · FDTemplateLayoutCell
- 2016-03-02 

  ### [UIKit performance tuning in practice](<https://allluckly.cn/en/journal/2016-03-02-uikit-performance-tuning-in-practice/>)

   

  Uses a list interface as an experiment and Instruments' Core Animation tools to examine layer blending, image dimensions, colour formats and offscreen rendering. It connects common scrolling-performance problems with targeted adjustments.

   

  bestswifter Instruments · Core Animation · offscreen rendering
- 2016-02-29 

  ### [Bison's guide to iOS multithreading, part 3](<https://allluckly.cn/en/journal/2016-02-29-bison-s-guide-to-ios-multithreading-part-3/>)

   

  Explores GCD tasks and queues, comparing the main queue, global queues and custom serial and concurrent queues. Image downloads, repeated execution and one-time initialisation illustrate common ways to submit work.

   

  Bison GCD · dispatch\_async · dispatch\_sync
- 2016-01-18 

  ### [Bison's guide to iOS multithreading, part 2](<https://allluckly.cn/en/journal/2016-01-18-bison-s-guide-to-ios-multithreading-part-2/>)

   

  Examines shared data accessed by several threads, introducing synchronized blocks and NSLock locking and unlocking. NSCondition examples then use waiting, signalling and broadcasting to explain coordination between threads.

   

  Bison thread safety · synchronized · NSLock
- 2016-01-13 

  ### [Bison's guide to iOS multithreading, part 1](<https://allluckly.cn/en/journal/2016-01-13-bison-s-guide-to-ios-multithreading-part-1/>)

   

  Introduces multithreading by distinguishing processes from threads and comparing NSThread, NSOperationQueue and GCD. It then demonstrates thread creation, execution, termination and priorities, using logs to observe scheduling behaviour.

   

  Bison NSThread · multithreading · thread scheduling

