title: Is logback isDebugEnabled() slow on a multi core CPU?
body: <p>We are currently developing a Scala and Akka Cluster based product for medical archives. In the code there is a lot of</p>
  
  <pre><code>if(logger.isDebugEnabled()) {
      logger.debug(expensiveFunction())
  }
  </code></pre>
  
  <p>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?</p>
  
  <p>There is an excellent blogpost on the topic of CPU cache synchronization and memory barriers:
  <a href="http://mechanical-sympathy.blogspot.se/2013/02/cpu-cache-flushing-fallacy.html" rel="nofollow">http://mechanical-sympathy.blogspot.se/2013/02/cpu-cache-flushing-fallacy.html</a></p>