• 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: Operations Beachball
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Operations Beachball


  • Subject: Re: Operations Beachball
  • From: Charles Srstka <email@hidden>
  • Date: Tue, 04 Dec 2012 12:40:13 -0600

On Dec 4, 2012, at 4:29 AM, Gerriet M. Denkmann <email@hidden> wrote:

> My app creates lots of MyOperations (subclass of NSOperation) and puts them into an NSOperationQueue.
>
> I would expect that the app thus remains responsive, but sometimes it is not.
>
> A sure way to beach-ball my app is: start it with a few hundred operations (which will take about 20 seconds to finish).
> Make some other app active.
> Try to make my app active again - it's panel stays grey and after a few seconds the cursor will turn into a beach-ball.
>
> These MyOperations interact with their controller in two ways:
>
> 1. they do once at start:  [ controller dataStringFor: row ];
>
> The controller has:
>
> - (NSString *) dataStringFor: (NSUInteger)row
> {
> 	@synchronized(self)
> 	{
> 		if ( self.stringArray == nil ) { create it - takes some time, but happens only once};
> 	}
> 	return self.stringArray[row];
> }
>
>
> 2. When MyOperations have finished their work they call: [ controller  done: row  result: someNumber ];
>
> The controller has:
>
> - (void) done: (NSUInteger) row  result: (NSUInteger) someNumber
> {
>    @synchronized(self)
> 	{
> 		[ self.rowsToDo removeIndex: row ];	//	NSMutableIndexSet
> 	};
>
> 	//	sometimes do some logging, update user interface - but only every few seconds
> }
>
> So, why the beach-ball? What am I doing wrong? How to debug this? Why does the app-switch make the beach-ball appear?

I don't know that this will make a big difference, but since you're dealing with a performance issue, @synchronized is known to be much slower than other methods of synchronization. You could try replacing this with dispatch_sync on a serial queue, a spin lock, or a mutex and see if it helps at all.

Charles


_______________________________________________

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: 
 >Operations Beachball (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Beachballing 2
  • Next by Date: Re: NSOperation Efficiency
  • Previous by thread: Re: Operations Beachball
  • Next by thread: Re: Operations Beachball
  • Index(es):
    • Date
    • Thread