mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
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 <berrange@redhat.com>
This commit is contained in:
parent
1a8d91d922
commit
27f2edf96c
@ -833,7 +833,7 @@ virLogVMessage(virLogSource source,
|
||||
emit = false;
|
||||
}
|
||||
|
||||
if (!emit && ((virLogBuffer == NULL) || (virLogSize <= 0)))
|
||||
if (!emit)
|
||||
goto cleanup;
|
||||
|
||||
/*
|
||||
@ -862,11 +862,7 @@ virLogVMessage(virLogSource source,
|
||||
virLogStr(timestamp);
|
||||
virLogStr(": ");
|
||||
virLogStr(msg);
|
||||
virLogUnlock();
|
||||
if (!emit)
|
||||
goto cleanup;
|
||||
|
||||
virLogLock();
|
||||
for (i = 0; i < virLogNbOutputs; i++) {
|
||||
if (priority >= virLogOutputs[i].priority) {
|
||||
if (virLogOutputs[i].logVersion) {
|
||||
|
Loading…
Reference in New Issue
Block a user