<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>williamhathaway.com &#187; java</title>
	<atom:link href="http://www.williamhathaway.com/wordpress/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.williamhathaway.com/wordpress</link>
	<description></description>
	<lastBuildDate>Tue, 30 Nov 2010 05:38:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Printing Java garbage collection time stamps</title>
		<link>http://www.williamhathaway.com/wordpress/2009/09/01/printing-java-garbage-collection-time-stamps/</link>
		<comments>http://www.williamhathaway.com/wordpress/2009/09/01/printing-java-garbage-collection-time-stamps/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 03:42:40 +0000</pubDate>
		<dc:creator>William Hathaway</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://www.williamhathaway.com/wordpress/?p=455</guid>
		<description><![CDATA[I&#8217;ve been spending a bunch of time lately looking at Java garbage collection (GC) performance &#38; tuning.  One of the old standby options for GC logging is: -XX:+PrintGCTimeStamps this option tells the JVM to print a time stamp in the front of each GC line that is the number of seconds since the Java process [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been spending a bunch of time lately looking at Java garbage collection (GC) performance &amp; tuning.  One of the old standby options for GC logging is:</p>
<p><strong>-XX:+PrintGCTimeStamps</strong></p>
<p>this option tells the JVM to print a time stamp in the front of each GC line that is the number of seconds since the Java process started.  You end up with lines like:</p>
<p>1.449: [GC 76756K-&gt;5892K(504320K), 0.0226648 secs]<br />
1.472: [Full GC 5892K-&gt;5752K(504320K), 0.1099638 secs]<br />
4.276: [GC 137848K-&gt;14895K(504320K), 0.0333021 secs]<br />
5.653: [GC 146991K-&gt;63707K(504320K), 0.0858191 secs]<br />
38.536: [GC 195803K-&gt;77393K(636416K), 0.0683676 secs]<br />
144.875: [GC 341585K-&gt;97580K(637440K), 0.1131954 secs]</p>
<p>While these are better than nothing, it can be a PITA to translate these to something useful, like say wall clock time, such as when you want to correlate a GC time to an external alarm.</p>
<p>Starting in Sun&#8217;s JDK version 1.6u4, there is another option that can be enabled that actually prints both the wall clock time as well as the seconds since process start.  This is way more user-friendly.  I suspect there is a extremely minute performance penalty to add this extra info, but I&#8217;d be shocked if it is actually perceptable.  If anyone knows differently, please let me know.  This option is:</p>
<p><strong>-XX:+PrintGCDateStamps</strong></p>
<p>If you have it enabled, the output looks like:</p>
<p>2009-09-02T23:02:07.151-0400: 1.463: [GC 79398K-&gt;5887K(504320K), 0.0236701 secs]<br />
2009-09-02T23:02:07.175-0400: 1.486: [Full GC 5887K-&gt;5753K(504320K), 0.1095894 secs]<br />
2009-09-02T23:02:10.028-0400: 4.339: [GC 137849K-&gt;14987K(504320K), 0.0345331 secs]<br />
2009-09-02T23:04:31.707-0400: 146.018: [GC 147083K-&gt;23143K(504320K), 0.0455040 secs]<br />
2009-09-02T23:14:28.502-0400: 742.813: [GC 155239K-&gt;28406K(504320K), 0.0912850 secs]</p>
<p>As you can see, this is much more easily digestable to  humans.  Since you still have the &#8216;seconds since program start&#8217; info handy, you can continue to use scripts/programs to easily calculate the time deltas between GCs.</p>
<p>Some useful links I&#8217;ve found for Java tuning in general are:</p>
<ul>
<li>Resources from Matty&#8217;s presentation:</li>
</ul>
<p style="padding-left: 30px;"><a href="http://prefetch.net/blog/index.php/2008/02/05/java-performance-presentation/">http://prefetch.net/blog/index.php/2008/02/05/java-performance-presentation/</a></p>
<ul>
<li>Java performance forum:</li>
</ul>
<p style="padding-left: 30px;"><a href="http://forums.java.net/jive/forum.jspa?forumID=60">http://forums.java.net/jive/forum.jspa?forumID=60</a></p>
<ul>
<li>Jon Masamitsu&#8217;s blog: (the last post was over a year ago, starting to age, but some good material)</li>
</ul>
<p style="padding-left: 30px;"><a href="http://blogs.sun.com/jonthecollector/">http://blogs.sun.com/jonthecollector/</a></p>
<ul>
<li>Garbage Collection Tuning in the Java HotSpot Virtual Machine presentation at Java One 2009</li>
</ul>
<p style="padding-left: 30px;"><a href="http://developers.sun.com/learning/javaoneonline/j1sessn.jsp?sessn=TS-4887&amp;yr=2009&amp;track=javase">http://developers.sun.com/learning/javaoneonline/sessions/2009/pdf/TS-4887.pdf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamhathaway.com/wordpress/2009/09/01/printing-java-garbage-collection-time-stamps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java garbage collection gone horribly wrong</title>
		<link>http://www.williamhathaway.com/wordpress/2008/08/28/java-garbage-collection-gone-horribly-wrong/</link>
		<comments>http://www.williamhathaway.com/wordpress/2008/08/28/java-garbage-collection-gone-horribly-wrong/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 01:02:53 +0000</pubDate>
		<dc:creator>William Hathaway</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://williamhathaway.com/?p=200</guid>
		<description><![CDATA[I was at a customer site and saw a java app that was chewing CPU.  Using prstat -L  we saw the busy threads were 2 through 9.  Running pstack $pid/$thread showed that the spinning threads were all running garbage collection.  Luckily verbose GC logging was turned on so we were able to look at the [...]]]></description>
			<content:encoded><![CDATA[<p>I was at a customer site and saw a java app that was chewing CPU.  Using <strong>prstat -L</strong>  we saw the busy threads were 2 through 9.  Running <strong>pstack <em>$pid</em>/<em>$thread</em></strong> showed that the spinning threads were all running garbage collection.  Luckily verbose GC logging was turned on so we were able to look at the log to see how long the previous full GC cycles lasted:</p>
<p>20493.297: [Full GC [PSYoungGen: 2040K-&gt;0K(240064K)] [ParOldGen: 697548K-&gt;397070K(1077248K)] 699589K-&gt;397070K(1317312K) [PSPermGen: 243883K-&gt;243054K(262144K)], <strong>9.3868202 secs</strong>]<br />
23490.529: [Full GC [PSYoungGen: 6063K-&gt;0K(663616K)] [ParOldGen: 1004912K-&gt;588931K(1400832K)] 1010975K-&gt;588931K(2064448K) [PSPermGen: 247384K-&gt;245927K(262144K)],<strong> 613.1687549 secs</strong>]<br />
25069.416: [Full GC [PSYoungGen: 660290K-&gt;0K(664704K)] [ParOldGen: 961941K-&gt;1287172K(1400832K)] 1622231K-&gt;1287172K(2065536K) [PSPermGen: 246538K-&gt;246128K(262144K)], <strong>14492.5636839 secs</strong>]</p>
<p>14492 seconds =  just over <strong>4 hours</strong>! Yikes!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamhathaway.com/wordpress/2008/08/28/java-garbage-collection-gone-horribly-wrong/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DTrace</title>
		<link>http://www.williamhathaway.com/wordpress/2008/02/12/dtrace/</link>
		<comments>http://www.williamhathaway.com/wordpress/2008/02/12/dtrace/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 03:51:34 +0000</pubDate>
		<dc:creator>William Hathaway</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[solaris]]></category>
		<category><![CDATA[technology]]></category>

		<guid isPermaLink="false">http://williamhathaway.com/?p=126</guid>
		<description><![CDATA[I attended a Sun presentation on DTrace today. Here are links to some good resources: OpenSolaris DTrace Community Solaris Internals DTrace Topics DTrace Toolkit Solaris Internals DTrace with Java OpenSolaris DTrace Discussion Forum Some anecdotes that were mentioned: Buffer sizes When DTrace was fired up on some monster sized boxes (like a 144 core E25k), [...]]]></description>
			<content:encoded><![CDATA[<p>I attended a Sun <a href="http://mediacast.sun.com/users/%7Ejdf/media/columbia-dtrace-event.zip/details">presentation</a> on <a href="http://en.wikipedia.org/wiki/DTrace">DTrace </a>today.  Here are links to some good resources:</p>
<ul>
<li>OpenSolaris <a href="http://www.opensolaris.org/os/community/dtrace/">DTrace Community</a></li>
<li>Solaris Internals <a href="http://www.solarisinternals.com/wiki/index.php/DTrace_Topics" rel="nofollow">DTrace Topics</a></li>
<li><a href="http://www.opensolaris.org/os/community/dtrace/dtracetoolkit/" rel="nofollow">DTrace Toolkit</a></li>
<li>Solaris Internals <a href="http://www.solarisinternals.com/wiki/index.php/DTrace_Topics_Java" rel="nofollow">DTrace with Java</a></li>
<li>OpenSolaris <a href="http://www.opensolaris.org/jive/forum.jspa?forumID=7">DTrace </a><a href="http://www.opensolaris.org/jive/forum.jspa?forumID=7" rel="nofollow">Discussion Forum</a></li>
</ul>
<p>Some anecdotes that were mentioned:</p>
<p><strong>Buffer sizes </strong></p>
<p>When DTrace was fired up on some monster sized boxes (like a 144 core <a href="http://www.sun.com/servers/highend/sunfire_e25k/index.xml">E25k</a>), it took a while for DTrace to kick in.  The issue turned out to be that, by default, DTrace allocates 4MB of memory for each core.  On a 144 core machine, this means you need to get ~ 600MB allocated  The presenter said he decided to lower the buffer size to 256k or so per CPU and that made DTrace start up much faster.</p>
<p><strong>DTrace aborts on Opteron machines<br />
</strong></p>
<p>If you are using dual-core Sun x4100 M2 or X4200 M2 servers and Solaris 10u3 or earlier, you will almost definitely get errors when trying to run DTrace where it aborts almost instantly.  You are  hitting:</p>
<p><a href="http://bugs.opensolaris.org/view_bug.do?bug_id=6507659">bug id 6507659 <font>tsc differences between CPU&#8217;s give dtrace_gethrtime() serious problems</font> </a></p>
<p>The workaround (-w option) is mentioned in the ticket, but that also disables DTrace safety features, so use caution.  If you are on Solaris 10u4 (aka 2008/07) or patched to 120012-14, you should be fine and won&#8217;t need the workaround.</p>
<p><strong>Which probes are safe for production?</strong></p>
<p>Probe effect is almost entirely a function of how often they get called.  The presenter mentioned that using the syscall, io, and profile providers are almost always fine in production.  He did mention that he would not recommend using the pid provider in most cases on a busy process in production, although the the only affect will be slowing the specific traced process down.</p>
<p><strong>DTrace Toolkit</strong></p>
<p>I really wanted to emphasize how good I think this collection of scripts/examples are.  I consider it to be almost like the <a href="http://www.setoolkit.com/">SE Toolkit </a>of the DTrace world.  Even if you have no desire to wade through the DTrace docs, or don&#8217;t consider yourself much of a scripter, take a look at the <a href="http://opensolaris.org/os/community/dtrace/dtracetoolkit/">DTrace Toolkit</a> and try running some of the examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamhathaway.com/wordpress/2008/02/12/dtrace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java developers &#8211; stack traces aren&#8217;t helpful to end users</title>
		<link>http://www.williamhathaway.com/wordpress/2007/03/27/java-developers-stack-traces-arent-helpful-to-end-users/</link>
		<comments>http://www.williamhathaway.com/wordpress/2007/03/27/java-developers-stack-traces-arent-helpful-to-end-users/#comments</comments>
		<pubDate>Tue, 27 Mar 2007 12:35:56 +0000</pubDate>
		<dc:creator>William Hathaway</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://williamhathaway.com/?p=14</guid>
		<description><![CDATA[I just tried registering a Solaris 10 11/06 machine using sconadm and here is the resulting output: /usr/sbin/sconadm register -a -r /tmp/regprofile sconadm is running javax.management.remote.JMXProviderException: Connection refused at com.sun.cacao.rmi.impl.CacaoRMIConnectorProvider.newJMXConnector(Caca oRMIConnectorProvider.java:415) at javax.management.remote.JMXConnectorFactory.getConnectorAsService(JMX ConnectorFactory.java:415) at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnec torFactory.java:307) at com.sun.scn.client.MSCConnection.doMscConnect(MSCConnection.java:155) at com.sun.scn.client.MSCConnection.mscConnectWithKeystorePassword(MSCCo nnection.java:67) (about 30 lines snipped out by me) at com.sun.cns.basicreg.BasicReg.&#60;init&#62;(BasicReg.java:100) at com.sun.cns.basicreg.BasicRegCLI.main(BasicRegCLI.java:523) How about [...]]]></description>
			<content:encoded><![CDATA[<p>I just tried registering a Solaris 10 11/06 machine using sconadm and here is the resulting output:</p>
<p><strong>/usr/sbin/sconadm register -a -r /tmp/regprofil</strong>e<br />
sconadm is running<br />
javax.management.remote.JMXProviderException: Connection refused<br />
at com.sun.cacao.rmi.impl.CacaoRMIConnectorProvider.newJMXConnector(Caca                         oRMIConnectorProvider.java:415)<br />
at javax.management.remote.JMXConnectorFactory.getConnectorAsService(JMX                         ConnectorFactory.java:415)<br />
at javax.management.remote.JMXConnectorFactory.newJMXConnector(JMXConnec                         torFactory.java:307)<br />
at com.sun.scn.client.MSCConnection.doMscConnect(MSCConnection.java:155)<br />
at com.sun.scn.client.MSCConnection.mscConnectWithKeystorePassword(MSCCo                         nnection.java:67)</p>
<p>(about 30 lines snipped out by me)</p>
<p>at com.sun.cns.basicreg.BasicReg.&lt;init&gt;(BasicReg.java:100)<br />
at com.sun.cns.basicreg.BasicRegCLI.main(BasicRegCLI.java:523)</p>
<p>How about something more helpful like:</p>
<p><strong>ERROR 68: Can&#8217;t connect to the fuzzbat service on server server99.</strong></p>
<p><strong>Please check that the fuzzbat service is enabled with &#8216;svcadm enable fuzzbat; svcs fuzzbat&#8217;.</strong></p>
<p>While stack traces are helpful to developers, they can largely obfuscate the problem to the end-user and certainly don&#8217;t provide guidance on what the likely problem is and what the next step should be.   If you want to print stack traces, at least try to provide some actionable information to the end user.</p>
<p>(My error was apparently generated because I had renamed the machine, but hadn&#8217;t bounced some services. After I rebooted, the sconadm command worked fine.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.williamhathaway.com/wordpress/2007/03/27/java-developers-stack-traces-arent-helpful-to-end-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

