Lazily registering hooks?

Jelmer Vernooij jelmer at vernstok.nl
Tue Jun 1 18:10:50 BST 2010


On Sun, 2010-05-30 at 13:55 -0400, John Yates wrote:
> What about lazing caching of hook registrations validated by plugin path/size/dtm.
> Would that not support "installation" via simple copying, registration prior to any
> hook evaluation and preservation of low amortized overhead?
The problem isn't really in loading the hooks themselves, we can
trivially do that in a lazy fashion - the issue is that registering any
sort of hook requires us to import the hook point for that hook, and
importing that hook point can be expensive.

Cheers,

Jelmer

> ________________________________________
> From: bazaar-bounces at lists.canonical.com [bazaar-bounces at lists.canonical.com] On Behalf Of Jelmer Vernooij [jelmer at samba.org]
> Sent: Sunday, May 30, 2010 1:01 PM
> To: John Arbash Meinel
> Cc: bazaar at lists.canonical.com
> Subject: Re: Lazily registering hooks?
> 
> On Sun, 2010-05-30 at 11:56 -0500, John Arbash Meinel wrote:
> > Jelmer Vernooij wrote:
> > > IIRC there was some discussion about this at the recent sprint during
> > > UDS, but I wasn't there for it.
> > >
> > > One of the slowdowns for me in starting up Bazaar is importing the
> > > various modules that the plugins I have installed install hooks in. E.g.
> > > bzr-svn has to load bzrlib.info, bzrlib.diff, bzrlib.send,
> > > bzrlib.filters, bzrlib.version_info_formats.format_rio.
> > >
> > > It'd be great if there was some way to lazily register hooks. I don't
> > > have any good ideas on how to fix that without giving up some of the
> > > benfits that our current infrastructure has (I don't want to centralize
> > > all hooks in a single file). Does anybody else have ideas?
> > The best I can think of still just ends up with a central registry. The
> > Hook code could be localized, but it would end up saying "what bits were
> > interested in my hook", and then call back to have them loaded.
> That doesn't seem too bad actually, especially given this could all be done
> under the covers in bzrlib.hooks (and the plugins would have to be updated, of
> course).
> 
> > I don't think we can really get away from that.
> >
> > Well, one option is to turn the registration into config code, that only
> > gets read when the hook runs, or something like that. But then the user
> > has to get involved, rather than just 'installing' the plugin.
> Yeah, that's probably not the best idea. The fact that plugins "just
> work" is one of the nicest things about them in Bazaar.
> 
> Cheers,
> 
> Jelmer




More information about the bazaar mailing list