Core Data validation question
Core Data validation question
- Subject: Core Data validation question
- From: Aurélien Hugelé <email@hidden>
- Date: Mon, 19 Jun 2006 08:42:22 +0200
Hi everybody !
i'm facing a core data performance problem with memory store:
when my app is started, many temporary objects (computed on the fly
because they depend of the date) are created and stored in a memory
store.
Saving this memory store consumes a lot of time and CPU.
I've sharked the program (see the shark results below) and discovered
that a huge part of the time is spent in [NSManagedObject
validateValue:forKey:error:].
i have a very simple question:
i've implemented accessors for all my attributes, using "copy method
implementations to clipboard", but did not implement any of the
validate<Key>:error: methods...
Does implementing this method and (only) returning YES, avoids core
data to perform its checks about the validity of the attribute ?
( positive value for integer if set in the model, max length of
strings and many usefull checking to ensure data integrity)
As stated in the doc, the validate<Key>:error: method is searched for
each property, and if not found, the default implementation returns
YES. To improve performances, are we supposed to implement it ? from
what i can see in shark, NSKeyValueMethodForPattern is very slow, is
it the search method ?
any help ?
thanks
Shark results
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | + 6.9 s -[NSManagedObjectContext save:] (CoreData)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | + 6.0 s -[NSManagedObjectContext
(_NSInternalChangeProcessing) _prepareForPushChanges:] (CoreData)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | + 5.9 s -[NSManagedObjectContext
(_NSInternalAdditions) _validateChangesForSave:] (CoreData)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | + 5.9 s -[NSManagedObjectContext
(_NSInternalAdditions)
_validateObjects:forOperation:error:exhaustive:forSave:] (CoreData)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | + 5.9 s -[NSManagedObject
(_NSInternalMethods) _validateForSave:] (CoreData)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | + 4.2 s -[NSManagedObject
(_NSInternalMethods)
_validateEnumeratedProperties:forPropertyType:error:] (CoreData)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | + 3.3 s -[NSManagedObject
validateValue:forKey:error:] (CoreData)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | + 2.8 s -[NSObject
(NSKeyValueCoding) validateValue:forKey:error:] (Foundation)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | + 2.5 s
NSKeyValueMethodForPattern (Foundation)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | + 1.5 s class_getInstanceMethod
(libobjc.A.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 21.1 ms
pthread_mutex_unlock (libSystem.B.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 12.1 ms __spin_lock
(commpage [libSystem.B.dylib])
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 11.0 ms pthread_mutex_lock
(libSystem.B.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 2.0 ms
__i686.get_pc_thunk.bx (libSystem.B.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 2.0 ms 0xa00110f0 [1B]
(libSystem.B.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 1.0 ms 0xa0011113 [1B]
(libSystem.B.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 1.0 ms spin_unlock
(libSystem.B.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 1.0 ms _spin_lock
(libSystem.B.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | + 534.3 ms __sel_registerName
(libobjc.A.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 249.1 ms
_objc_search_builtins (libobjc.A.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | + 213.9 ms __objc_sel_set_get
(libobjc.A.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | | 212.9 ms
__objc_sel_set_findBuckets (libobjc.A.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 17.1 ms
pthread_mutex_unlock (libSystem.B.dylib)
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | | 17.1 ms __spin_lock
(commpage [libSystem.B.dylib])
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden