Re: NSOperation Efficiency
Re: NSOperation Efficiency
- Subject: Re: NSOperation Efficiency
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Wed, 05 Dec 2012 16:09:33 +0700
On 5 Dec 2012, at 15:07, Quincey Morris <email@hidden> wrote:
> On Dec 4, 2012, at 23:02 , "Gerriet M. Denkmann" <email@hidden> wrote:
>
>> And got almost the same overhead (tested three times with 99 operations);
>> clock time per operation expected time overhead factor
>> // 8 ops 29.9, 30.1, 29.7 12.5 2.4
>> // 7 ops 29.2, 30.0, 29.7 14.3 2.1
>> // 6 ops 28.8, 28.5, 29.0 16.7 1.7
>> // 5 ops 28.6, 28.4, 28.9 20 1.4
>> // 4 ops 29.4, 31.9, 30.8 25 1.2
>> // 3 ops 35.7, 35.4, 35.2 33 1.06
>> // 2 ops 51.7, 51.5, 51.2 50 1.03
>> // 1 ops 100
>>
>> Looks like NSOperationQueue has some problems, or?
>
> Your expected times are questionable:
>
> 1. You "expect" a multi-threaded execution to have no measurable overheads at all. Since your expectations are unreasonable, you don't know whether the actual times are good or bad.
Well, I expect "some" overhead, like I see for 3 or 4 operations.
> 2. You don't state whether you create all of the operations before letting any run, or if you're creating them while some are already running. That's going to affect what you measure as overheads. The questions of overheads in queuing operations (which Kyle has being saying is inefficient) is an entirely separate matter from what you seem to be measuring here.
When I press a button "Start" this gets done:
self.start = [ NSDate date ];
for( NSUInteger i = 0; i < self.nbrWork; i++ )
{
GmdOperationBasis *m2 = [ [ GmdOperationBasis alloc ] init ];
[ self.operationQueue addOperation: m2 ];
};
>
> 4. How many cores on the Mac you used for the test? 2? 4? 8?
No idea. But NSProcessInfo reports: processorCount = 8.
About this Mac says: MacBook Pro; Retina, Mid 2012; Processor 2.3 GHz Intel Core i7; Memory 8 GB 1600 MHz DDR3.
>
>
> 8. You don't take into account what else might be using CPUs during your test.
This is no scientific test. There probably was some 5% CPU time from other activities.
> Perhaps the *important* test is to give control of the number of simultaneous operations back to NSOperationQueue. If that produces elapsed times of about 35, then you have some evidence that the default behavior is the correct choice.
This I cannot do.
When I use NSOperationQueueDefaultMaxConcurrentOperationCount (i.e. letting NSOperationQueue decide what is appropriate) then my app will block (see thread: Operations Beachball).
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