• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOperation Dispatch Thread Soft Limit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOperation Dispatch Thread Soft Limit


  • Subject: Re: NSOperation Dispatch Thread Soft Limit
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Tue, 04 Mar 2014 00:21:34 +0700

On 3 Mar 2014, at 23:14, Jens Alfke <email@hidden> wrote:

>
> On Mar 3, 2014, at 12:43 AM, Gerriet M. Denkmann <email@hidden> wrote:
>
>> 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).
>
> NSOperation already has dependency settings so you can tell an NSOperation not to start running until dependent operations finish. You should be using that instead. Having large numbers of NSOperations blocked in mid-flight is bad for scalability, as you found, because it creates lots of threads.
>
> It sounds like you’ve implemented some hierarchical algorithm in the simplest possible way. (Which is not an insult; one of the Agile principles is Do The Simplest Thing That Could Possibly Work.) The flip side of this approach is that when profiling shows you that the simple approach isn’t good enough, you have to go back and redesign it in a cleverer/faster way.

Yes, I did that. The new version:

MyOperation does:
	if at the root of the recursion:
		create an NSOperationQueue
		add 4 MyOperations to this queue
		waitUntilAllOperationsAreFinished
	else
		do all stuff synchronously
	endif

This is much faster. It is twice as fast as the single-threaded version. Only four MyOperations are ever put into an NSOperationQueue; no more blocking.

Adding more operations increases the Cpu load (up to 800%), but takes longer to finish.

Thanks for your suggestions!


Kind regards,

Gerriet.



_______________________________________________

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


References: 
 >NSOperation Dispatch Thread Soft Limit (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: NSOperation Dispatch Thread Soft Limit (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Public API method naming for NSString * / const char * parameters
  • Next by Date: Re: Public API method naming for NSString * / const char * parameters
  • Previous by thread: Re: NSOperation Dispatch Thread Soft Limit
  • Next by thread: Public API method naming for NSString * / const char * parameters
  • Index(es):
    • Date
    • Thread