<div dir="ltr">Hey!<div><br></div><div>Please have a look at the latest perf test results [1][2]:</div><div><div><br></div><div><div>Benchmark                             Mode  Cnt           Score          Error  Units</div><div>MyBenchmark.noVariable               thrpt   20   <b>681131269.875</b> ±  3961932.923  ops/s</div><div>MyBenchmark.withIsTraceEnabledCheck  thrpt   20   <b>676307984.921</b> ± 14305970.393  ops/s</div><div>MyBenchmark.withVariable             thrpt   20  <b>2411000894.582</b> ± 17382438.635  ops/s</div></div></div><div><br></div><div>I think there is no surprise here.. using a field, which stores the result of `logger.isTraceEnabled()` evaluation is 3 times faster than other options.</div><div><br></div><div>If anyone is interested in printing out JIT stuff, I also ran it with &quot;-XX:+PrintCompilation&quot;, &quot;-XX:+PrintCompilation2&quot; and &quot;-XX:+PrintInlining&quot; here [3]. </div><div><br></div><div>I&#39;m not a performance expert but it seems that JIT could not inline the &quot;translate&quot; method because of its size (see line 1861). However it tried several times with different optimizations (and some of them were thrown away - &quot;made not entrant&quot; messages [4]).</div><div><br></div><div>Let&#39;s wait for James&#39; opinion on this, but I think we should address this issue on JBoss Logging/LogManager side (so I agree with David here) and make those parts inlinable (wow, does this word even exist? :D). Once this is done, we could experiment further in Infinispan codebase and see how this relates to some real world benchmarks...</div><div><br></div><div>Thanks</div><div>Sebastian</div><div><br></div><div>[1] <a href="https://gist.github.com/slaskawi/6766b6e17c7a28ac8d8962293c48a53c">https://gist.github.com/slaskawi/6766b6e17c7a28ac8d8962293c48a53c</a></div><div>[2] Test repository: <a href="https://github.com/slaskawi/jboss-logging-perf-test">https://github.com/slaskawi/jboss-logging-perf-test</a></div><div>[3] <a href="https://gist.github.com/slaskawi/6f317bb05539611434bc91d66924bae0">https://gist.github.com/slaskawi/6f317bb05539611434bc91d66924bae0</a></div><div>[4] <a href="https://www.safaribooksonline.com/library/view/java-performance-the/9781449363512/ch04.html">https://www.safaribooksonline.com/library/view/java-performance-the/9781449363512/ch04.html</a></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 3, 2016 at 7:32 AM, Sebastian Laskawiec <span dir="ltr">&lt;<a href="mailto:slaskawi@redhat.com" target="_blank">slaskawi@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hey!<div><br></div><div>Adding James to this thread.</div><div><br></div><div>@Dennis - I think Dan has a point here. The trick with checking a field in a class is 3 times faster. Most of the checks are done in core so they are executed multiple times per operation. Changing all those places is probably not an option.</div><div><br></div><div>@David - Let me run a test with JBoss Log Manager and get back to you with some results. But if Dan is right, and the problem is with enum mapping, I will get similar results.</div><div><br></div><div>Thanks</div><span class="gmail-HOEnZb"><font color="#888888"><div>Sebastian</div></font></span></div><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 1, 2016 at 11:53 AM, Dan Berindei <span dir="ltr">&lt;<a href="mailto:dan.berindei@gmail.com" target="_blank">dan.berindei@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span>On Fri, Sep 30, 2016 at 10:15 PM, David M. Lloyd &lt;<a href="mailto:david.lloyd@redhat.com" target="_blank">david.lloyd@redhat.com</a>&gt; wrote:<br>
&gt; The performance problem that this trick is meant to resolve is really a<br>
&gt; problem in the logging backend.  It *should* be faster inside of<br>
&gt; WildFly, where JBoss LogManager is used, because that project just<br>
&gt; checks a single volatile field for the level check... and the path to<br>
&gt; that code *should* be inline-friendly.<br>
&gt;<br>
<br>
</span>Indeed, we started using this trick because of log4j 1.2, which needs<br>
to walk the logger hierarchy in order to check the level, and it made<br>
a significant difference there.<br>
<br>
Nowadays I think it&#39;s pretty close to optimal in all logging<br>
frameworks. The only nitpick is that they all use enums for the<br>
levels, and the JIT can&#39;t inline Level.TRACE.value as it would with a<br>
Level.TRACE_VALUE int constant. If JDK9 fixes that, then it&#39;s going to<br>
be more or less equivalent to using a volatile &quot;trace&quot; field in each<br>
class, so it should be suitable even for local read operations that<br>
take &lt; 200ns.<br>
<br>
We&#39;d probably still need to weed out some of the trace messages, as we<br>
probably have more than 10 of them during such a read operation. I<br>
confess that I added way too many trace logs myself, precisely because<br>
I knew we are using a static final field and the JIT compiler doesn&#39;t<br>
even generate code for that branch.<br>
<br>
Cheers<br>
<span><font color="#888888">Dan<br>
</font></span><div><div>______________________________<wbr>_________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org" target="_blank">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/mailma<wbr>n/listinfo/infinispan-dev</a><br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>