Re: GCD killed my performance
Re: GCD killed my performance
- Subject: Re: GCD killed my performance
- From: Jonathan Taylor <email@hidden>
- Date: Fri, 25 Apr 2014 09:11:51 +0100
Have you looked at the output from System Trace on both systems? I often find that to be informative.
That might or might not be the way to tell, but have you considered that the very different CPU characteristics might mean that the actual timing and pattern of database commands is different on the iPhone, resulting in e.g. a different level of contention for the queues? Suppose dispatch_sync is fast on an empty queue but has additional overhead on a full queue - resulting in different performance on one platform to another?
On 25 Apr 2014, at 04:42, email@hidden wrote:
> I’m writing an Objective-C API around a database library, and trying to add some optimizations. There’s a lot of room for parallelizing, since tasks like indexing involve a combination of I/O-bound and CPU-bound operations. As a first step, I made my API thread-safe by creating a dispatch queue and wrapping the C database calls in dispatch_sync blocks. Then I did some reorganization of the code so different parts run on different queues, allowing I/O and computation to run in parallel.
>
> On my MacBook Pro this gave me a nice speedup of 50% or more.
>
> But when I tested the code on my iPhone 5 today, I found performance had dropped by about a third. Profiling shows that most of the time is being spent in thread/queue management or Objective-C refcount bookkeeping. It looks as though adding GCD introduced a lot of CPU overhead, and the two cores on my iPhone aren’t enough to make up for that, while the eight cores in my MacBook Pro make it worthwhile.
>
> I tried backing out all the restructuring of my code, so there’s no actual parallelism going on, just the dispatch_sync calls. Predictably, performance is even worse; slightly more than half as fast as without them.
>
> So, I’m pretty disappointed. I know that dispatch queues aren’t free, but I wasn’t expecting them to be this expensive! I’m not doing anything silly like wrapping dispatch_sync around trivial calls. The APIs I’m using it on do things like reading and writing values from the persistent store. I was expecting the cost of thread-safety to be lost in the noise compared to that.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden