Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Data Import Performance Improvements #588

Closed
wants to merge 10 commits into
from

Conversation

Projects
None yet
3 participants

seepel commented Oct 13, 2013

This is a starting point, and open for discussion pull request regarding issue #450.

WARNING: I haven’t run any unit tests on my changes. I remember it used to be pretty straight forward, but I just wasn’t sure how to do it. Probably should be done before merging, I’m open to any pointers.

The main gist of this pull request is to cut down on the number of fetches required (especially when importing to-many relationships). With these changes I see ~3-4x improvement on large imports with nested to-many relationships.

Main changes:

  • Import from array fetches in batch, this trades off some memory for performance improvements.
  • Check to see if values need to be update before setting them. If there are no actual changes in content and the NSManagedObject gets touched, Xcode updates it’s version number resulting in many unnecessary UPDATE statements

Finally, another ~3-4x performance improvement can be made by not calling MR_swapMethodsFromClass on every single object. I didn’t quite grasp the reason for swapping back and forth all the time, so I didn’t change it here.

@tonyarnold tonyarnold was assigned Dec 29, 2013

I've been playing with these changes and they do seem to help. Sounds like MR 3.0 will have a lot of performance improvements on it (which will be good) but in the meantime some of the things done in this PR have definitely helped.

@tonyarnold tonyarnold closed this Oct 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment