0

having real problems with a very unresponsive (OSX) app. When using about 3K (Core Data) objects, the app freezes during startup and save, and when adding new managed objects.

When I dig into the call tree, using (Instruments) Time Profiler, most of the time seems to be spent sorting array controllers. During startup, half of the time goes to NSUndoManager, which observes notifications while array controllers are setting their content...

Is the array controller sorting while new managed objects are being instantiated? Do I need to put sorting on hold? Could NSUndoManager be the culprit?

More importantly, how does one go about analyzing something like this? It could very well be that I have some sort of exponential sorting going on, by which I mean that when one array controller sorts itself, several other array controllers may needlessly start re-sorting themselves too.

The datamodel I am using is fairly extensive. Also, I have about 30-ish array controllers in 2 .xib files, some of them managing the same class-type.

Marcus Zarra's book on Core Data has been very informative, in this context especially the chapter on optimizing Core Data.

Also, this article by Matt Gallagher is pretty impressive, although the issue I'm having probably isn't related to code that needs to be optimized.

Any and all tips are welcome, I am pulling my hair out here. Could you point me to some tutorials or books that could help me out? Thanks.

4
  • Do you need the undo manager? You can always set it to nil and see if it's an improvement . . . May 31, 2012 at 10:13
  • Good idea. I checked the undo architecture docs, but it isn't clear to me at which point during startup I should be doing this.
    – Fnord23
    May 31, 2012 at 12:12
  • I set the NSUndoManager of the managed object context to nil, both in the app delegate's init and awakeFromNib. No real improvement in both cases. Time Profiler does not show NSUndoManager to be involved anymore.
    – Fnord23
    May 31, 2012 at 12:27
  • OK, it was a long shot anyway :) Sorry! May 31, 2012 at 13:46

1 Answer 1

0

If half the time is being taken by undoManager, but you see no performance improvement when removing the undo manager, I'd say you should look at IO as your potential bottleneck.

Look at the amount of time spent doing I/O operations.

Also, when it comes to core data, I'd do all my work in a background thread. No sense letting it hang your UI. Hopefully, you are able to use parent/child MOCs, as that greatly simplifies working with multiple contexts.

Even if it does not, it's worth the extra work to get it working in a separate thread. Your UI will thank you.

1
  • Right, let me do some research about using threads and such. I'll get back to you, though it might take a while.
    – Fnord23
    Jun 5, 2012 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.