Re: GCD killed my performance
Re: GCD killed my performance
- Subject: Re: GCD killed my performance
- From: Kyle Sluder <email@hidden>
- Date: Sat, 26 Apr 2014 12:02:13 -0700
> On Apr 25, 2014, at 10:35 AM, Seth Willits <email@hidden> wrote:
>
>> On Apr 25, 2014, at 8:08 AM, Jens Alfke <email@hidden> wrote:
>>
>> I’m ending up at the opposite of the received wisdom, namely:
>> * dispatch_sync is a lot cheaper than dispatch_async
>> * only use dispatch_async if you really need to, or for an expensive operation, because it will slow down all your dispatch_sync calls
>
> Saying "dispatch_async will slow down *all* dispatch_sync calls" throws up red flags for me.
>
> In my mind there's still a possibility that You're Doing It Wrong.
FWIW, I’ve been of the opinion for a while that including dispatch_sync in the API was a mistake. Too often it becomes a crutch used without understanding, resulting in stop-start behavior across threads or cores. The correct solution is usually to rewrite the code in continuation-passing style, even if that means a cascade of blocks. Microsoft realized this when designing WinRT and _removed all the synchronous APIs_. They also added the async/await keywords to C# to avoid the seventeen-levels-of-indentation problem that plagues ObjC code.
Some people at Apple agree that use of dispatch_sync is a code smell, but that if they didn't include it a hundred different re-implementations would arise, all differently broken.
--Kyle Sluder
_______________________________________________
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