[PATCHES] Logging to multiple debug backends

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Mar 16 04:56:06 MDT 2015

On Sat, Mar 14, 2015 at 02:52:05PM +1100, Martin Schwenke wrote:
> The debug code is very heavily used so I would prematurely
> optimise.  :-)  Instead of using an array of all possible backends in
> debug_set_backends() and debug_backends_log(), I would suggest using a
> doubly-linked list, and inserting the backends in reverse-sorted order
> of priority.  Then you only need to traverse the list as long as
> msg_level <= log_level.  This makes debug_set_backends() more expensive
> but makes debug_backends_log() cheaper.

If you *really* want to prematurely optimize, I would recommend splitting
the array into two, just for cache locality. If you make it two arrays,
one with full information and one with just what is required in the
debug_backends_log for-loop, you should be able to squeeze 4 backends
into 64 bytes. At that point I'd say the for-loop over all those 4
backends comes at almost no cost. Most of it should be hidden behind
loop unrolling and speculative execution. A linked list will very likely
be much more expensive to chase through our 15 levels of cache these
days. That together with the fact that we only enter debug_backends_log()
when there is something to log, my gut feeling is that everything else
will be much more expensive than walking 2 or 3 backends unnecessarily.


SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de

More information about the samba-technical mailing list