<?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>Stochastic Geometry &#187; dotMobi</title>
	<atom:link href="http://www.stochasticgeometry.ie/tag/dotmobi/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stochasticgeometry.ie</link>
	<description>Articles on random topics in Programming, Systems Administration, Academia and Industry by Mark Dennehy</description>
	<lastBuildDate>Fri, 27 Jan 2012 17:38:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Cache conscious hash tables</title>
		<link>http://www.stochasticgeometry.ie/2008/03/29/cache-concious-hash-tables/</link>
		<comments>http://www.stochasticgeometry.ie/2008/03/29/cache-concious-hash-tables/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 20:00:39 +0000</pubDate>
		<dc:creator>Mark Dennehy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Cache Concious]]></category>
		<category><![CDATA[DeviceAtlas]]></category>
		<category><![CDATA[dotMobi]]></category>
		<category><![CDATA[HashMap]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://stochasticgeometry.wordpress.com/?p=36</guid>
		<description><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>So one of the things I was working on as part of <a href="http://www.deviceatlas.com" target="_blank">DeviceAtlas</a> (but which ultimately didn&#8217;t get used) was a cache-conscious hash table in Java. It&#8217;s not unique in design &#8211; in fact it comes right out of a research paper written for the SPIRE 2005 conference by Nikolas Askitis and Justin Zobel &#8211; but the implementation was interesting to me as I&#8217;d not done optimisation work in Java in a while, and some things had changed quite a bit since I last wrote Java code. And it was a bit of an ego boost that I got it to outperform java.util.HashMap:</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">SUN HashMap fill: 57797 us<br />
SUN HashMap query: 165701 us, 0 errors<br />
CCHashTable fill (fair): 23205 us<br />
CCHashTable query (fair): 35513 us, 0 errors<br />
CCHashTable fill: 41723 us<br />
CCHashTable query: 43055 us, 0 errors</div></div>
<p>Of course, there are the minor criticisms that it&#8217;s nowhere near as general-purpose as the HashMap class and that HashMap is arguably exhibiting an intelligent design choice rather than <em>cheating</em> per se, but I like my ego so I&#8217;m going to ignore those arguments!</p>
<p><span id="more-36"></span></p>
<p>Looking at the more interesting bits, there&#8217;s the hash function. This came from more work by Zobel, this time with Ramakrishna for a database conference in Melbourne in 1997, and it&#8217;s a fairly simple design:  for each character in the input string, left shift the interim hashcode, add the character, then right shift the interim hashcode and add that to the mix, then xor the whole lot with the interim hashcode and that&#8217;s your interim hashcode for the next iteration. Which, as a description intended to convey simplicity, probably fails. Oh well, the code is clearer:</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
* getHashCode() differs from the standard Java hashcode algorithm.<br />
* It's an shift-add-xor class algorithm, as tested in &#60;em&#62;&#34;Performance<br />
* in Practise </span></div>&#8230; <a href="http://www.stochasticgeometry.ie/2008/03/29/cache-concious-hash-tables/" class="read_more">Read the rest</a></div>]]></description>
		<wfw:commentRss>http://www.stochasticgeometry.ie/2008/03/29/cache-concious-hash-tables/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

