We are currently developing a Scala and Akka Cluster based product for medical archives. In the code there is a lot of
if(logger.isDebugEnabled()) {
logger.debug(expensiveFunction())
}
In our previous codes with standard SQL/JPA, blocking I/O and lots of threads, this construction was more or less for free. However, today in the era of reactive programming, CPU cache synchronization and memory barriers and locks are considered expensive and should be avoided. Is the Logback isDebugEnabled() resulting in a volatile access and hence a memory barrier. If so, is having a lot of logger.isDebugEnabled() a potential performance killer?
There is an excellent blogpost on the topic of CPU cache synchronization and memory barriers: http://mechanical-sympathy.blogspot.se/2013/02/cpu-cache-flushing-fallacy.html