Thursday, January 27, 2011

Multi-core iOS devices are coming. Are you ready?

I recently gave a presentation at the Tampa iOS Developers Meetup about Grand Central Dispatch (GCD). If you are wondering how your application can take advantage of multi-core CPUs, then you'll likely want to become familiar with GCD.

Here's what I talk about in the presentation:


  • Why did Apple create Grand Central Dispatch?

  • The effect of multi-core CPUs on software developers.

  • Why did the Desktop industry transition to multi-core CPUs?

  • Will the mobile industry follow suite?

  • The effect of over-flowing the pipeline. (threads vs available cores)

  • The OS imposed difficulty in properly filling the pipeline.

  • Real-world benchmarks of GCD vs traditional thread pools.

  • How is GCD different from traditional multi-threading solutions?

  • What GCD does NOT help you with.

  • Threads vs GCD queues.

  • What is a block exactly?

  • How does memory-management work with blocks? (primitives & objects)

  • Using the basic GCD APIs.

  • Using GCD to help create thread-safe classes.

  • Other advanced GCD topics

The video is not of the highest quality (crappy camera), but I hope the content will make up for it.

Watch The Video: Part 1 Part 2

Download the slides: Keynote | PDF

I've been doing a lot of work with GCD, and it's been great! It's not too difficult to learn, and the performance improvements have been impressive. We introduced a GCD based AsyncSocket library a few months ago, and found it to be up to 400% faster than the traditional thread/runloop version. And we also migrated CocoaHTTPServer to GCD and posted some impressive benchmarks.

9 comments:

brandon said...

Can you post the slides?

Robbie Hanson said...

Sure. Slides posted in Keynote and PDF format.

Bram said...

Thank you for posting. About your terminology: i think you misuse the word pipeline a lot. Pipelines suggest stages, and the problem of the idle system with 1 core at 100% is not a pipeline thing. It's a problem of utilizing the entire pool of computational resources.

hjaltij said...

Great talk. Thanks a lot for sharing.

Anonymous said...

Brilliant video. Thanks a lot!

Your last slide about Dispatch Sources promised info about timers, files, sockets etc, but then you only talked about timers. I was left wanting to know more about all the others. Any samples similar to the timer slide?

Robbie Hanson said...

Dispatch sources for files and sockets are a little more involved. For more information I'd recommend browsing some source code:

Dispatch sources for sockets: GCDAsyncSocket

Dispatch sources for reading files: HTTPAsyncFileResponse

(search for dispatch_source_create)

Mark Wright said...

Great video. Some good info there and brilliantly presented.

thealpha said...

Is it possible to post your video again? I was really looking forward to watching it again and taking some more notes

Robbie Hanson said...

Reposted the video. Had trouble trying to get it on YouTube because of time restrictions. Finally succeeded with Vimeo.