To begin with I built a test core data project utilising an NSArrayController bound to an NSTableView. This showed no performance issues at all so, surprise surprise, the problem was of my own creation.

Looking at the Shark traces reveals an implementation change in the way that model observing is handled.
So I go to my NSManagedObject subclass and note the following:

[self addObserver:self forKeyPath:@"message" options:0 context:(void *) &MGSContextMessage]; [self addObserver:self forKeyPath:@"date" options:0 context:(void *) &MGSContextDate]; [self addObserver:self forKeyPath:@"score" options:0 context:(void *) &MGSContextScore]; [self addObserver:self forKeyPath:@"category" options:0 context:(void *)&MGSContextCategory];

Removing these observers fixes the problem.

And why is self observing self?
Because my NSManagedObject subclass has a number of derived properties backed by ivars. Core Data undo doesn't call accessors during undo, but does update KVO, so the observations keep the modelled and un-modelled derived properties in sync during undo.
On 10.5 it's fine, on 10.6 dog slow.

The solution is simply to ditch the un-modelled derived properties in favour of transient modelled properties.
Core Data undo works and the self-self observation is redundant.

On 15 Oct 2009, at 13:01, jonat...@mugginsoft.com wrote:


I am using an array of simple NSManagedObject subclasses bound to an NSArrayController.
The object graph is shallow with a tiny number of objects (<500).

All objects are loaded into the NSArrayController MOC using an NSFetchRequest with setReturnsObjectsAsFaults:NO.
Therefore no faulting should be occurring.
The app is garbage collected.
The CoreData atore type is XML.

The NSArrayController's arrangedObjects is bound to an NSTableView.
The NSArrayController's filterPredicate is bound to an NSSearchField.

Under 10.5 manipulating the NSArrayController's arrangedObjects using either sort descriptors or the predicate is quick.
Under 10.6 the performance is noticeably worse.

Shark shows the following for both 10.5 and 10.6 when the filter predicate is updated.
The issue seems to make itself manifest on the lines marked >>.
Obviously the implementation here is different.

NSPointerArray -compact seems to be the centre of activity.

What options do I have here to try and restore performance?
Is the issue related to the use of NSManagedObject content at all?

OS X 10.6 (poor)
0.0% 89.5% AppKit -[NSArrayController setFilterPredicate:] 0.0% 89.5% AppKit -[NSArrayController _didChangeArrangementCriteriaWithOperationsMask:useBasis:] 0.0% 65.3% AppKit -[NSArrayController _arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis :] 0.0% 49.7% AppKit - [NSArrayController _setObjects:] 0.0% 49.7% AppKit - [_NSModelObservingTracker setIndexReferenceModelObjectArray:clearAllModelObjectObserving:] 0.0% 49.7% AppKit - [_NSModelObservingTracker clearAllModelObjectObserving] 0.0% 49.6% AppKit - [_NSModelObservingTracker _registerOrUnregister:observerNotificationsForModelObject:] 0.0% 49.6% Foundation -[NSObject (NSKeyValueObserverRegistration) removeObserver:forKeyPath:] 0.0% 49.5% Foundation -[NSObject (NSKeyValueObserverRegistration) _removeObserver:forProperty:] 0.1% 49.0% Foundation _NSKeyValueObservationInfoCreateByRemoving 0.0% 48.5% Foundation - [NSKeyValueObservationInfo _initWithObservances:count:] >>> 3.6% 46.4% Foundation - [NSConcretePointerArray compact] 10.0% 42.8% Foundation readWeakAt 9.7% 31.4% libobjc.A.dylib objc_read_weak 19.6% 19.8% libauto.dylib auto_read_weak_reference 0.2% 0.2% libSystem.B.dylib __spin_lock

OS X 10.5 (Good)
0.0% 37.6% AppKit -[NSArrayController setFilterPredicate:] 0.0% 37.6% AppKit -[NSArrayController _didChangeArrangementCriteriaWithOperationsMask:useBasis:] 0.0% 29.9% AppKit -[NSArrayController _arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis :] 0.0% 13.3% AppKit - [NSArrayController _setObjects:] 0.0% 12.4% AppKit - [NSArrayController _updateObservingForAutomaticallyRearrangingObjects] 0.0% 12.1% AppKit - [_NSModelObservingTracker startObservingModelObjectsAtReferenceIndexes:] 0.0% 12.1% AppKit - [_NSModelObservingTracker _startObservingModelObject:] 0.0% 12.1% AppKit - [_NSModelObservingTracker _registerOrUnregister:observerNotificationsForModelObject:] 0.0% 12.1% AppKit - [_NSModelObservingTracker _registerOrUnregister:observerNotificationsForKeyPath:ofModelObject:] 0.3% 12.1% Foundation -[NSObject (NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:] 0.3% 10.7% Foundation - [NSObject(NSKeyValueObserverRegistration) _addObserver:forProperty:options:context:] 0.0% 9.5% Foundation _NSKeyValueObservationInfoCreateByAdding 0.9% 6.5% Foundation - [NSKeyValueObservationInfo _initWithObservances:count:] >>> 0.0% 4.1% CoreFoundation -[__NSPlaceholderArray initWithObjects:count:] 0.3% 4.1% CoreFoundation CFArrayCreate 0.0% 2.7% CoreFoundation __CFArrayInit 0.0% 2.7% CoreFoundation _CFRuntimeCreateInstance 0.0% 2.7% CoreFoundation CFAllocatorAllocate 0.0% 2.7% libauto.dylib auto_zone_allocate_object 0.0% 2.7% libauto.dylib Auto::Zone::allocate_small_medium(unsigned long, unsigned int, bool, bool) 0.0% 2.7% libauto.dylib Auto::Region::allocate(unsigned long, unsigned int, bool, bool) 0.0% 2.7% libauto.dylib Auto::Admin::find_allocation(unsigned long, unsigned int, bool, bool&) 2.7% 2.7% libSystem.B.dylib __spin_lock

Jonathan Mitchell

Developer
http://www.mugginsoft.com





_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com

Jonathan Mitchell

Developer
http://www.mugginsoft.com





_______________________________________________

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

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

Reply via email to