FROM : Ben Trumbull
DATE : Tue Jan 15 23:50:30 2008
Martin,
Looking at the Instruments snapshot, one can see most of the time is
spent maintaining the inverse relationship as that is triggering
faulting of unloaded data.
When you dirty a managed object for the first time, we need its
current data to establish a snapshot. The snapshot is used for
several features including undo, merge policies & conflict detection,
and the committedValuesForKeys/changedValues methods. This includes
the identities (but not full data) of object's current relationships.
For to-many relationships, this can trigger additional faulting (in
database terms, a fetch against the join table)
You can address the problem by prefetching Foo's to-many
relationships during your initial fetch. If Bar has other to-many
relationships, you'll want to prefetch those in the fetch request for
"bar where ID = X"
The Instruments set you used doesn't include all the Core Data
instruments from the main template, specifically "Core Data Cache
Misses", so Instruments isn't high lighting the specific problem as
well as it could.
If you add that instrument, you should see both the entity and
relationships that are being faulted.
--
-Ben
DATE : Tue Jan 15 23:50:30 2008
Martin,
Looking at the Instruments snapshot, one can see most of the time is
spent maintaining the inverse relationship as that is triggering
faulting of unloaded data.
When you dirty a managed object for the first time, we need its
current data to establish a snapshot. The snapshot is used for
several features including undo, merge policies & conflict detection,
and the committedValuesForKeys/changedValues methods. This includes
the identities (but not full data) of object's current relationships.
For to-many relationships, this can trigger additional faulting (in
database terms, a fetch against the join table)
You can address the problem by prefetching Foo's to-many
relationships during your initial fetch. If Bar has other to-many
relationships, you'll want to prefetch those in the fetch request for
"bar where ID = X"
The Instruments set you used doesn't include all the Core Data
instruments from the main template, specifically "Core Data Cache
Misses", so Instruments isn't high lighting the specific problem as
well as it could.
If you add that instrument, you should see both the entity and
relationships that are being faulted.
--
-Ben






Cocoa mail archive

