<div dir="ltr"><div><div><div><div><div><div>Ok,<br><br></div>thanks for clarifying it.<br><br></div>So there is a factor of 3 for the test if no trace is enabled, just for checking.<br></div>It makes sense to use it.<br></div>But my concern is still that it is sometimes good to have the possibility to enable debug for some important information in production just on the fly and switch it of to prevent from throtteling the server by that log statements or restart the server.<br></div>We have the same issue in EAP but here a restart is not that bad as here you don&#39;t have to load the cache or rebalance the cluster for stop/start.<br><br></div>- Wolf<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 30, 2016 at 1:53 PM, David M. Lloyd <span dir="ltr">&lt;<a href="mailto:david.lloyd@redhat.com" target="_blank">david.lloyd@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 09/30/2016 01:53 AM, Sebastian Laskawiec wrote:<br>
&gt; Hey!<br>
&gt;<br>
&gt; A while ago I asked Radim and Dan about these kind of constructs [1]:<br>
&gt;<br>
&gt; private boolean trace = logger.isTraceEnabled(); //stored in a field<br>
&gt;<br>
&gt; ... called in some method ...<br>
&gt;     if(trace)<br>
&gt;         logger.tracef(...);<br>
&gt; ...<br>
&gt;<br>
&gt; At first they seemed wrong to me, because if one changes logging level<br>
&gt; (using JMX for example), the code won&#39;t notice it. I also though it&#39;s<br>
&gt; quite ok to use tracef directly, because JIT will inline and optimize it.<br>
&gt;<br>
&gt; Unfortunately my benchmarks [2] show that I was wrong. Logger#tracef<br>
&gt; indeed checks if the logging level is enabled but since JBoss Logging<br>
&gt; may use different backends, the check is not trivial and is not inlined<br>
&gt; (at least with default settings).<br>
<br>
</span>What backend where you using with your test?<br>
<span class=""><br>
&gt; The performance results look like this:<br>
&gt; Benchmark                  Mode  Cnt           Score          Error  Units<br>
</span>&gt; MyBenchmark.noVariable    thrpt   20   *717252060.124* ± 13420522.229  ops/s<br>
&gt; MyBenchmark.withVariable  thrpt   20  *2358360244.627* ± 50214969.572  ops/s<br>
<span class="im HOEnZb">&gt;<br>
&gt; So if you even see a construct like this: logger.debuf or logger.tracef<br>
&gt; - make sure you check if the logging level is enabled (and the check<br>
&gt; result is stored in a field).<br>
&gt;<br>
&gt; That was a bit surprising and interesting lesson :D<br>
&gt;<br>
&gt; Thanks<br>
&gt; Sebastian<br>
&gt;<br>
&gt; [1] <a href="https://github.com/infinispan/infinispan/pull/4538#discussion_r80666086" rel="noreferrer" target="_blank">https://github.com/infinispan/<wbr>infinispan/pull/4538#<wbr>discussion_r80666086</a><br>
&gt; [2] <a href="https://github.com/slaskawi/jboss-logging-perf-test" rel="noreferrer" target="_blank">https://github.com/slaskawi/<wbr>jboss-logging-perf-test</a><br>
&gt;<br>
&gt;<br>
</span><span class="im HOEnZb">&gt; ______________________________<wbr>_________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a><br>
&gt;<br>
<br>
--<br>
</span><span class="HOEnZb"><font color="#888888">- DML<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/infinispan-<wbr>dev</a></div></div></blockquote></div><br></div>