• 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
Beachballing 2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Beachballing 2


  • Subject: Beachballing 2
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Wed, 05 Dec 2012 00:54:33 +0700

My app creates lots of MyOperations (subclass of NSOperation) and puts them into an NSOperationQueue.
These operations do not do any I/O - they just use the Cpu.

When I make some other app active and then try again to make my app active, my app beach-balls. When all my operations have finished, the app becomes responsive again.

This seems to be a known problem:  <http://stackoverflow.com/questions/13148684/deadlock-using-dispatch-semaphore-t-in-a-concurrent-queue>

I used to do:
[ self.operationQueue setMaxConcurrentOperationCount: NSOperationQueueDefaultMaxConcurrentOperationCount ];

because I wanted "the receiver to choose an appropriate value based on the number of available processors and other relevant factors."

But, the receiver obviously chooses a value, which is NOT appropriate at all.

When I change this to:
[ self.operationQueue setMaxConcurrentOperationCount: 7 ];
my app runs 3% slower (not 14% slower as I expected) and the beach-ball problem disappears.

The problem: 7 is the right magic number on my machine with my number of processor cores etc.
But certainly on other machines the number will be different.

So: How do I choose an appropriate number?
And is this a bug (NSOperationQueue choosing an inappropriate number) or not?

Gerriet.

P.S. Big thanks to Jonathan for his very valuable help off-list.


_______________________________________________

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

  • Follow-Ups:
    • Re: Beachballing 2
      • From: Chris Hanson <email@hidden>
    • Re: Beachballing 2
      • From: Jens Alfke <email@hidden>
    • Re: Beachballing 2
      • From: Alex Zavatone <email@hidden>
  • Prev by Date: Re: Operations Beachball
  • Next by Date: NSOperation Efficiency
  • Previous by thread: Re: Operations Beachball
  • Next by thread: Re: Beachballing 2
  • Index(es):
    • Date
    • Thread