提交 27f2edf9 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 1a8d91d9
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册