Allow faster eventhandler dispatching by keeping pointers to handler lists.

Ian Lepore ian at freebsd.org
Sun Oct 29 17:03:52 UTC 2017


On Sun, 2017-10-29 at 09:38 -0700, Matt Joras wrote:
> On 10/29/2017 09:24, Ian Lepore wrote:
> > 
> > On Sun, 2017-10-29 at 10:12 -0600, Ian Lepore wrote:
> > > 
> > > Actually, it looks like we've done nearly identical work, modulo some
> > > minor naming differences (that I'm completely agnostic about), and you
> > > have the EHL_NONEMPTY flag that didn't occur to me until after I
> > > created the phab review last night.
> > > 
> > > The other big difference is that mine still links the fast/static lists
> > > into the global list-of-lists, to preserve what I call "late loose
> > > binding" where an event handler can register for events before the
> > > event provider is present (picture a module that monitors events which
> > > gets loaded before a module that produces those events).
> > > 
> > > It ocurred to me this morning that an optimization for mine would be to
> > > place any list created by eventhandler_create_list() at the end of the
> > > global list, on the theory that it will mostly be accessed directly via
> > > pointer and the items at the head of the global list should be the ones
> > > more likely to be searched by name.
> > > 
> > > -- Ian
> > Oops, I apparently overlooked _eventhandler_insert_static() in your
> > changes.  I think if that were changed to first check whether the new
> > handler list already exists on the global list, our changes really
> > would be essentially identical.
> > 
> > -- Ian
> Indeed. The other difference I noted is that my version
> statically-allocates the actual list structs, and relies on static
> initialization, whereas yours uses malloc and initializes them explicitly.
> 
> How would you like to proceed?
> 
> Matt
> 

Oh.  Right.  Hmmm, I think malloc() is required to support the case
where a handler registers before the static list init is invoked, and I
do think that's a useful feature to preserve.  That means the lists
aren't really static, though, which then makes STATIC a bit out of
place in the new function/macro names.

>From my version of the changes, I really liked then names
EVENTHANDLER_DEFINE_LIST() and EVENTHANDLER_DECLARE_LIST() because they
so exactly say what they do.  On the other hand, I hate
EVENTHANDLER_INVOKE_LIST(), I just couldn't think of anything
better.  I considered FAST where LIST appears, playing off the existing
'slow' comments, but it seems to somehow imply the handlers themselves
are different or faster, which is all wrong.

-- Ian




More information about the freebsd-arch mailing list