





<?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"
	>

<channel>
	<title>Ajax Performance &#187; java</title>
	<atom:link href="http://www.ajaxperformance.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ajaxperformance.com</link>
	<description>A blog by Ryan Breen of Gomez</description>
	<pubDate>Wed, 25 Jun 2008 04:54:54 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>GWT 1.4 provides easy, native support of image concatenation with special sauce</title>
		<link>http://www.ajaxperformance.com/2007/06/02/gwt-14-provides-easy-native-support-of-image-concatenation-with-special-sauce/</link>
		<comments>http://www.ajaxperformance.com/2007/06/02/gwt-14-provides-easy-native-support-of-image-concatenation-with-special-sauce/#comments</comments>
		<pubDate>Sat, 02 Jun 2007 05:50:33 +0000</pubDate>
		<dc:creator>Ryan Breen</dc:creator>
		
		<category><![CDATA[ajax]]></category>

		<category><![CDATA[http]]></category>

		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.ajaxperformance.com/2007/06/02/gwt-14-provides-easy-native-support-of-image-concatenation-with-special-sauce/</guid>
		<description><![CDATA[The RC for GWT 1.4 provides native support for image concatenation in a feature called ImageBundle.  If you&#8217;ll recall, I discussed image concatenation in a round up last month, and it&#8217;s a key embodiment of our &#8220;First Principal of Performance Optimization&#8221; &#8212; reduce network requests as much as possible.
Given that this is Google, they [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://googlewebtoolkit.blogspot.com/2007/05/google-web-toolkit-14-release-candidate.html">RC for GWT 1.4</a> provides native support for image concatenation in a feature called <a href="http://code.google.com/p/google-web-toolkit/wiki/ImageBundleDesign">ImageBundle</a>.  If you&#8217;ll recall, I discussed image concatenation in a <a href="http://www.ajaxperformance.com/2007/05/09/another-technique-for-minimizing-requests-image-concatenation/">round up last month</a>, and it&#8217;s a key embodiment of our &#8220;First Principal of Performance Optimization&#8221; &#8212; reduce network requests as much as possible.</p>
<p>Given that this is Google, they had to take things to that next level.  And by that, I of course mean that their implementation has a few twists and refinements so brilliant and elegant that they seem obvious in retrospect and make the rest of us feel unworthy.  Because we are.</p>
<p>The aspect of ImageBundle that jumps out at me is the infinite cacheability of the images: the file name includes an MD5 of the image contents, so there is no need for even periodic HTTP round trips for if-modified-since or if-none-match checks.  You can set the expiration date to the expected heat death of the universe, or beyond.  Thus, network requests are only made when they are absolutely necessary.  Only one network round trip is made at that time.  Everything is as simple as possible, but not one bit simpler.</p>
<p>And to those naysayers who may suggest a pathological case where minor modifications to one or two contained images cause frequent downloads of the larger, concatenated image: it just doesn&#8217;t matter.  As <a href="http://www.edgeblog.net/2007/its-still-the-latency-stupid/">this post at edgeblog</a> explores, it&#8217;s still the latency, stupid.  The real cost of object downloads is the round tripping.  Establishing a connection, sending a request, and waiting for the first byte dominate network times.  The added marginal cost of additional contents is always a fraction of those setup costs as the bytes of the reply are in flight by the time you begin receiving the reply.  And as bandwidth increases while latency remains relatively flat, the dominance of latency will only increase.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxperformance.com/2007/06/02/gwt-14-provides-easy-native-support-of-image-concatenation-with-special-sauce/feed/</wfw:commentRss>
		</item>
		<item>
		<title>java.net.URL considered annoying</title>
		<link>http://www.ajaxperformance.com/2006/10/07/javaneturl-considered-annoying/</link>
		<comments>http://www.ajaxperformance.com/2006/10/07/javaneturl-considered-annoying/#comments</comments>
		<pubDate>Sat, 07 Oct 2006 18:34:15 +0000</pubDate>
		<dc:creator>Ryan Breen</dc:creator>
		
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.ajaxperformance.com/?p=5</guid>
		<description><![CDATA[The implementation of hashCode in java.net.URL has a quirk that tends to introduce subtle bugs into Java networking apps.  Haven&#8217;t seen much discussion about this in the wild.
As implemented, hashCode uses the IP address of the URL hostname as part of its calculations.  This leads to at least three annoying issues:

Calling equals on [...]]]></description>
			<content:encoded><![CDATA[<p>The implementation of hashCode in java.net.URL has a quirk that tends to introduce subtle bugs into Java networking apps.  Haven&#8217;t seen much discussion about this in the wild.</p>
<p>As implemented, hashCode uses the IP address of the URL hostname as part of its calculations.  This leads to at least three annoying issues:</p>
<ol>
<li>Calling equals on a URL or using it as a key to a Map is a blocking operation on a network call.  It&#8217;s unlikely this is what you intended, but it&#8217;s easy enough to overlook until (e.g.) your primary name server dies and you wonder why all hash lookups are now taking 5 seconds.  This is how I stumbled onto the issue years ago.</li>
<li>Calling equals on two URLs with identical paths and different hostnames will return true in the case that both hostnames map to the same IP.  It can certainly be argued that this is intended behavior since the URLs point to the same network resource, but I&#8217;m guessing that most developers who call myURL.equals(yourURL) are expecting to get a string comparison, ala myURL.toString().equals(yourURL.toString())</li>
<li>Using a URL as a key into a Map may lead to a miss in a DNS round robin scenario where the same hostname maps to multiple IPs.  This is, I think, the most insidious case as most URLs will hash properly until one day you discover multiple entries in a Map keyed to string-identical URLs.</li>
</ol>
<p>My advice? Simple enough. Just use strings.  When working on projects involving URLs, a useful internal convention is to use all capitals to designate a method that will return a URL and lower case for a method that will return a String representation of the URL, perhaps suffixing with String just to be absolutely clear.  Example:</p>
<p><code></p>
<pre>
public interface HttpRequest {
   public URL getURL();
   public String getUrlString();
}
</pre>
<p></code><br />
Also, generic collections make spotting abuse of this convention much easier in the Map cases.  Code that does HashMap&lt;URL, HttpRequest&gt; has a very distinct odor and is much easier to sniff out at the source.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ajaxperformance.com/2006/10/07/javaneturl-considered-annoying/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>


<!-- Dynamic Page Served (once) in 0.261 seconds -->
