Re: NSOperation Dispatch Thread Soft Limit
Re: NSOperation Dispatch Thread Soft Limit
- Subject: Re: NSOperation Dispatch Thread Soft Limit
- From: Daniel Vollmer <email@hidden>
- Date: Mon, 03 Mar 2014 14:25:08 +0100
Hi,
On 3 Mar 2014, at 09:43, Gerriet M. Denkmann <email@hidden> wrote:
> I have a MyOperation, subclass of NSOperation.
>
> MyOperation does:
> create an NSOperationQueue
> add a few MyOperations to this queue
> waitUntilAllOperationsAreFinished
> (obviously this recursion stops at some point - I do not create an infinite number of operations).
>
> The good thing: this is very energy saving: cpu utilisation = 0%
> The bad thing: nothing gets done.
>
> Using Activity Monitor to sample my app I see:
>
> “Dispatch Thread Soft Limit: 64 reached in 2152 of 2152 samples -- too many dispatch threads blocked in synchronous operations"
IMO the problem is not really the limit itself, but the second part of the message: That your operations themselves are blocking. If you haven’t, take a look at
https://www.mikeash.com/pyblog/friday-qa-2009-09-25-gcd-practicum.html
He has reasonably expensive blocks, so he aims to have 2x cpuCores operations in flight (and does IO scheduling).
> But: Is there some way to find out programmatically at which point my app should stop adding operations?
That depends largely on what your operations do (e.g. whether I/O is involved, duration, dependencies, …). Somehow (constant) scaling with the number of cores available in the machine seems like a good start, as you cannot ever execute more things in parallel.
Daniel.
_______________________________________________
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