<?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>ClickOnChris &#187; Databases</title>
	<atom:link href="http://www.clickonchris.com/category/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clickonchris.com</link>
	<description>Christopher G Johnson: programmer, entrepreneur, gamer</description>
	<lastBuildDate>Sat, 21 Jan 2012 23:31:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Performance Optimization: Doing Science</title>
		<link>http://www.clickonchris.com/2011/06/performance-optimization-doing-science/</link>
		<comments>http://www.clickonchris.com/2011/06/performance-optimization-doing-science/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 03:37:51 +0000</pubDate>
		<dc:creator>clickonchris</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[science]]></category>

		<guid isPermaLink="false">http://www.clickonchris.com/?p=320</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I couldn&#8217;t hold a candle to Brian Green on such topics as Quantum Entaglement, Higgs Boson, or Grand Unified Theory (despite obtaining a <a title="Augustana Graduation" href="http://physics.augustana.edu/alumni/2004/commencement-photo.html" target="_blank">B.A. in Physics</a>), however I <em>can</em> apply the scientific method to improving the performance of your software.</p>
<div id="attachment_337" class="wp-caption alignright" style="width: 372px"><a href="http://www.sciencebuddies.org/science-fair-projects/project_scientific_method.shtml" target="_blank"><img class="size-full wp-image-337" title="Scientific Method" src="http://www.clickonchris.com/wp-content/uploads/2011/06/overview_scientific_method2.gif" alt="" width="362" height="348" /></a><p class="wp-caption-text">The Scientific Method (sciencebuddies.org)</p></div>
<p>In this article I will explain a basic, but often overlooked foundation for improving the performance of any software application.</p>
<p>Much of software development is an art, but performance tuning is a science.  I&#8217;ve seen a lot of good developers waste time significant amounts of time on performance with little to show for it, or just as bad, improve performance without knowing exactly which change had the desired effect.</p>
<p>Do you remember talking about the Scientific Method from your high school science class?  The diagram on the right is a refresher.  The scientific method is the repeatable process on which all scientific exploration is based.  It gives scientists across the world a common language and framework to compare the process and outcomes of experiments.</p>
<p>The scientific process provides a few of important points that can be applied to software performance optimization:</p>
<ol>
<li>Repeatable process &#8211; use the same process for every performance enhancement you make</li>
<li>Only modify one variable at a time &#8211; Do not make multiple tweaks at the same time.</li>
<li>Record the results of each optimization.  Track what you did and how much it helped.</li>
</ol>
<div id="attachment_343" class="wp-caption alignright" style="width: 290px"><a href="http://www.clickonchris.com/wp-content/uploads/2011/06/performanceOptimization2.gif"><img class="size-full wp-image-343 " title="performance Optimization" src="http://www.clickonchris.com/wp-content/uploads/2011/06/performanceOptimization2.gif" alt="" width="280" height="495" /></a><p class="wp-caption-text">Performance Optimization Method (clickonchris.com)</p></div>
<p>This sounds simple right?  It is.  The tough part for software developers is to never break these rules during a round of optimizations.  To the right I&#8217;ve also included a more detailed diagram of what the scientific process looks like when applied to performance optimization.  Let&#8217;s call it the Performance Optimization Method.</p>
<p><em>But I know what I&#8217;m doing!  Why shouldn&#8217;t I make multiple tweaks at once?</em></p>
<p>Lets say you do make two changes at once.  You optimize two queries and drop the page load time from 3s to .1s.  Do you know how much relative impact the changes had?  Did each change reduce the cost by the same amount (50%/50%)?  Did one query account for most of the cost (75%/25%)?  Or did one of the changes not even have any impact (100%/0%)?  What if the two changes were somehow interdependent?  For the most part these questions are impossible to answer unless you use a repeatable process and only modify one variable at a time.  There are exceptions *(there are always exceptions.  If you have a good profiling tool that tells you exactly what two different method calls cost and you are absolutely sure they are not somehow related then you could cut a corner and make multiple changes at once.  If the results do not turn out as expected you still need to go back and make the changes one at a time).  By the way, I hope you are testing against a volume of data you expect in production.</p>
<p>Don&#8217;t forget to record the result of each optimization.  This way you can <a href="http://www.clickonchris.com/2011/06/tuning-reducing-jboss-memory-footprint/" target="_blank">throw your results into a table</a>, and with a little explanation about the process and results you turn it into a report and send it to management so they can see how you&#8217;re spending their budget (and how good you are at science).  Having these sorts of metrics reports also makes it easy for stakeholders to justify the time spent on performance optimization activities.</p>
<p>The <a href="http://en.wikipedia.org/wiki/Diminishing_returns" target="_blank">law of diminishing returns</a> applies to performance enhancements.  At some point you will have picked all of the low-hanging fruit and enhancements start to get progressively more expensive.  Stakeholders need insight into how this is progressing on your project so they can make decisions on how much more to spend on performance.  Metrics reports should provide sufficient detail for stakeholders to make those decisions.</p>
<p>Ultimately you will end up with a faster application and a clear story of how you got there.  Isn&#8217;t science fun?</p>
<g:plusone href="http://www.clickonchris.com/2011/06/performance-optimization-doing-science/"></g:plusone><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/share?url=http://www.clickonchris.com/2011/06/performance-optimization-doing-science/&text=Performance+Optimization%3A+Doing+Science&via=clickonchris&related=richardxthripp%2Ctweetthisplugin" title="Post to Twitter"><img class="nothumb" src="http://www.clickonchris.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a></p></div><div align="left" style="vertical-align:top;display:inline-block; padding:2px 10px 10px 35px;"><a name="fb_share" type="button" share_url="http://www.clickonchris.com/2011/06/performance-optimization-doing-science/"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.clickonchris.com/2011/06/performance-optimization-doing-science/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring Jetty, Maven, and Eclipse together with Hot Swap</title>
		<link>http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/</link>
		<comments>http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/#comments</comments>
		<pubDate>Fri, 28 May 2010 05:06:43 +0000</pubDate>
		<dc:creator>clickonchris</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Hot Swap]]></category>

		<guid isPermaLink="false">http://www.clickonchris.com/?p=186</guid>
		<description><![CDATA[This tutorial will show you how to setup Jetty in embedded mode, and using Eclipse, attach a debugger to enable True Hot Deployment of code onto your Jetty server.]]></description>
			<content:encoded><![CDATA[<p>For over a year I&#8217;ve been developing a Java webapp in Hibernate with maven and Jetty.  Recently I&#8217;ve figure out how to make them all play nice with each other.  For too long I had to restart my application server, which takes upwards of 45 seconds, for any code changes to make it to my development server.  This tutorial will show you how to setup Jetty in embedded mode, and using Eclipse, attach a debugger to enable <strong>True Hot Swap </strong>of code onto your Jetty server.</p>
<p><strong>Environment Information:</strong></p>
<p>JDK 1.5+<br />
Eclipse 3.4.0<br />
maven 2.0.10<br />
m2eclipse 0.9.7 (maven plugin for eclipse)<br />
Jetty 6.1.10<br />
Spring<br />
JPA,Hibernate</p>
<p><span id="more-186"></span></p>
<p><strong>Maven Jetty Configuration:</strong></p>
<p>In your maven project’s pomx.xml, in your &lt;build&gt; section, add the jetty plugin.  An example can be found at the Jetty website here:</p>
<p><a href="http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin#MavenJettyPlugin-WebappConfiguration">http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin#MavenJettyPlugin-WebappConfiguration</a></p>
<p>It is very important to keep &lt;scanIntervalSeconds&gt; set to zero.  This setting tells Jetty how often (in seconds) to scan the webapp for changes and if changes are found, it re-cycles the web container.  You don’t want to do this and setting it to zero will disable it.</p>
<p><strong>Configuring Jetty to start within Eclipse:</strong></p>
<p>Next, create an easy way to launch your jetty server.  I’m using Jetty through Maven and Eclipse.  Here is how I setup an Eclipse External Tool to launch my Jetty server:</p>
<p style="text-align: center;"><a href="http://www.clickonchris.com/wp-content/uploads/2010/05/jettyserver.png"><img class="aligncenter size-full wp-image-188" title="Jetty External Tool Config" src="http://www.clickonchris.com/wp-content/uploads/2010/05/jettyserver.png" alt="" width="666" height="502" /></a></p>
<p>To make sure it is listening for a debugger, make sure that a MAVEN_OPTS environment variable is set with the following options:</p>
<p>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n</p>
<p>The address parameter is what port the jetty server will be listening on for the remote debugger.</p>
<p style="text-align: center;"><a href="http://www.clickonchris.com/wp-content/uploads/2010/05/jettyserver.png"><img class="aligncenter size-full wp-image-188" title="Jetty External Tool Config Environment Tab" src="http://www.clickonchris.com/wp-content/uploads/2010/05/jettyserver.png" alt="" width="666" height="502" /></a></p>
<p>Click ‘Run’ and your jetty server should start running in Eclipse’s console window.  It should look something like this (depending on your log4j config):</p>
<p>Listening for transport dt_socket at address: 4000</p>
<p><pre><code>
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: &#039;jetty&#039;.
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject
[INFO]    task-segment: [jetty:run]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing jetty:run
2010-05-27 15:39:25.733::INFO:  Started SelectChannelConnector@0.0.0.0:8080
[INFO] Started Jetty Server</code></pre></p>
<p><strong>Attaching the Debugger:</strong></p>
<p><strong> </strong>Next, setup a debugger.  In Eclipse open ‘Debug Configurations’, and create a new ‘Remote Java Debugger’.   Select your eclipse project, set the host to localhost, and set the port to 4000, or whatever you defined earlier.</p>
<p><a href="http://www.clickonchris.com/wp-content/uploads/2010/05/debugger.png"><img class="aligncenter size-full wp-image-190" title="Debug Configuration" src="http://www.clickonchris.com/wp-content/uploads/2010/05/debugger.png" alt="" width="587" height="595" /></a></p>
<p>Press the Debug Button and the remote debugger should attach to your jetty server.</p>
<p>Finally, make sure Build Automatically is enabled in eclipse (Project-&gt;Build Automatically).</p>
<p>At this point your environment is enabled for debugging code on your Jetty server through Eclipse.  Breakpoints, watch variables, you name it.</p>
<p>Hot deploy is also enabled.  If you modify some java code, the automatic builder should compile the .java file to a .class file.  The remote debugger will see it and use it, all without restarting your jetty server or its web container.  This will not work for things like adding static variables, new domain classes,  or new injectable service methods that require the application to acknowledge  them on startup.</p>
<g:plusone href="http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/"></g:plusone><div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/share?url=http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/&text=Configuring+Jetty%2C+Maven%2C+and+Eclipse+together+with+Hot+Swap&via=clickonchris&related=richardxthripp%2Ctweetthisplugin" title="Post to Twitter"><img class="nothumb" src="http://www.clickonchris.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter6.png" alt="Post to Twitter" /></a></p></div><div align="left" style="vertical-align:top;display:inline-block; padding:2px 10px 10px 35px;"><a name="fb_share" type="button" share_url="http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

