Re: experimental ZODB prefetch support in ZEO
Jim Fulton <[email protected]>
| Newsgroups | gmane.comp.web.zope.zodb |
|---|---|
| Message-ID | <CAPDm-Fjc1SCvcNQUMg8sJwxc-E9uFbnGTgdVS8RjpNxJ+k_8Aw@mail.gmail.com> |
On Sun, Jul 17, 2016 at 3:34 PM, Julien Muchembled <[email protected]> wrote: > Le 07/15/16 à 14:47, Jim Fulton a écrit : > > For years, people have been asking for a bulk load feature, especially > > in ZEO and especially to aid startup. For years, I've been threatening > > to add a prefetch feature to address this requirement. I finally took > > the first step towards this yesterday. > > Prefetching is also something we'd like to do at Nexedi, because it would > certainly speed up our applications, with ZEO or NEO, not only at startup. > > However, the biggest issue for us is to know which oids to prefetch. Yup. However, now(ish) that we have prefetch, people can explore different ideas for using it. > In fact, it's so difficult that we though about something different than > an explicit method call to the connection or storage. > > In ERP5, requests that loads many oids and for which we have an idea to > optimize are those that loop over several objects, like children of the > same folder. We think that with 'greenlet', we could manage to process > iterations of such loops in parallel: whenever a load is about to wait for > IO, the current iteration would be suspended and another would start/resume. So you'd launch greenlets to deal with each of the children? I'd be interested to see pseudocode to see how this might look in an application. > This can lead to several tasklets loading oids at the same time, which is > also a good thing because only one network packet could be sent to retrieve > these oids. > How only one network packet? > More generally, we're more interested in something that would allow the > caller to continue execution elsewhere whenever the storage has to wait. > That's how prefetch works. ZEO prefetch doesn't block. The application can go on about its business without blocking until it needs an object that's still inflight. For the folder use case above, you'd just prefetch the children. It might be interesting to have some collection classes that did this automatically, say when someone called ``values`` or started iterating. A variation on this theme might be to have a collection with an iterator that prefetched the next object or few objects after the current item being iterated. Also note that ZEO 5, unlike ZEO 4, allows multiple outstanding loads (loadBefores), so an application that expected to spend a lot of time waiting on the storage server could be split into threads and actually load in parallel. BTW, I implemented the ZODB side of this: https://github.com/zopefoundation/ZODB/pull/92 Jim -- Jim Fulton http://jimfulton.info -- You received this message because you are subscribed to the Google Groups "zodb" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.