hypfvieh / dbus-java

Improved version of java DBus library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/)
https://hypfvieh.github.io/dbus-java/
MIT License
185 stars 73 forks source link

Excessive marshalling for the logging on the inactive level #115

Closed OlegAndreych closed 4 years ago

OlegAndreych commented 4 years ago

In the org.freedesktop.dbus.Marshalling#deSerializeParameters(java.lang.Object[], java.lang.reflect.Type[], org.freedesktop.dbus.connections.AbstractConnection) method exists a call:

LOGGER.trace("Deserializing from {} to {} ", Arrays.deepToString(_parameters), Arrays.deepToString(_types));

I think there's no need to call Arrays.deepToString(_parameters) in the case when the trace level of the logging is inactive.

My proposal is to wrap beforementioned call into the LOGGER.isTraceEnabled() condition.

I've noticed that by observing huge CPU usage spikes during signal processing on the RPi.

hypfvieh commented 4 years ago

I improved the usage of Arrays.deepToString in logging calls, so this method should no longer be called when the loglevel is not enabled. This also was the case in some other locations, not only the one you changed.