On Apr 30, 2015, at 23:46:53, Graham Cox <graham....@bigpond.com> wrote:
> 
> Well, here’s a huge clue.
> 
> I use NSOperationQueue with the default -maxConcurrentOperationCount which is 
> NSOperationQueueDefaultMaxConcurrentOperationCount, i.e. let the system 
> figure it out. That appears to create 4 threads for my particular machine, 
> which has a Core i3 (2 cores) CPU. My peak CPU usage is reported as 418%. I’m 
> not sure how it achieves that from a dual core CPU, but one would assume that 
> Apple know what they’re doing [/irony].
> 
> So, I tried setting that NSOperationQueue property directly to something 
> less, and lo-and-behold, the problem goes away with a limit of 3 or less. A 
> limit of 4 produces the same problem.
> 
> This appears to suggest that if you let NSOperationQueue take all of the CPU 
> resources, the main thread is left high and dry if it needs to create another 
> thread, e.g. for an XPC call. Maybe this is intentional, but it’s a bloody 
> nuisance - surely a better outcome for the “let the system figure it out” 
> would be to say “whatever the max is -1”, so it leaves some capacity in hand 
> for the main thread. The way it works now might give slightly better 
> performance overall, but it causes an app to hang unresponsively for some 
> indeterminate period in some cases. Of course I can set the limit to 3 
> myself, but if I found myself on a 16 core machine, that's very suboptimal.
> 
> I’m tempted to report this as a bug, but I’d like to hear what others think 
> about this first.

I’ve run into this too, where letting the OS figure out how many operations to 
queue at once doesn’t always work like a human wants it to work. I ended up 
doing what you did - leave one for the main thread. 
NSOperationQueueDefaultMaxConcurrentOperationCount really isn’t smart enough, 
or they need to add another constant 
NSOperationQueueDefaultMaxConcurrentButDontBeAJerkOperationCount.

--
Steve Mills
Drummer, Mac geek


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to