<?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>Infoforia</title>
	<atom:link href="http://blog.robmela.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.robmela.com</link>
	<description>The jittery buzz of too much information</description>
	<pubDate>Tue, 01 Apr 2008 03:16:59 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>WordPress Permalinks</title>
		<link>http://blog.robmela.com/2008/03/30/wordpress-permalinks/</link>
		<comments>http://blog.robmela.com/2008/03/30/wordpress-permalinks/#comments</comments>
		<pubDate>Sun, 30 Mar 2008 21:25:28 +0000</pubDate>
		<dc:creator>rmela</dc:creator>
		
		<category><![CDATA[software]]></category>

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

		<category><![CDATA[apache configuration]]></category>

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

		<category><![CDATA[mod rewrite]]></category>

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

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

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

		<guid isPermaLink="false">http://blog.robmela.com/?p=12</guid>
		<description><![CDATA[The simple Apache configuration that WordPress suggests for use with Permalinks doesn&#8217;t always work.  If you&#8217;re seeing strange behavior, you may be having interactions with other redirect configurations.
The solution is to specify the permalink URLs more precisely in RewriteRule matches.
This configuration assumes the standard &#8220;Day and Name&#8221; permalink setting for articles, and WordPress&#8217; default [...]]]></description>
			<content:encoded><![CDATA[<p>The simple Apache configuration that WordPress suggests for use with Permalinks doesn&#8217;t always work.  If you&#8217;re seeing strange behavior, you may be having interactions with other redirect configurations.</p>
<p>The solution is to specify the permalink URLs more precisely in RewriteRule matches.</p>
<p>This configuration assumes the standard &#8220;Day and Name&#8221; permalink setting for articles, and WordPress&#8217; default category base:</p>
<ul>
<li>http://your-domain-here/2008/05/21/some-post-title</li>
<li>http://your-domain-here/category/some-category-name</li>
</ul>
<p>To enable permalinks through the WordPress 2.5 admin panel ( very similar to WordPress 2.3 ):</p>
<ol>
<li>http://your-domain-here/wp-admin</li>
<li>Log in as admin</li>
<li>Select &#8220;Settings&#8221;</li>
<li>Select &#8220;Permalinks&#8221;</li>
<li>Check &#8220;Day and Name&#8221;
<p><i>You may select other formats so long as the mod_rewrite entry ( below ) matches the format you choose</i></p>
</li>
<li>Leave &#8220;category base&#8221; and &#8220;tag base&#8221; settings blank for defaults of &#8216;/tag/&#8217; and &#8216;/category/&#8217;</li>
<li>Click &#8220;Save&#8221;</li>
</ol>
<p>If the default .htaccess configuration WordPress suggests on that admin page doesn&#8217;t work then give mod_rewrite more specific patterns for matching incoming permalink requests.</p>
<pre style='font-size: 1.2em; background-color: #E0E0E0; margin-left: -5%; margin-right: -20%; padding-left: 10px'>

# "RewriteBase" allowed only within .htaccess files.
# Comment it it out if you're putting this into
# httpd.conf or file included therein.

RewriteBase /

# Take default WordPress permalink URL and
# redirect back to WordPress /index.php with
# named parameter to retrieve story by name

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/([\-_0-9a-z\/]+) /index.php?name=$1 [L]

# Ditto, but for categories.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /category/.* /index.php?category=/$1 [L]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.robmela.com/2008/03/30/wordpress-permalinks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Jefferson on Christianity</title>
		<link>http://blog.robmela.com/2008/03/23/jefferson-on-christianity/</link>
		<comments>http://blog.robmela.com/2008/03/23/jefferson-on-christianity/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 09:45:39 +0000</pubDate>
		<dc:creator>rmela</dc:creator>
		
		<category><![CDATA[history]]></category>

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

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

		<category><![CDATA[Founding Fathers]]></category>

		<category><![CDATA[Thomas Jefferson]]></category>

		<guid isPermaLink="false">http://blog.robmela.com/2008/03/23/jefferson-on-christianity/</guid>
		<description><![CDATA[&#8230; but a short time elapsed after the death of the great reformer of the Jewish religion, before his principles were departed from by those who professed to be his special servants, and perverted into an engine for enslaving mankind, and aggrandizing their oppressors in Church and State; that the purest system of morals ever [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230; but a short time elapsed after the death of the great reformer of the Jewish religion, before his principles were departed from by those who professed to be his special servants, and perverted into an engine for enslaving mankind, and aggrandizing their oppressors in Church and State; that the purest system of morals ever before preached to man, has been adulterated and sophisticated by artificial constructions, into a mere contrivance to filch wealth and power to themselves; that rational men not being able to swallow their impious heresies, in order to force them down their throats, raise the hue and cry of infidelity, while they themselves are the obstacles to the advancement of the real doctrines of Jesus, and do in fact constitute the real Anti-Christ.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.robmela.com/2008/03/23/jefferson-on-christianity/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Thomas Jefferson on the Gospels</title>
		<link>http://blog.robmela.com/2008/03/23/thomas-jefferson-on-the-gospels/</link>
		<comments>http://blog.robmela.com/2008/03/23/thomas-jefferson-on-the-gospels/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 09:44:33 +0000</pubDate>
		<dc:creator>rmela</dc:creator>
		
		<category><![CDATA[history]]></category>

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

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

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

		<category><![CDATA[Thomas Jefferson]]></category>

		<guid isPermaLink="false">http://blog.robmela.com/2008/03/23/thomas-jefferson-on-the-gospels/</guid>
		<description><![CDATA[Thomas Jefferson approached religion with common sense and reason. His writings will come as a disappointment to the religionists of today. Here&#8217;s an excerpt from a letter to Dr. Benjamin Rush, dated April 23rd, 1803. He writes of Jesus and the Gospels:
The Disadvantages under which his doctrines appear are remarkable.

Like Socrates and Epicteus, he wrote [...]]]></description>
			<content:encoded><![CDATA[<p class="content"><span style="font-style: italic">Thomas Jefferson approached religion with common sense and reason. His writings will come as a disappointment to the religionists of today. Here&#8217;s an excerpt from a letter to Dr. Benjamin Rush, dated April 23rd, 1803. He writes of Jesus and the Gospels:</span></p>
<p>The Disadvantages under which his doctrines appear are remarkable.</p>
<ol>
<li>Like Socrates and Epicteus, he wrote nothing himself</li>
<li>But he had not, like them, a Xenephon or Arrian to write for him.    On the contrary, all the learned of his country, entrenched in its    powers and riches, were opposed to him, lest his labors should undermine    their advantages; and the committing to writing his life &amp; doctrines    fell on the most unlettered &amp; ignorant men; who wrote, to, from memory,    and not till long after the transactions have past.According to the ordinary fate of those who attempt to enlighten and reform mankind, he fell victim to the jealosy and combination of the altar and the throne, at about 33. years of age, his reason having not yet attained the <em>maximum</em> of its energy, nor the course of his preaching, which was but of 3. years at most, presented occasions for developing a complete system of morals.</li>
<li> Hence the doctrines which he really delivered were defective as a whole, and fragments only of what he did deliver have come to us mutilated, misstated, and often unintelligible.</li>
<li> They have been still more disfigured by the corruptions of schismatising followers, who have found an interest in sophisticating and perverting the simple doctrines he taught by engrafting on them the mysticisms of a Grecian sophist, frittering them into subtleties, and obscuring them with jargon, until they have caused good men to reject the whole in disgust, and to view Jesus himself as an imposter.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.robmela.com/2008/03/23/thomas-jefferson-on-the-gospels/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Never an Infidel, if Never a Priest</title>
		<link>http://blog.robmela.com/2008/03/23/never-an-infidel-if-never-a-priest/</link>
		<comments>http://blog.robmela.com/2008/03/23/never-an-infidel-if-never-a-priest/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 09:43:34 +0000</pubDate>
		<dc:creator>rmela</dc:creator>
		
		<category><![CDATA[history]]></category>

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

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

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

		<category><![CDATA[Founding Fathers]]></category>

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

		<category><![CDATA[Thomas Jefferson]]></category>

		<guid isPermaLink="false">http://blog.robmela.com/2008/03/23/never-an-infidel-if-never-a-priest/</guid>
		<description><![CDATA[Letter from Thomas Jefferson to Mrs. Samuel H. Smith 
Monticello, August 6, 1816
I have received, dear Madam, your very friendly letter of July 21st, and assure you that I feel with deep sensibility its kind expressions towards myself, and the more as from a person than whom no others could be more in sympathy with [...]]]></description>
			<content:encoded><![CDATA[<p class="content"><em>Letter from Thomas Jefferson to Mrs. Samuel H. Smith </em></p>
<p>Monticello, August 6, 1816</p>
<p>I have received, dear Madam, your very friendly letter of July 21st, and assure you that I feel with deep sensibility its kind expressions towards myself, and the more as from a person than whom no others could be more in sympathy with my own affections.  I often call to mind the occasions of knowing your worth, which the societies of Washington furnished; and none more than those derived from your much valued visit to Monticello.  I recognize the same motives of goodness in the solicitude you express on the rumor supposed to proceed form a letter of mine to Charles Thomson, on the subject of the Christian religion.  It is true that, in writing to the translator of the Bible and Testament, that the subject was mentioned; but equally so that no adherence to any particular mode of Christianity was there expressed, nor any change of opinions suggested.  A change from what? the priests indeed have heretofore thought proper to ascribe to me religious or rather anti-religous sentiments, of their own fabric, but such as soothed their resentments against the act of Virginia for establishing religious freedom.  They wished him to be thought atheist, deist, or devil, who could advocate freedom from their religious dictations.  But I have ever thought religion a concern purely between our God and our consciences, for which we were accountable to him, and not to the priests.  I never told my own religion, nor scrutinized that of another.  I never attempted to make a convert, nor wished to change another&#8217;s creed.  I have ever judged of the religion of others by their lives, and by this test, dear Madam, I have been satisfied yours must be an excellent one, to have produced a life of such exemplary virtue and correctness.  For it is in our lives, and not from our words, that our religion must be read.  By the same test the world must judge me.  But this does not satisfy the priesthood.  They must have a positive, a declared assent to all their interested absurdities.  My opinion is that there never would have been an infidel, if there had never been a priest.  The artificial structures they have built on the purest of all moral systems, for the purpose of deriving from it pence and power, revolts those who think for themselves, and who read in that system only what is really there.   These, therefore, they brand with such nick-names as their enmity chooses gratuitously to impute.  I have left the world, in silence, to judge of causes from their effects; and I am consoled in this course, my dear friend, when I perceive the candor with which I am judged by your justice and discernment; and that, notwithstanding the slanders of the saints, my fellow citizens hve thought me worthy of their trusts.  The imputations of irreligion having spent their force; they think an imputation of change might now be turned to account as a holster for their duperies.   I shall leave them, as heretofore, to grope on in the dark.</p>
<p>Our family at Monticello is all in good heath; Ellen speaking of you with affection, and Mrs.  Randolph always regretting the accident which so far deprived her of the happiness of your former visit.  She still cherishes the hope of some future renewal of that kindness; in which we all join her, as in the assurances of affectionate attachment and respect.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.robmela.com/2008/03/23/never-an-infidel-if-never-a-priest/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fixed Gear Panic Stop</title>
		<link>http://blog.robmela.com/2008/03/23/fixed-gear-panic-stop/</link>
		<comments>http://blog.robmela.com/2008/03/23/fixed-gear-panic-stop/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 09:42:59 +0000</pubDate>
		<dc:creator>rmela</dc:creator>
		
		<category><![CDATA[cycling]]></category>

		<category><![CDATA[fixed gear]]></category>

		<category><![CDATA[single speed]]></category>

		<guid isPermaLink="false">http://blog.robmela.com/2008/03/23/fixed-gear-panic-stop/</guid>
		<description><![CDATA[My first fixed-gear bike, a Gunnar Street Dog, is light, quick, and nimble. The best way to describe the feel is&#8230; zinggg&#8230; A bike like that rewards every effort, which of course inspires more effort.
My first time in the saddle I hammered up a long hill. Then hammered back down, wherein my first white-knuckle lesson [...]]]></description>
			<content:encoded><![CDATA[<p class="content">My first fixed-gear bike, a Gunnar Street Dog, is light, quick, and nimble. The best way to describe the feel is&#8230; zinggg&#8230; A bike like that rewards every effort, which of course inspires more effort.</p>
<p>My first time in the saddle I hammered up a long hill. Then hammered back down, wherein my first white-knuckle lesson on the zen of fixed-gear riding. I&#8217;m lucky I survived.</p>
<p>&#8220;Fixed&#8221; means the rear cog is not mounted on a freewheel. It is &#8220;fixed&#8221; in position and cannot spin. If the wheel turns it drives the cog. The cog drives the chain. The chain drives the crank and pedals. Your feet need to move with them.</p>
<p>Fear helped in confronting sabre tooth tigers, woolly mammoths, and fighting with broad swords. But it&#8217;s not well suited to coping with most modern situations.</p>
<p>Fear leads to tension. Tension on a fixed gear bike leads to choppy spin. Choppy spin leads to a greater loss of control, leading to more fear. Once the muscles sieze up the situation takes over. Being afraid is what gives the fates we fear the upper hand.</p>
<p>The bike has taught me to acknowledge the danger behind the fear while setting the fear aside. On a good day can do 130 rpm and be fine. On a good day I can be present, focused, engaged with my surroundings and the forces, and not afraid.</p>
<p>But if I&#8217;m off my game in the slightest the bike will makes it instantly, inescapably clear. I can hide things from myself in many situations. I can hide things from myself that the bike, on a steep descent, will quickly reveal.</p>
<p>I think the lesson applies broadly. If, as a society, we allow fear to drive us, our reaction is driven by the instinctive knee-jerk. Instead of the patience, focus, reason, and coordination required to engage and work with the problem, we resort to the knee-jerk. Our fear leads us to deliver exactly whats required for the situation to catapult us into the crash.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.robmela.com/2008/03/23/fixed-gear-panic-stop/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Famous New Yorker on City Bicycle Commuting</title>
		<link>http://blog.robmela.com/2008/03/23/famous-new-yorker-on-city-bicycle-commuting/</link>
		<comments>http://blog.robmela.com/2008/03/23/famous-new-yorker-on-city-bicycle-commuting/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 09:42:05 +0000</pubDate>
		<dc:creator>rmela</dc:creator>
		
		<category><![CDATA[cycling]]></category>

		<guid isPermaLink="false">http://blog.robmela.com/2008/03/23/famous-new-yorker-on-city-bicycle-commuting/</guid>
		<description><![CDATA[ &#8220;once you get used to it riding in the city it gives you a nice jolt of energy first thing in the morning.&#8221;
&#8220;it&#8217;s an exciting visual parade that you get at slightly above normal eye level&#8221;
The sights in New York you never get tired of it&#8221;
ed. comment: same is true for Boston
&#8220;That&#8217;s one of [...]]]></description>
			<content:encoded><![CDATA[<p class="content"> &#8220;once you get used to it riding in the city it gives you a nice jolt of energy first thing in the morning.&#8221;</p>
<p>&#8220;it&#8217;s an exciting visual parade that you get at slightly above normal eye level&#8221;</p>
<p>The sights in New York you never get tired of it&#8221;<br />
<em>ed. comment: same is true for Boston</em></p>
<p>&#8220;That&#8217;s one of the rules I learned is if you see New Jersey Plates watch out. They have uh, they&#8217;re not familiar with non-cars on the road, so they don&#8217;t expect them. It&#8217;s not a criticism it&#8217;s just a fact&#8221;</p>
<p><a href="http://journal.davidbyrne.com/2007/10/10072007-how-ne.html">See the video</a></p>
<p>And another New Yorker &#8212; coulda been describing Cambridge&#8230;</p>
<p>“I have been riding a bike in Manhattan for 40 years, and I have yet to shift gears.”</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.robmela.com/2008/03/23/famous-new-yorker-on-city-bicycle-commuting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Stone Building</title>
		<link>http://blog.robmela.com/2008/03/23/the-stone-building/</link>
		<comments>http://blog.robmela.com/2008/03/23/the-stone-building/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 09:28:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[history]]></category>

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

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

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

		<guid isPermaLink="false">http://wp.robmela.com/2008/03/23/the-stone-building/</guid>
		<description><![CDATA[Plaque on the East Branch of the Lexington Library, next to the Follen Church.
Below are two excerpts from &#8220;&#8216;History of the Stone Building&#8217;, read by A. Bradford Smith, Dec. 12, 1893&#8243;, in   Proceedings of the Lexington Historical Society, Volume II, 1890-1899
 RALPH WALDO EMERSON &#124; CHARLES FOLLEN &#124; JOHN S. DWIGHT &#124; WENDELL [...]]]></description>
			<content:encoded><![CDATA[<p>Plaque on the East Branch of the Lexington Library, next to the <a href="http://follen.org/">Follen Church</a>.<br />
<i>Below are two excerpts from &#8220;&#8216;History of the Stone Building&#8217;, read by A. Bradford Smith, Dec. 12, 1893&#8243;, in   Proceedings of the Lexington Historical Society, Volume II, 1890-1899</i></p>
<div style="padding: 2em; float: right; width: 30%"><img src="http://robmela.com/wp-content/uploads/Emerson_Hall_Plaque_medium.jpg" alt="" /> <a href="http://www25.uua.org/uuhs/duub/articles/ralphwaldoemerson.html">RALPH WALDO EMERSON</a> | <a href="http://follen.org/?q=History">CHARLES FOLLEN</a> | <a href="http://www25.uua.org/uuhs/duub/articles/johnsullivandwight.html">JOHN S. DWIGHT</a> | WENDELL PHILLIPS | <a href="http://www25.uua.org/uuhs/duub/articles/josiahquincy.html">JOSIAH QUINCY</a> | JOHN PEIRPONT | <a href="http://www25.uua.org/uuhs/duub/articles/theodoreparker.html">THEODORE PARKER</a> | CHARLES SUMNER | JOHN C. PARK | PARKER PILLSBURY | NATHANIEL P. BANKS</div>
<p>In the winter of 1846-&#8217;47 a course of lyceum lectures was given in this hall by some of the ablest speakers of their time.   Among them were Charles Sumner, Wendell Phillips, Theodore Parker, Josiah Quincy Jr., and John C. Park.  Sumner&#8217;s subject was &#8220;The true Grandeur of Nations&#8221;, an oration delivered in Boston on the 4th of July 1844.  The grand sentiments of this address (though disapproved by the rich men of Boston) were fully approved and endorsed by John A. Andrew, John Quincy Adams, and by Richard Cobden, the great apostle of peace, and Rogers, the English poet.  Wendell Phillips&#8217; subject was, &#8220;The Lost Arts&#8221;.  The committee were afraid to let him select his own subject, for fear it would be on  anti-slavery.  Afterwards he delivered the same lecture in Lexington for the same reason.   Theodore Parker&#8217;s subject was &#8220;The Landing of the Pilgrims&#8221;.   Josiah Quincy&#8217;s was &#8220;Lafayette&#8221;, he being on the staff of Gov. Eustis in 1842, when Lafayette visited this country. John C. Parks, &#8220;The Military of Massachusetts&#8221;.</p>
<p>One of the fist lectures by Gen. Banks was in this hall.  In 1847 Parker Pillsbury, the noted abolitionist, gave a lecture here on the slavery question, and one gentleman said, &#8220;They wanted a free soil party.&#8221; Pillsbury replied, &#8220;There is not an inch of free soil in this country.&#8221; The old gentleman said &#8220;We wish it to be.&#8221;.  Pillsbury replied, &#8220;Call it the wish party.&#8221;</p>
<hr />After the decease of the widow of Mr. Abner Stone, the town became entitled, under Article 3 of her will, to a gift of one half acre of land in Lexington, as a site for a public reading room and library, the same to be selected by her daughter, Miss Ellen A. Stone.  In lieue of a literal compliance with said portion of her mother&#8217;s will, she offered the town, for a sum of two thousand dollars, a deed of conveyance of this large mansion house owned by her, with a suitable lot of land adjoining, for library, reading room, and other purposes.  The town accepted the generous offer, and their gratitude to Miss E. A. Stone for furnishing a home for an institution so beneficial to her native village, so dear to her mother and herself.  It was voted by the town to call the building the &#8220;Stone Building.&#8221;.  The town generously voted an appropriation to repair the building and make it suitable for the purposes designated; and now, as the result, we have a beautiful place where all ages, nationalities, and sects in our village may gain knowledge and wisdom, not alone from books and magazines, but also from the varied classes for instruction, which shall meet here.</p>
<div style="margin-left: 10%">Excerpts from &#8220;History of the Stone Building&#8221;, read by A. Bradford Smith, Dec. 12, 1893.  Proceedings of the Lexington Historical Society, Volume II, 1890-1899</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.robmela.com/2008/03/23/the-stone-building/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Smaller, Faster Counters</title>
		<link>http://blog.robmela.com/2008/03/22/smaller-faster-counters/</link>
		<comments>http://blog.robmela.com/2008/03/22/smaller-faster-counters/#comments</comments>
		<pubDate>Sun, 23 Mar 2008 02:50:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://wp.robmela.com/2008/03/22/smaller-faster-counters/</guid>
		<description><![CDATA[I normally avoid this sort of low-level stuff like the plague, but: since I do lot of multi-threaded programming with large, dynamic data structures this has turned out to matter&#8230;
I wound up doing C++ in Windows again, and this time decided to look at InterlockedIncrement and friends. I also looked at atomic.h in my preferred [...]]]></description>
			<content:encoded><![CDATA[<p class="content">I normally avoid this sort of low-level stuff like the plague, but: since I do lot of multi-threaded programming with large, dynamic data structures this has turned out to matter&#8230;</p>
<p>I wound up doing C++ in Windows again, and this time decided to look at InterlockedIncrement and friends. I also looked at atomic.h in my preferred operating system, Linux.</p>
<p>The size and performance difference between mutex lock/unlock as compared to an atomic bus-locked operations is:</p>
<p>On my 64-bit Ubuntu system, it takes a 40-byte mutex to synchronize access to an 8-byte integer or pointer. While I prefer the mutex for portability and features, it&#8217;s not practical for wrapping very simple counter or pointer swap operations when there are billions of objects.</p>
<p>An atomic operation in assembler consists of placing the &#8220;lock&#8221; prefix before certan operations, e.g., compare and exchange, increment, decrement, various ors and ands. The lock prefix causes the system to lock the memory bus for the location of the variable you&#8217;re operating on.</p>
<p>Each mutex *lock* runs about 20 assembler instructions, of which *two* are atomic instructions. After that&#8217;s done, you can do your increment or swap. Finally, you call pthread_mutex_unlock, for another dozen or two instructions, including two more atomic operations. The fact that the pthread_mutex_lock/unlock are function calls adds some overhead, but that&#8217;s a drop in the bucket after everything else is considered.</p>
<p>Finally, you can expect a several-fold increase in speed when using the atomic operations. A single atomic operation is about three or four assembler instructions, of which one is the increment, decrement, or whatever that you&#8217;re interested in.</p>
<p>Atomic operations require no initialization . If you&#8217;re creating and destroying thousands of objects per second then a pthread mutex or that other system&#8217;s CriticalSection add more burden.<br />
A call to pthread_mutex_lock requires 19 assembly instructions&#8230; and then there&#8217;s still the unlock.</p>
<pre id="mutex_assembler" class="code" style="margin-left: 1%; margin-right: -10%; font-size: 0.9em;">
'>
0x00002abee47cd2f0 &lt;pthread_mutex_lock+0&gt;   push   %rbp
0x00002abee47cd2f1 &lt;pthread_mutex_lock+1&gt;   mov    %rdi,%r8
<span style='color: blue' >
0&#215;00002abee47cd2f4 &lt;pthread_mutex_lock+4&gt;   push   %rbx
0&#215;00002abee47cd2f5 &lt;pthread_mutex_lock+5&gt;   sub    $0&#215;8,%rsp
0&#215;00002abee47cd2f9 &lt;pthread_mutex_lock+9&gt;   mov    %fs:0&#215;90,%r9d
0&#215;00002abee47cd302 &lt;pthread_mutex_lock+18&gt;  movslq 0&#215;10(%rdi),%rax
0&#215;00002abee47cd306 &lt;pthread_mutex_lock+22&gt;  cmp    $0&#215;13,%rax
0&#215;00002abee47cd30a &lt;pthread_mutex_lock+26&gt;  ja     0&#215;2abee47cd320 &lt;pthread_mutex_lock+48&gt;

0&#215;00002abee47cd336 &lt;pthread_mutex_lock+70&gt;  mov    $0&#215;1,%esi
0&#215;00002abee47cd33b &lt;pthread_mutex_lock+75&gt;  xor    %eax,%eax
0&#215;00002abee47cd33d &lt;pthread_mutex_lock+77&gt;  lock cmpxchg %esi,(%r8)
0&#215;00002abee47cd342 &lt;pthread_mutex_lock+82&gt;  jne    0&#215;2abee47cd5d9 &lt;pthread_mutex_lock+745&gt;
0&#215;00002abee47cd348 &lt;pthread_mutex_lock+88&gt;  mov    0&#215;8(%r8),%ecx
0&#215;00002abee47cd34c &lt;pthread_mutex_lock+92&gt;  test   %ecx,%ecx
0&#215;00002abee47cd34e &lt;pthread_mutex_lock+94&gt;  jne    0&#215;2abee47cd559 &lt;pthread_mutex_lock+617&gt;
0&#215;00002abee47cd354 &lt;pthread_mutex_lock+100&gt; addl   $0&#215;1,0xc(%r8)
0&#215;00002abee47cd359 &lt;pthread_mutex_lock+105&gt; mov    %r9d,0&#215;8(%r8)
0&#215;00002abee47cd35d &lt;pthread_mutex_lock+109&gt; add    $0&#215;8,%rsp
0&#215;00002abee47cd361 &lt;pthread_mutex_lock+113&gt; pop    %rbx
0&#215;00002abee47cd362 &lt;pthread_mutex_lock+114&gt; pop    %rbp
0&#215;00002abee47cd363 &lt;pthread_mutex_lock+115&gt; xor    %eax,%eax
</span>
0&#215;00002abee47cd365 &lt;pthread_mutex_lock+117&gt;    retq
</pre>
<p>The atomic increment, on the other hand, is about four assembler operations, not counting the stack setup and return.  And there&#8217;s no subsequent unlock step.</p>
<pre class="code" style="margin-left: 1%; margin-right: -10%">0x0000000000400628 &lt;increment2+0&gt;      push   %rbp
0x0000000000400629 &lt;increment2+1&gt;      mov    %rsp,%rbp
<span style="color: blue;">
0&#215;000000000040062c &lt;increment2+4&gt;      mov    %rdi,0xfffffffffffffff8(%rbp)
0&#215;0000000000400630 &lt;increment2+8&gt;      mov    0xfffffffffffffff8(%rbp),%rdx
0&#215;0000000000400634 &lt;increment2+12&gt;     mov    0xfffffffffffffff8(%rbp),%rax
0&#215;0000000000400638 &lt;increment2+16&gt;     lock incl (%rdx)
</span>
0&#215;000000000040063b &lt;increment2+19&gt;     leaveq
0&#215;000000000040063c &lt;increment2+20&gt;     retq</pre>
<p>If you&#8217;re created and destroying thousands of objects per second, each with its own mutex, then you&#8217;ll have to take mutex initialization and teardown into account.</p>
<p>The code below, source of the assembler dumps, illustrates the two approaches. The assembler code is lifted from /usr/include/asm-x86_64/atomic.h.</p>
<pre class="code" style="margin-left: 1%; margin-right: -10%">#include &lt;pthread.h&gt;
#include &lt;stdio.h&gt;

pthread_mutex_t gMutex = PTHREAD_MUTEX_INITIALIZER;

void mutexed_increment(unsigned long* pn)
{
    pthread_mutex_lock(&amp;gMutex);
    ++*pn;
    pthread_mutex_unlock(&amp;gMutex);
}
static inline atomic_increment(unsigned long* pn)
{
        __asm__ __volatile__(
                "lock; incl %0"
                :"=m" (*pn)
                :"m" (*pn));
}
int main (int argc, char **argv)
{
   unsigned long i = 0;
   printf( "Size of pthread_mutex_t: %u; sizeof long: %u\n",
            sizeof(pthread_mutex_t),
            sizeof(i));
   mutex_increment(&amp;i);
   atomic_increment(&amp;i);
   printf("i=%u\n", i );
   return 0;
}</pre>
<h2>Conclusion</h2>
<p>Native synchronization code can offer significant benefits in high-performance server applications, especially where there is a very large number of objects to be synchronized, and where synchronized access occurs at a high rate.</p>
<ul>
<li>Several-fold memory savings; synchronized object requires no corresponding synchronization object</li>
<li>Several-fold reduction in clock cycles per object access<br />
<em>Measurable if there is a very high rate of access to the synchronized objects</em></li>
<li>No mutex initialization or tear-down.<br />
<em>Useful when synchronized objects are created and destroyed at high rates</em></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.robmela.com/2008/03/22/smaller-faster-counters/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
