<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for blog.smart-java.nl</title>
	<atom:link href="http://blog.smart-java.nl/blog/index.php/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smart-java.nl/blog</link>
	<description>Ordina J-Technologies - Java Blog</description>
	<lastBuildDate>Wed, 12 May 2010 21:44:32 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Running JPA (Hibernate3) and JTA on IBM Websphere 6.1 &amp; 7 by Peter Schuler</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/05/05/jpa-hibernate3-jta-was7/comment-page-1/#comment-687</link>
		<dc:creator>Peter Schuler</dc:creator>
		<pubDate>Wed, 12 May 2010 21:44:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1100#comment-687</guid>
		<description>You&#039;re observation that auto_commit does inhibit a seizable performance hit is correct. Using auto_commit means that the DB manager has to start and stop a transaction for every single query. Instead of using one transaction for all you&#039;re queries you end up with the overhead of a transaction for every query. And for no gain whatsoever as you loose all benefits of transactions.

Auto_commit should be avoided like the plague. And not only as performance issue. Think about concurrency and atomicity?</description>
		<content:encoded><![CDATA[<p>You&#8217;re observation that auto_commit does inhibit a seizable performance hit is correct. Using auto_commit means that the DB manager has to start and stop a transaction for every single query. Instead of using one transaction for all you&#8217;re queries you end up with the overhead of a transaction for every query. And for no gain whatsoever as you loose all benefits of transactions.</p>
<p>Auto_commit should be avoided like the plague. And not only as performance issue. Think about concurrency and atomicity?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reflection slow? Class vs. Constructor newInstance by soudmaijer</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/05/01/reflection-slow-class-vs-constructor-newinstance/comment-page-1/#comment-683</link>
		<dc:creator>soudmaijer</dc:creator>
		<pubDate>Wed, 12 May 2010 17:44:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1083#comment-683</guid>
		<description>Interesting read JK...

Have you tried to run the benchmark without -server? If yes, what was the outcome?</description>
		<content:encoded><![CDATA[<p>Interesting read JK&#8230;</p>
<p>Have you tried to run the benchmark without -server? If yes, what was the outcome?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reflection slow? Well, it depends&#8230; by Peter Lawrey</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/04/25/reflection-slow-well-it-depends/comment-page-1/#comment-667</link>
		<dc:creator>Peter Lawrey</dc:creator>
		<pubDate>Sat, 08 May 2010 21:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1065#comment-667</guid>
		<description>If each test is performing the same work, shouldn&#039;t the counter have the same value every time?</description>
		<content:encoded><![CDATA[<p>If each test is performing the same work, shouldn&#8217;t the counter have the same value every time?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reflection slow? Well, it depends&#8230; by Peter Lawrey</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/04/25/reflection-slow-well-it-depends/comment-page-1/#comment-666</link>
		<dc:creator>Peter Lawrey</dc:creator>
		<pubDate>Sat, 08 May 2010 21:51:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1065#comment-666</guid>
		<description>The default CompileThreshold is 10,000 unless you have changed it. e.g. -XX:CompileThreshold=10000 in which case the JIT won&#039;t have fully warmed up until you have called a method 10,000 times.

I suggest runing the test for at least 10,000 times, twice and discarding the first run.  I also suggest you run what you believe is the fastest first, to prevent earlier benchmarks from warming up the JVM and making later ones appear faster.

You can improve reflection performance by disabling the security check which is performed on every call. i.e. setAccessible(true) even if its public, which stops it checking its public. ;)

You could also benchmark using POJO&#039;s without accessor methods.  Fields via reflection can be faster, esp for primitive typed fields, and if this isn&#039;t fast enough you can try the *Unsafe* class which can be 2-3x faster again.  The Unsafe class is approriately named, BTW. ;)</description>
		<content:encoded><![CDATA[<p>The default CompileThreshold is 10,000 unless you have changed it. e.g. -XX:CompileThreshold=10000 in which case the JIT won&#8217;t have fully warmed up until you have called a method 10,000 times.</p>
<p>I suggest runing the test for at least 10,000 times, twice and discarding the first run.  I also suggest you run what you believe is the fastest first, to prevent earlier benchmarks from warming up the JVM and making later ones appear faster.</p>
<p>You can improve reflection performance by disabling the security check which is performed on every call. i.e. setAccessible(true) even if its public, which stops it checking its public. <img src='http://blog.smart-java.nl/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>You could also benchmark using POJO&#8217;s without accessor methods.  Fields via reflection can be faster, esp for primitive typed fields, and if this isn&#8217;t fast enough you can try the *Unsafe* class which can be 2-3x faster again.  The Unsafe class is approriately named, BTW. <img src='http://blog.smart-java.nl/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Running JPA (Hibernate3) and JTA on IBM Websphere 6.1 &amp; 7 by Roy van Rijn</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/05/05/jpa-hibernate3-jta-was7/comment-page-1/#comment-661</link>
		<dc:creator>Roy van Rijn</dc:creator>
		<pubDate>Thu, 06 May 2010 09:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1100#comment-661</guid>
		<description>A small snippet from the Spring (2.5.x) documentation:
&quot;..if you run a Spring-based application on the WebSphere Application Server, we highly recommend to use Spring 2.5&#039;s WebSphereUowTransactionManager as your PlatformTransactionManager of choice. This is also IBM&#039;s official recommendation.&quot;

So both Spring and WebSphere recommend you to use the UOW instead. For example if you use the standard JPA transaction manager things like PROPAGATION_REQUIRES_NEW suspend/resume won&#039;t work, but with UOW IBM supports it.</description>
		<content:encoded><![CDATA[<p>A small snippet from the Spring (2.5.x) documentation:<br />
&#8220;..if you run a Spring-based application on the WebSphere Application Server, we highly recommend to use Spring 2.5&#8217;s WebSphereUowTransactionManager as your PlatformTransactionManager of choice. This is also IBM&#8217;s official recommendation.&#8221;</p>
<p>So both Spring and WebSphere recommend you to use the UOW instead. For example if you use the standard JPA transaction manager things like PROPAGATION_REQUIRES_NEW suspend/resume won&#8217;t work, but with UOW IBM supports it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reflection slow? Class vs. Constructor newInstance by Jan-Kees van Andel</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/05/01/reflection-slow-class-vs-constructor-newinstance/comment-page-1/#comment-631</link>
		<dc:creator>Jan-Kees van Andel</dc:creator>
		<pubDate>Tue, 04 May 2010 19:59:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1083#comment-631</guid>
		<description>&lt;blockquote&gt;
The same bench with ITERATIONS=1000000 and THREADS=1 will “show” reflection performance 30 times slower than normal (which is currently closer to reality).
&lt;/blockquote&gt;
IMHO, this is not close to reality. Multithreading and concurrency are very real and my clients need solutions that scale, also with regards to concurrency.

But, I&#039;ve ran the test with multiple variations of thread counts and they result in pretty much the same numbers.

I know the claim that setAccessible(true) has a positive effect on performance. This is also pretty obvious when you look at the source code of Method and Constructor. But... in my experiment I didn&#039;t see any difference in performance, not even under high contention. I assume the JIT inlines the invoke() call and generates a fast-path for the common case.
So, I guess with modern VM&#039;s we can put the setAccessible(true) optimization in the &quot;performance myths&quot; bucket. :)&lt;/li&gt;

About the primitives, dunno how to use reflection with primitives. :S

You&#039;re right about the Varargs. I forgot them on the Method.invoke() calls. (I think the interchangeability of arrays and varargs was a big design flaw. See Arrays.asList() for an example) A simple test where I (re)used an array to hold the parameters, seemed to give me a 25% improvement. Thank you for that one. :)

I agree with your JIT argument.</description>
		<content:encoded><![CDATA[<blockquote><p>
The same bench with ITERATIONS=1000000 and THREADS=1 will “show” reflection performance 30 times slower than normal (which is currently closer to reality).
</p></blockquote>
<p>IMHO, this is not close to reality. Multithreading and concurrency are very real and my clients need solutions that scale, also with regards to concurrency.</p>
<p>But, I&#8217;ve ran the test with multiple variations of thread counts and they result in pretty much the same numbers.</p>
<p>I know the claim that setAccessible(true) has a positive effect on performance. This is also pretty obvious when you look at the source code of Method and Constructor. But&#8230; in my experiment I didn&#8217;t see any difference in performance, not even under high contention. I assume the JIT inlines the invoke() call and generates a fast-path for the common case.<br />
So, I guess with modern VM&#8217;s we can put the setAccessible(true) optimization in the &#8220;performance myths&#8221; bucket. <img src='http://blog.smart-java.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>About the primitives, dunno how to use reflection with primitives. :S</p>
<p>You&#8217;re right about the Varargs. I forgot them on the Method.invoke() calls. (I think the interchangeability of arrays and varargs was a big design flaw. See Arrays.asList() for an example) A simple test where I (re)used an array to hold the parameters, seemed to give me a 25% improvement. Thank you for that one. <img src='http://blog.smart-java.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I agree with your JIT argument.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reflection slow? Class vs. Constructor newInstance by Gluck</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/05/01/reflection-slow-class-vs-constructor-newinstance/comment-page-1/#comment-611</link>
		<dc:creator>Gluck</dc:creator>
		<pubDate>Mon, 03 May 2010 16:32:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1083#comment-611</guid>
		<description>This benchmarking method seems pretty wrong to me.
The &quot;normal&quot; run time spent is entirely on the threading stuff + cpu task scheduling due to the high number of threads, and definitely not spent calling getValue or setValue.

The same bench with ITERATIONS=10 will &quot;show&quot; reflection performance being very close to normal.
The same bench with ITERATIONS=1000000 and THREADS=1 will &quot;show&quot; reflection performance 30 times slower than normal (which is currently closer to reality).

Microbenchmarking is difficult, and often the conclusions taken from those is wrong.
In your case too many factors are tested at the same time, making the result benchmarks of not only reflection, but all those as well, such as:
- synchronization performance, as reflection is synchronized in Method.invoke for instance, you&#039;ll get better reflection performance in your bench by NOT sharing the cached Method instance between the threads.
- Integer autoboxing is used in the reflection case, involving more object creation (only 128 first Integer objects are cached) and garbaging. This overhead only occurs with primitive types.
- varargs are used in all operations (as you showed with constructor), making a lot of Object[] creation &amp; garbage, you can optimize that away as well

As finbar said, setAccessible(true) makes a huge difference for reflection, and brings reflection calls times to only 200% of regular calls.
It also bypasses security checks, and might be prevented by a lot of real-world apps java security policies.

But my final word about reflection performance is that it prevents JIT optimizations.
It might not be obvious in your case, but do the same test keeping only the getter in the loop, the normal case will get jit&#039;ed, not the reflection one, and even with all our efforts (setAccessible included), there&#039;ll be a LARGE difference between the 2 tests :)

Have fun !
Microbenchmarking Java seems a neverending task to me, but I do keep trying :)</description>
		<content:encoded><![CDATA[<p>This benchmarking method seems pretty wrong to me.<br />
The &#8220;normal&#8221; run time spent is entirely on the threading stuff + cpu task scheduling due to the high number of threads, and definitely not spent calling getValue or setValue.</p>
<p>The same bench with ITERATIONS=10 will &#8220;show&#8221; reflection performance being very close to normal.<br />
The same bench with ITERATIONS=1000000 and THREADS=1 will &#8220;show&#8221; reflection performance 30 times slower than normal (which is currently closer to reality).</p>
<p>Microbenchmarking is difficult, and often the conclusions taken from those is wrong.<br />
In your case too many factors are tested at the same time, making the result benchmarks of not only reflection, but all those as well, such as:<br />
- synchronization performance, as reflection is synchronized in Method.invoke for instance, you&#8217;ll get better reflection performance in your bench by NOT sharing the cached Method instance between the threads.<br />
- Integer autoboxing is used in the reflection case, involving more object creation (only 128 first Integer objects are cached) and garbaging. This overhead only occurs with primitive types.<br />
- varargs are used in all operations (as you showed with constructor), making a lot of Object[] creation &amp; garbage, you can optimize that away as well</p>
<p>As finbar said, setAccessible(true) makes a huge difference for reflection, and brings reflection calls times to only 200% of regular calls.<br />
It also bypasses security checks, and might be prevented by a lot of real-world apps java security policies.</p>
<p>But my final word about reflection performance is that it prevents JIT optimizations.<br />
It might not be obvious in your case, but do the same test keeping only the getter in the loop, the normal case will get jit&#8217;ed, not the reflection one, and even with all our efforts (setAccessible included), there&#8217;ll be a LARGE difference between the 2 tests <img src='http://blog.smart-java.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Have fun !<br />
Microbenchmarking Java seems a neverending task to me, but I do keep trying <img src='http://blog.smart-java.nl/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reflection slow? Class vs. Constructor newInstance by finbar</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/05/01/reflection-slow-class-vs-constructor-newinstance/comment-page-1/#comment-608</link>
		<dc:creator>finbar</dc:creator>
		<pubDate>Sun, 02 May 2010 16:33:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1083#comment-608</guid>
		<description>You can increase performance by calling setAccessible(true) on the constructor and method instances.</description>
		<content:encoded><![CDATA[<p>You can increase performance by calling setAccessible(true) on the constructor and method instances.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reflection slow? Well, it depends&#8230; by blog.smart-java.nl &#187; Blog archief &#187; Reflection slow? Class vs. Constructor newInstance</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/04/25/reflection-slow-well-it-depends/comment-page-1/#comment-603</link>
		<dc:creator>blog.smart-java.nl &#187; Blog archief &#187; Reflection slow? Class vs. Constructor newInstance</dc:creator>
		<pubDate>Sat, 01 May 2010 18:53:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1065#comment-603</guid>
		<description>[...] &#171; Reflection slow? Well, it depends&#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] &laquo; Reflection slow? Well, it depends&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reflection slow? Well, it depends&#8230; by Java Reflection API &#8211; mit Cache, ey! &#171; knallisworld</title>
		<link>http://blog.smart-java.nl/blog/index.php/2010/04/25/reflection-slow-well-it-depends/comment-page-1/#comment-595</link>
		<dc:creator>Java Reflection API &#8211; mit Cache, ey! &#171; knallisworld</dc:creator>
		<pubDate>Wed, 28 Apr 2010 22:15:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.smart-java.nl/blog/?p=1065#comment-595</guid>
		<description>[...] Jeder Zugriff über die Reflection API kostet Zeit. Für Konfigurationen und Pläne ist das meist nebensächlich; die JPA-Konfiguration wird beim Start der Applikation eingelesen, analysiert und gespeichert. Nebenbei profitiert das natürlich von der anfänglichen &#8220;Warmup-Phase&#8221;. [...]</description>
		<content:encoded><![CDATA[<p>[...] Jeder Zugriff über die Reflection API kostet Zeit. Für Konfigurationen und Pläne ist das meist nebensächlich; die JPA-Konfiguration wird beim Start der Applikation eingelesen, analysiert und gespeichert. Nebenbei profitiert das natürlich von der anfänglichen &#8220;Warmup-Phase&#8221;. [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
