Reduce performance overhead of the global log buffer
Reduce performance overhead of the global log buffer

With the vast number of log debug statements in the code, the
logging framework has a measurable performance impact on libvirt
code, particularly in the daemon event loop.

The global log buffer records every single log message triggered
whether anyone cares to see them or not. This makes it impossible
to eliminate the overhead of printf format expansions in any of
the logging code. It is possible to disable the global log buffer
in libvirtd itself, but this doesn't help client side library
code. Also even if disabled by the config file, the existence of
the feature makes other performance improvements in the logging
layer impossible.

Instead of logging every single message to the global buffer, only
log messages that pass the log filters. This if libvirtd is set
to have log_filters="1:libvirt 1:qemu" the global log buffer will
only get filled with those messages instead of everything. This
reduces the performance burden, as well as improving the signal
to noise ratio of the log buffer.

As a quick benchmark, a demo program that registers 500 file
descriptors with the event loop (eg equiv of 500 QEMU monitor
commands), creates pending read I/O on every FD, and then runs
virEventRunDefaultImpl() took 1 minute 40 seconds to do 51200
iterations with nearly all the time shown against the logging
code. After this optimization it only takes 4.6 seconds.

Signed-off-by: Daniel P. Berrange <bb938cf255e055ff3507f2627d214e8e62118fcf@redhat.com>

rlaager/libvirt,crobinso/libvirt,crobinso/libvirt,VenkatDatta/libvirt,taget/libvirt,taget/libvirt,VenkatDatta/libvirt,rlaager/libvirt,andreabolognani/libvirt,jardasgit/libvirt,olafhering/libvirt,olafhering/libvirt,jardasgit/libvirt,eskultety/libvirt,VenkatDatta/libvirt,agx/libvirt,shugaoye/libvirt,elmarco/libvirt,rlaager/libvirt,eskultety/libvirt,jfehlig/libvirt,jfehlig/libvirt,nertpinx/libvirt,zippy2/libvirt,agx/libvirt,VenkatDatta/libvirt,taget/libvirt,jfehlig/libvirt,jardasgit/libvirt,crobinso/libvirt,taget/libvirt,andreabolognani/libvirt,nertpinx/libvirt,crobinso/libvirt,agx/libvirt,elmarco/libvirt,eskultety/libvirt,shugaoye/libvirt,jardasgit/libvirt,olafhering/libvirt,eskultety/libvirt,agx/libvirt,taget/libvirt,olafhering/libvirt,datto/libvirt,andreabolognani/libvirt,datto/libvirt,andreabolognani/libvirt,elmarco/libvirt,datto/libvirt,shugaoye/libvirt,shugaoye/libvirt,zippy2/libvirt,datto/libvirt,elmarco/libvirt,rlaager/libvirt,datto/libvirt,fabianfreyer/libvirt,agx/libvirt,nertpinx/libvirt,libvirt/libvirt,fabianfreyer/libvirt,andreabolognani/libvirt,jardasgit/libvirt,nertpinx/libvirt,VenkatDatta/libvirt,fabianfreyer/libvirt,libvirt/libvirt,eskultety/libvirt,nertpinx/libvirt,zippy2/libvirt,elmarco/libvirt,shugaoye/libvirt,fabianfreyer/libvirt,libvirt/libvirt,rlaager/libvirt,zippy2/libvirt,libvirt/libvirt,fabianfreyer/libvirt,jfehlig/libvirt