[CORE DATA] BackgroundFetching app explanation, and more...
[CORE DATA] BackgroundFetching app explanation, and more...
- Subject: [CORE DATA] BackgroundFetching app explanation, and more...
- From: Aurélien Hugelé <email@hidden>
- Date: Mon, 19 Dec 2005 19:38:22 +0100
Hi list and all core data masters that have helped me recently!
I would like to do a fetch in a thread because of core data slowness:
i have about 50 000 objects to fetch and unfault the first time the
user ask for them. The objects are displayed sorted by date,
descendingly, So that he immediatly sees the most recent entries.
As several people knows, fetching and unfaulting 50 000 objects with
core data is slow (my objects do not have many attributes, and they
are very simple (few dates, very small strings etc...)) : it takes
about 30s on a 2*2Ghz G5 with 3GB of RAM to display the datas in a
tableview!!! I already reported this problem on this list ("Core
Data Fetch request very poor performance ??!"), i suceeded to get
better results thanks to help from some of you, mainly by redesigning
my model to use more relationships, and avoid my big blobs of datas.
This post did start a sort of little flameware, and i hope this
message will not start another one :).
To conclude on what is slow : unfaulting is slow : unfaulting datas
take about 25seconds of the total time. While the fetch request takes
about 5 seconds to execute (which i find too long too, but...). This
is from Shark report. I insist that basically the fetch request is
VERY simple : i want ALL entries of a certain Entity... so i fetch
ALL : the fetch request has no predicate! the result of this fetch is
put in an arraycontroller, and that is of course what start the
unfaulting of datas : displaying the entries in a tableview sorted
descendingly unfaults each objects, one by one (?) when accessing to
dates...
So, i want to find a cheating solution do display datas by burst to
the user :
instead of fetching and unfaulting 50 000 objects *at once*, i would
like to fetch the 1000 most recent ones first, display them as fast
as possible by putting them in an NSArrayController that controls a
tableview. Then, in a thread, fetch the remaining ones, probably by
block of 5000 objects (from date1 to date2 inceremented for each
blocks), unfault them (using UNEXPLAINED/UNSUCCESSFUL batch faulting?
I saw on this same list a question about batch faulting that was not
really answered :)) and add them to the arraycontroller. I hope this
will give the user a better experience (like Mail) because he will
probably focus on the most recent entries, displayed quickly because
few objects will be unfaulted at the first time. Then the other
entries will appear by blocks few seconds later, and be added at the
end of the arrayController , without disturbing the user...
first is that possible? is it a good idea? is it easy to implement?
if yes, let's go to the second part :
i've studied BackgroundFetching app to learn about core data and
multithreading...
i have a quite simple question, in method : - (void)
fetchWordsForLetter:(NSManagedObject *)letter why do you execute a
fetch request (wordFetch) that finds all Words for a letter, when
you **already** have a (faster, from my experience) relationship for
that ??? more funny: you start by fetching, then "evaluate" the
relationship !!! you are doing the same jobs twice don't you ? There
is a vague comment "Fault the words relationship on the letter, The
precise contents of the relationship are a separate fault-firing
(fetch) from the actual words data" what does this mean ?? "Fault" ??
are'nt you "UNfaulting" ??? or even do nothing since you do not
access any attribute, but only relationship (that do not fire faults?!)?
Can any one explain me a little bit more what is happening here ?
From what i understand, unfaulting objects is one context is not
useful if the objects are to be passed in another context, because
they will be unfaulted in the destination context anyway... am i wrong ?
thanks for your help. Core data helped me a lot in my project, i was
able to rewrite *a big* part of my project in no time with it. But,
like many other on this list, i'm frustrated by the poor
performances i can achieve with not so large numbers of entries. I'm
always modifying my model and measuring performance instead of coding
smart features... I can recognize that my first designs were
responsible of the poor performance i had, but i think i've reached a
wall now, and i think there is something "lacking" in core data....
SPEED. We need concrete batch faulting code sample, something to
measure the performance gain. We need some tips and advices to get
better results. Aperture seems quite fast (not really played with it,
and i had too few datas. I passed more time to read the class dump :-
P to try to understand how Apple engineers did design the core data
part of this big application) so it seems possible to get better
performance, by using AND EXPLAINING "relationship prefetching" etc...
Thanks to have read this rant :)
Aurelien
_______________________________________________
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