Re: NSOperation Efficiency
Re: NSOperation Efficiency
- Subject: Re: NSOperation Efficiency
- From: Kyle Sluder <email@hidden>
- Date: Tue, 04 Dec 2012 19:33:36 -0800
On Tue, Dec 4, 2012, at 05:02 PM, Gerriet M. Denkmann wrote:
>
> On 5 Dec 2012, at 02:58, Kyle Sluder <email@hidden> wrote:
>
> > On Tue, Dec 4, 2012, at 10:15 AM, Gerriet M. Denkmann wrote:
> >> I have an app which uses NSOperations inside an NSOperationQueue. These
> >> operations do not do any I/O - just Cpu. No swapping is taking place.
> >>
> >> When I set [ self.operationQueue setMaxConcurrentOperationCount: 1 ] each
> >> operation takes on average 200 msec., measured by NSDate.
> >>
> >> With 2 concurrent operations, it takes not 100 msec but 110 - an extra
> >> 10%. Ok - some overhead is to be expected.
> >>
> >> With 4 ops it takes 70 instead of 50 - overhead 40% - rather a lot.
> >> With 8 ops it takes 60 instead of 25 - overhead 140%. or: 40% of the cpu
> >> is used by my operations, 60% is used by whom? And for what?
> >>
> >> Is this to be expected? Or does my app has some hidden flaws? If so,
> >> where should I start looking?
> >
> > How many operations are you creating? We've found that with more than a
> > few hundred operations, NSOperationQueue is unusable.
>
> In this test I was using 444 operations. Otherwise there might be many
> thousands.
> Just tried again with 44 operations, but did not see any change in
> average execution time.
Yeah, it sounds like you're saturating the thread pool due to
non-CPU-bound operations. NSOpQ is going to spend its entire time
spawning and switching to threads while you append more and more
operations to the queue.
--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