<?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>My Workday &#187; Admin</title>
	<atom:link href="http://www.goworkday.com/author/Admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.goworkday.com</link>
	<description>Let&#039;s talk TECH</description>
	<lastBuildDate>Tue, 23 Mar 2010 03:28:59 +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>Single-word Wang/Jenkins Hash in ConcurrentHashMap</title>
		<link>http://www.goworkday.com/2010/03/19/single-word-wangjenkins-hash-concurrenthashmap/</link>
		<comments>http://www.goworkday.com/2010/03/19/single-word-wangjenkins-hash-concurrenthashmap/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 00:23:16 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Bitwise Operation]]></category>
		<category><![CDATA[hash]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=244</guid>
		<description><![CDATA[<br/>ConcurrentHashMap is hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. I recently came across this code during testing, and one part really got my attention. To generate the hash, ConcurrentHashMap uses an algorithm based on bitshifting and bitwise operations. ?View Code JAVA1 2 3 4 5 6 7 8 9 [...]]]></description>
			<content:encoded><![CDATA[<br/><p>ConcurrentHashMap is hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. I recently came across this code during testing, and one part really got my attention. To generate the hash, ConcurrentHashMap uses an algorithm based on bitshifting and bitwise operations.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code6'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2446"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p244code6"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">========================================</span>
Variant of single<span style="color: #339933;">-</span>word Wang<span style="color: #339933;">/</span>Jenkins hash
<span style="color: #339933;">========================================</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> hash<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> h<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Spread bits to regularize both segment and index locations,</span>
<span style="color: #666666; font-style: italic;">// using variant of single-word Wang/Jenkins hash.</span>
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span>  <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">^</span> 0xffffcd7d<span style="color: #339933;">;</span>
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span>   <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span>  <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span>   <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">14</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">return</span> h <span style="color: #339933;">^</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>According to the comment in the code, this method applies a supplemental hash function to a given hashCode, which defends against poor quality hash functions.  </p>
<p>Good hash functions are important as a hash table effectively turns from a map to a linked list, in the worst case, all keys in the same bucket. There are also other considerations that come into play such as the performance of hash calculation and the number of buckets. Dr. Heinz M. Kabutz explains the power of <a href="http://www.javaspecialists.co.za/archive/Issue054.html">&#8220;power-of-two number of buckets&#8221;</a> which gives us some good starting point to understand what is really going on here. </p>
<p>Let&#8217;s look at the code above and see how things change, line-by-line. To make things simple,  I use <strong>int 1</strong> to perform all the operations. </p>
<p>In Java, the <strong> int</strong> data type is a 32-bit signed two&#8217;s complement integer. To represent int 1 in binary code, we have the following:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code7'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2447"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p244code7"><pre class="java" style="font-family:monospace;">h<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&gt;</span> 0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0001</pre></td></tr></table></div>

<p>Now, let&#8217;s dissect the following line:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code8'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2448"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p244code8"><pre class="java" style="font-family:monospace;">h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">^</span> 0xffffcd7d</pre></td></tr></table></div>

<p>First, let&#8217;s re-write this into an easier-to-read format.. at least for me <img src='http://www.goworkday.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' title=" Single word Wang/Jenkins Hash in ConcurrentHashMap" /> .</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code9'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2449"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p244code9"><pre class="java" style="font-family:monospace;">h1 <span style="color: #339933;">=</span> h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">15</span>      <span style="color: #339933;">=</span>  0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span><span style="color: #cc66cc;">1000</span><span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000
hex <span style="color: #339933;">=</span> 0xffffcd7d  <span style="color: #339933;">=</span>  <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1100</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0111<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span>
h2 <span style="color: #339933;">=</span> h1 <span style="color: #339933;">^</span> hex     <span style="color: #339933;">=</span>  <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0111<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span>
h2 <span style="color: #339933;">+</span> h            <span style="color: #339933;">=</span>  <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0111<span style="color: #339933;">-</span><span style="color: #cc66cc;">1110</span></pre></td></tr></table></div>

<p>Using the same thought processing and applying it to each line, we end-up with:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code10'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24410"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p244code10"><pre class="java" style="font-family:monospace;">h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">^</span> 0xffffcd7d <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0111<span style="color: #339933;">-</span><span style="color: #cc66cc;">1110</span>
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>	            <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1100</span><span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span><span style="color: #cc66cc;">1011</span><span style="color: #339933;">-</span>0010<span style="color: #339933;">-</span><span style="color: #cc66cc;">1010</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span>
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span>		    <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1100</span><span style="color: #339933;">-</span>0110<span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1000</span><span style="color: #339933;">-</span>0001<span style="color: #339933;">-</span>0101
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span>              <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1110</span><span style="color: #339933;">-</span>0011<span style="color: #339933;">-</span>0001<span style="color: #339933;">-</span>0101<span style="color: #339933;">-</span>0001<span style="color: #339933;">-</span>0011<span style="color: #339933;">-</span>0101
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">14</span><span style="color: #009900;">&#41;</span>   <span style="color: #339933;">=</span> 0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1011</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span>0011<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0110<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span><span style="color: #cc66cc;">1001</span>
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span>             <span style="color: #339933;">=</span> 0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1011</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span>0011<span style="color: #339933;">-</span><span style="color: #cc66cc;">1001</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1010</span></pre></td></tr></table></div>

<p>Result:<br />
Bin          = 0100-1011-0100-0011-1001-1101-0100-1010<br />
Decimal = 1,262,722,378</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/03/19/single-word-wangjenkins-hash-concurrenthashmap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: Bin/Dec/Hex Conversion and Primitive Data Types</title>
		<link>http://www.goworkday.com/2010/03/19/java-primitive-data-types/</link>
		<comments>http://www.goworkday.com/2010/03/19/java-primitive-data-types/#comments</comments>
		<pubDate>Fri, 19 Mar 2010 15:59:32 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=236</guid>
		<description><![CDATA[<br/>﻿Conversion Table HEX DECIMAL BINARY 0 0 = 0+0+0+0 0000 1 1 = 0+0+0+1 0001 2 2 = 0+0+2+0 0010 3 3 = 0+0+2+1 0011 4 4 = 0+2+0+0&#160; 0100 5 5 = 0+4+0+1 0101 6 6 = 0+4+2+0 0110 7 7 = 0+4+2+1 0111 8 8 = 8+0+0+0 1000 9 9 = 8+0+0+1 1001 [...]]]></description>
			<content:encoded><![CDATA[<br/><p style="text-align: center;">﻿<span style="color: #990000;"><strong>Conversion Table</strong></span></p>
<table border="1" cellpadding="2" cellspacing="0" bordercolor="#000000" width="483">
<tr>
<td bgcolor="#CCCCCC" width="6"><b>HEX</b></td>
<td bgcolor="#CCCCCC" width="121"><b>DECIMAL</b></td>
<td bgcolor="#CCCCCC" width="197"><b>BINARY</b></td>
</tr>
<tr>
<td width="6">0</td>
<td width="121">0 = 0+0+0+0</td>
<td width="197">0000</td>
</tr>
<tr>
<td width="6">1</td>
<td width="121">1 = 0+0+0+1</td>
<td width="197">0001</td>
</tr>
<tr>
<td width="6">2</td>
<td width="121">2 = 0+0+2+0</td>
<td width="197">0010</td>
</tr>
<tr>
<td width="6">3</td>
<td width="121">3 = 0+0+2+1</td>
<td width="197">0011</td>
</tr>
<tr>
<td width="6">4</td>
<td width="121">4 = 0+2+0+0&nbsp;</td>
<td width="197">0100</td>
</tr>
<tr>
<td width="6">5</td>
<td width="121">5 = 0+4+0+1</td>
<td width="197">0101</td>
</tr>
<tr>
<td width="6">6</td>
<td width="121">6 = 0+4+2+0</td>
<td width="197">0110</td>
</tr>
<tr>
<td width="6">7</td>
<td width="121">7 = 0+4+2+1</td>
<td width="197">0111</td>
</tr>
<tr>
<td width="6">8</td>
<td width="121">8 = 8+0+0+0</td>
<td width="197">1000</td>
</tr>
<tr>
<td width="6">9</td>
<td width="121">9 = 8+0+0+1</td>
<td width="197">1001</td>
</tr>
<tr>
<td width="6">A</td>
<td width="121">10 = 8+0+2+0</td>
<td width="197">1010</td>
</tr>
<tr>
<td width="6">B</td>
<td width="121">11 = 8+0+0+1</td>
<td width="197">1011</td>
</tr>
<tr>
<td width="6">C</td>
<td width="121">12 = 8+4+0+0</td>
<td width="197">1100</td>
</tr>
<tr>
<td width="6">D</td>
<td width="121">13 = 8+4+0+1</td>
<td width="197">1101</td>
</tr>
<tr>
<td width="6">E</td>
<td width="121">14 = 8+4+2+0</td>
<td width="197">1110</td>
</tr>
<tr>
<td width="6">F</td>
<td width="121">15 = 8+4+2+1&nbsp;</td>
<td width="197">1111</td>
</tr>
</table>
<p style="text-align: center;">﻿<span style="color: #990000;"><strong>Data Types and Data Structures</strong></span></p>
<table cellspacing="1" bgcolor="#c0c0c0">
<tbody>
<tr>
<td style="text-align: center;"><span style="color: #000099;"><strong>Primitive Type</strong></span></td>
<td><span style="color: #000099;"><strong>Size</strong></span></td>
<td><span style="color: #000099;"><strong>Minimum Value</strong></span></td>
<td><span style="color: #000099;"><strong>Maximum Value</strong></span></td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>char</strong></td>
<td>16-bit</td>
<td>Unicode 0</td>
<td>Unicode 2<sup>16</sup>-1</td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>byte</strong></td>
<td>8-bit</td>
<td>-128</td>
<td>+127</td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>short</strong></td>
<td>16-bit</td>
<td>-2<sup>15</sup><br />
<em>(-32,768)</em></td>
<td>+2<sup>15</sup>-1<br />
<em>(32,767)</em></td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>int</strong></td>
<td>32-bit</td>
<td>-2<sup>31</sup><br />
<em>(-2,147,483,648)</em></td>
<td>+2<sup>31</sup>-1<br />
<em>(2,147,483,647)</em></td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>long</strong></td>
<td>64-bit</td>
<td>-2<sup>63</sup><br />
<em>(-9,223,372,036,854,775,808)</em></td>
<td>+2<sup>63</sup>-1<br />
<em>(9,223,372,036,854,775,807)</em></td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>float</strong></td>
<td>32-bit</td>
<td colspan="2">32-bit IEEE 754 floating-point numbers</td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>double</strong></td>
<td>64-bit</td>
<td colspan="2">64-bit IEEE 754 floating-point numbers</td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>boolean</strong></td>
<td>1-bit</td>
<td colspan="2"><tt>true</tt> or <tt>false</tt></td>
</tr>
<tr bgcolor="#e0e0e0">
<td><strong>void</strong></td>
<td>&#8212;&#8211;</td>
<td>&#8212;&#8211;</td>
<td>Void</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/03/19/java-primitive-data-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create and Apply Patch in SVN</title>
		<link>http://www.goworkday.com/2010/03/16/create-and-apply-patch-in-svn/</link>
		<comments>http://www.goworkday.com/2010/03/16/create-and-apply-patch-in-svn/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 06:32:08 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=230</guid>
		<description><![CDATA[<br/>Creating a patch file Creating a patch file is really easy. First, check out the most recent version of the code from Subversion using the ‘checkout’ command. Make your changes. Then, in the root the project run the following command. It will store the patch file in your home directory. Make sure to give it meaningful [...]]]></description>
			<content:encoded><![CDATA[<br/><p><strong>Creating a patch file</strong></p>
<p><strong><span style="font-weight: normal;">Creating a patch file is really easy. First, check out the most recent version of the code from Subversion using the ‘checkout’ command.</span></strong></p>
<p>Make your changes. Then, in the root the project run the following command. It will store the patch file in your home directory. Make sure to give it meaningful filename.</p>
<p><em>svn diff &gt; ~/fix_bug.diff</em></p>
<p>The file has the .diff extention, which stands for differences. This extension is recognized by many text editors and enables ’syntax highlighting’ automatically. (Give it a try with TextMate and you’ll know what I mean.) You can send the diff-file to the author of the project by email, or you can create a ticket in Trac and add it as an attachment. The author will review the changes you made and possibly apply them to the source.</p>
<p><strong>Applying a patch</strong></p>
<p>You should never apply patches from any person other than your development team without first reading through the changes, apply them locally and test your application and then commit them. Patches can not only include bug fixes, but also alterations to create back doors or add other exploits to your code.</p>
<p><em>Always read through a patch before applying it!</em></p>
<p>When you are sure the patch will bring no harm to you, your application or your customers, go ahead an apply it to your working copy. Here, I assume that you downloaded the patch file we previously generated, and placed it in your home directory. In the root of your application now run:</p>
<p><em> patch -p0 -i ~/fix_bug.diff</em></p>
<p>This will apply all the changes in the patch to your source. The -p0 option makes sure that all files can be found correctly (this has to do with something called ‘zero directories’, I won’t get into that right now). The -i option tells ‘patch’ what to use as input, in this case the ‘fix_bug.diff’ file in your home directory.<br />
With the code changes in place, run your tests and make sure everything works as expected. If it does, commit your changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/03/16/create-and-apply-patch-in-svn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JProfiler: Getting Started</title>
		<link>http://www.goworkday.com/2010/02/04/jprofiler-getting-started/</link>
		<comments>http://www.goworkday.com/2010/02/04/jprofiler-getting-started/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 07:23:21 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Profiling]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=221</guid>
		<description><![CDATA[<br/>JProfiler helps you find performance bottlenecks, pin down memory leaks and resolve threading issues in your Java application. JProfiler combines CPU, Memory and Thread profiling in one application and is developed by ej-technologies. The latest version at the time of this article is 6.0.]]></description>
			<content:encoded><![CDATA[<br/><p>JProfiler helps you find performance bottlenecks, pin down memory leaks and resolve threading issues in your Java application. JProfiler combines CPU, Memory and Thread profiling in one application and is developed by ej-technologies.  The latest version at the time of this article is 6.0.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/02/04/jprofiler-getting-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL 5.5 and Semisynchronous Replication Available</title>
		<link>http://www.goworkday.com/2009/12/15/mysql-5-5-and-semi-sync-replication-available/</link>
		<comments>http://www.goworkday.com/2009/12/15/mysql-5-5-and-semi-sync-replication-available/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 22:04:37 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=205</guid>
		<description><![CDATA[<br/>The new 5.5 is now available with &#8220;Semisynchronous Replication&#8221;. This comes as an addition to the built-in asynchronous replication. MySQL replication is asynchronous by default. Events written to the binary logs on the Master server being retrieved by the slave server(s). Unfortunately, the Master server has no knowledge of when the slave has retrieved or [...]]]></description>
			<content:encoded><![CDATA[<br/><p>The new 5.5 is now available with &#8220;Semisynchronous Replication&#8221;.  This comes as an addition to the built-in asynchronous replication.   MySQL replication is asynchronous by default. Events written to the binary logs on the Master server being retrieved by the slave server(s). Unfortunately, the Master server has no knowledge of when the slave has retrieved or processed these events.   As a result, when Master crashes, transactions committed on Master, might have not have been committed on the slave server(s). In other words, there is no guarantee that any event will ever reach any slave.</p>
<p>In case of  &#8220;Semisynchronous Replication&#8221;, the Master server blockes the transaction commit until at least one of the slave servers acknowledges the it has received all the events for that transaction.  Obviously, this is great for consistency, however it brings up questions about replication over the WWW which isn&#8217;t an uncommon practice.  In case of hitting the timeout limit (in case of no response from any of the slave servers), the Master server reverts back to asynchronous replication.</p>
<p>From MySQL support:</p>
<blockquote><p>
 To understand what the “semi” in “semisynchronous replication” means, compare it with asynchronous and fully synchronous replication:</p>
<p>    * With asynchronous replication, the master writes events to its binary log and slaves request them when they are ready. There is no guarantee that any event will ever reach any slave.<br />
    * With fully synchronous replication, when a master commits a transaction, all slaves also will have committed the transaction before the master returns to the session that performed the transaction. The drawback of this is that there might be a lot of delay to complete a transaction.<br />
    * Semisynchronous replication falls between asynchronous and fully synchronous replication. The master waits after commit only until at least one slave has received and logged the events. It does not wait for all slaves to acknowledge receipt, and it requires only receipt, not that the events have been fully executed and committed on the slave side.
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2009/12/15/mysql-5-5-and-semi-sync-replication-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Humor: Software Development Cycle</title>
		<link>http://www.goworkday.com/2009/07/28/humor-software-development-cycle/</link>
		<comments>http://www.goworkday.com/2009/07/28/humor-software-development-cycle/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 02:55:41 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Humor]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/2009/07/28/humor-software-development-cycle/</guid>
		<description><![CDATA[<br/>Software doesn&#8217;t just appear on the shelves by magic. That program shrink-wrapped inside the box along with the indecipherable manual and 12-paragraph disclaimer notice actually came to you by way of an elaborate path, through the most rigid quality control on the planet. Here, shared for the first time with the general public, are the [...]]]></description>
			<content:encoded><![CDATA[<br/><p>Software doesn&#8217;t just appear on the shelves by magic. That  program shrink-wrapped inside the box along with the  indecipherable manual and 12-paragraph disclaimer notice  actually came to you by way of an elaborate path, through  the most rigid quality control on the planet.   Here, shared for the first time with the general public, are  the inside details of the program development cycle.</p>
<p>1. Programmer produces code he believes is bug-free.<br />
2. Product is tested. 20 bugs are found.<br />
3. Programmer fixes 10 of the bugs and explains to the testing department that the other 10 aren&#8217;t really bugs.<br />
4. Testing department finds that five of the fixes didn&#8217;t  work and discovers 15 new bugs.<br />
5. See 3.<br />
6. See 4.<br />
7. See 5.<br />
8. See 6.<br />
9. See 7.<br />
10. See 8.<br />
11. Due to marketing pressure and an extremely pre-mature product announcement based on overly-optimistic programming schedule, the product is released.<br />
12. Users find 137 new bugs.<br />
13. Original programmer, having cashed his royalty check, is nowhere to be found.<br />
14. Newly-assembled programming team fixes almost all of the 137 bugs, but introduce 456 new ones.<br />
15. Original programmer sends underpaid testing department a postcard from Fiji. Entire testing department quits.<br />
16. Company is bought in a hostile takeover by competitor using profits from their latest release, which had 783 bugs.<br />
17. New CEO is brought in by board of directors. He hires programmer to redo program from scratch.<br />
18. Programmer produces code he believes is bug-free&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2009/07/28/humor-software-development-cycle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: GC Options</title>
		<link>http://www.goworkday.com/2009/06/24/java-gc-options/</link>
		<comments>http://www.goworkday.com/2009/06/24/java-gc-options/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 21:40:48 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=127</guid>
		<description><![CDATA[<br/>Verbose GC options Option Default value Max Value Description -XX:+PrintGCDetails false PrintGC details -XX:+PrintGCTimeStamps false Adds timestamp info to GC details -XX:+PrintHeapAtGC false Prints detailed GC info including heap occupancy before and after GC -XX:+PrintTenuringDistribution false Prints object aging or tenuring information -XX:+PrintHeapUsageOverTime false Print heap usage and capacity with timestamps -Xloggc:filename false Prints GC [...]]]></description>
			<content:encoded><![CDATA[<br/><p><strong>Verbose GC options</strong></p>
<table border="1" cellspacing="0" cellpadding="2" width="500">
<tbody>
<tr>
<td class="yellowtitle" width="300">Option</td>
<td class="yellowtitle" width="75">Default value</td>
<td class="yellowtitle" width="75">Max Value</td>
<td class="yellowtitle" width="50">Description</td>
</tr>
<tr>
<td><code>-XX:+PrintGCDetails</code></td>
<td>false</td>
<td></td>
<td>PrintGC details</td>
</tr>
<tr>
<td><code>-XX:+PrintGCTimeStamps</code></td>
<td>false</td>
<td></td>
<td>Adds timestamp info to GC details</td>
</tr>
<tr>
<td><code>-XX:+PrintHeapAtGC</code></td>
<td>false</td>
<td></td>
<td>Prints detailed GC info including heap occupancy before and after GC</td>
</tr>
<tr>
<td><code>-XX:+PrintTenuringDistribution</code></td>
<td>false</td>
<td></td>
<td>Prints object aging or tenuring information</td>
</tr>
<tr>
<td><code>-XX:+PrintHeapUsageOverTime</code></td>
<td>false</td>
<td></td>
<td>Print heap usage and capacity with timestamps</td>
</tr>
<tr>
<td><code>-Xloggc:filename</code></td>
<td>false</td>
<td></td>
<td>Prints GC info to a log file</td>
</tr>
<tr>
<td><code>-verbose:gc</code></td>
<td>false</td>
<td></td>
<td>Prints some GC info</td>
</tr>
<tr>
<td><code>-XX:+PrintTLAB</code></td>
<td>false</td>
<td></td>
<td>Print TLAB information</td>
</tr>
</tbody>
</table>
<p><span id="more-127"></span><br />
<strong>Parallel Scavenge Collector</strong></p>
<table border="1" cellspacing="0" cellpadding="2" width="500">
<tbody>
<tr>
<td class="yellowtitle" width="235">Option</td>
<td class="yellowtitle" width="90">Default value</td>
<td class="yellowtitle" width="80">Max Value</td>
<td class="yellowtitle" width="95">Description</td>
</tr>
<tr>
<td><code>-XX:UseParallelGC</code></td>
<td></td>
<td></td>
<td>Enables young generation parallel scavenge collector. Works only with the default mark-sweep-compact collector. Do not use with the concurrent collector.</td>
</tr>
<tr>
<td><code>-XX:+UseAdaptiveSizePolicy</code></td>
<td>false</td>
<td></td>
<td>Automatically sizes the young generation and chooses an optimum survivor ratio to maximize performance.</td>
</tr>
<tr>
<td><code>-XX:+PrintAdaptiveSizePolicy</code></td>
<td>false</td>
<td></td>
<td>Prints information about adaptive size policy</td>
</tr>
<tr>
<td><code>-XX:ParallelGCThreads</code></td>
<td>As many threads as CPUs</td>
<td></td>
<td>Controls the number of threads used for copying collection</td>
</tr>
</tbody>
</table>
<p><strong>Parallel Copying Collector</strong></p>
<table border="1" cellspacing="0" cellpadding="2" width="500">
<tbody>
<tr>
<td class="yellowtitle" width="170">Option</td>
<td class="yellowtitle" width="85">Default value</td>
<td class="yellowtitle" width="75">Max Value</td>
<td class="yellowtitle" width="170">Description</td>
</tr>
<tr>
<td><code>-XX:+UseParNewGC</code></td>
<td></td>
<td></td>
<td>Enables young generation parallel copying collector. Use with concurrent collector or default mark-sweep-compact collector</td>
</tr>
<tr>
<td><code>-XX:ParallelGCThreads</code></td>
<td>As many threads as CPUs</td>
<td></td>
<td>Controls the number of threads used for copying collection</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2009/06/24/java-gc-options/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>千の風になって</title>
		<link>http://www.goworkday.com/2009/06/07/%e5%8d%83%e3%81%ae%e9%a2%a8%e3%81%ab%e3%81%aa%e3%81%a3%e3%81%a6/</link>
		<comments>http://www.goworkday.com/2009/06/07/%e5%8d%83%e3%81%ae%e9%a2%a8%e3%81%ab%e3%81%aa%e3%81%a3%e3%81%a6/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 18:34:35 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Japan]]></category>
		<category><![CDATA[song]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=121</guid>
		<description><![CDATA[<br/>]]></description>
			<content:encoded><![CDATA[<br/><p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/MRAFYTNgXME&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/MRAFYTNgXME&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2009/06/07/%e5%8d%83%e3%81%ae%e9%a2%a8%e3%81%ab%e3%81%aa%e3%81%a3%e3%81%a6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Profiling MySQL Queries</title>
		<link>http://www.goworkday.com/2009/05/23/profiling-mysql-queries/</link>
		<comments>http://www.goworkday.com/2009/05/23/profiling-mysql-queries/#comments</comments>
		<pubDate>Sat, 23 May 2009 00:41:10 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=112</guid>
		<description><![CDATA[<br/>Profiling Queries with SHOW STATUS mysql&#62; flush status; mysql&#62; select SQL_NO_CACHE count(*) from table; - Check query plan now: mysql&#62; show status like 'Select%'; - Check engine operations: mysql&#62; show status like 'Handler%'; - Check if there was any ordering: mysql&#62; show status like 'Sort%'; - Check how many temporary tables have been created: mysql&#62; [...]]]></description>
			<content:encoded><![CDATA[<br/><p><strong>Profiling Queries with SHOW STATUS</strong><code><br />
mysql&gt; flush status;<br />
mysql&gt; select SQL_NO_CACHE count(*) from table;<br />
</code><br />
- Check query plan now:<br />
<code><br />
mysql&gt; show status like 'Select%';<br />
</code><br />
- Check engine operations:<br />
<code><br />
mysql&gt; show status like 'Handler%';<br />
</code><br />
- Check if there was any ordering:<br />
<code><br />
mysql&gt; show status like 'Sort%';<br />
</code><br />
- Check how many temporary tables have been created:<br />
<code><br />
mysql&gt; show status like 'Created%';<br />
</code></p>
<p><span id="more-112"></span></p>
<p><strong>Profiling Queries with SHOW PROFILE</strong><br />
<code><br />
mysql&gt; set profile=1;<br />
select count(*) from table;<br />
mysql&gt; show profiles\G<br />
*************************** 1. row ***************************<br />
Query_ID: 1<br />
Duration: 9.28089300<br />
Query: select count(*) from table<br />
1 row in set (0.00 sec)<br />
mysql&gt; show profile;<br />
+--------------------+----------+<br />
| Status             | Duration |<br />
+--------------------+----------+<br />
| starting           | 0.165418 |<br />
| Opening tables     | 0.000024 |<br />
| System lock        | 0.000004 |<br />
| Table lock         | 0.000008 |<br />
| init               | 0.000014 |<br />
| optimizing         | 0.000006 |<br />
| statistics         | 0.000013 |<br />
| preparing          | 0.000012 |<br />
| executing          | 0.000006 |<br />
| Sending data       | 9.115348 |<br />
| end                | 0.000015 |<br />
| end                | 0.000004 |<br />
| query end          | 0.000003 |<br />
| freeing items      | 0.000008 |<br />
| closing tables     | 0.000004 |<br />
| logging slow query | 0.000002 |<br />
| cleaning up        | 0.000004 |<br />
+--------------------+----------+</code></p>
<p>mysql&gt; show profile cpu;<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+<br />
| Status             | Duration | CPU_user | CPU_system |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+<br />
| starting           | 0.000063 | 0.000000 |   0.000000 |<br />
| query end          | 0.000004 | 0.000000 |   0.000000 |<br />
| freeing items      | 0.000005 | 0.000000 |   0.000000 |<br />
| logging slow query | 0.000003 | 0.000000 |   0.000000 |<br />
| cleaning up        | 0.000003 | 0.000000 |   0.000000 |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;+</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2009/05/23/profiling-mysql-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find the Biggest CPU Hog</title>
		<link>http://www.goworkday.com/2009/03/27/find-the-biggest-cpu-hog/</link>
		<comments>http://www.goworkday.com/2009/03/27/find-the-biggest-cpu-hog/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 04:36:34 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[ps]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=103</guid>
		<description><![CDATA[<br/>Is a certain process running your CPU right into the ground? How do you find said process without picking your way through the ps aux results? With this command: ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu &#124; sed '/^ 0.0 /d' &#8230;at which point you can kill it with sudo kill -9.]]></description>
			<content:encoded><![CDATA[<br/><p>Is a certain process running your CPU right into the ground? How do you find said process without picking your way through the ps aux results? With this command:</p>
<p><code>ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'</code></p>
<p>&#8230;at which point you can kill it with sudo kill -9.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2009/03/27/find-the-biggest-cpu-hog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
