<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: The Treacherous Optimization</title>
	<atom:link href="http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/feed/" rel="self" type="application/rss+xml" />
	<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/</link>
	<description>serious code</description>
	<lastBuildDate>Fri, 03 Jul 2009 08:31:00 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Cowherd</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-611</link>
		<dc:creator>Cowherd</dc:creator>
		<pubDate>Tue, 03 Feb 2009 01:10:31 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-611</guid>
		<description>Micro-optimizations are all well and good, but you can beat grep by 100% on dual-core systems for haystacks that are large in comparison to the needles being searched for in them:

If the haystack length is n and the needle length is m, let p = (n - m)/2 and q = p + m - 2. Now spawn two threads, each doing Boyer-Moore, one from 0 to q and the other from p to n - 1 in your big char array. If one thread finds a match, halt both.

This parallelizes the job and divides it exactly in two. Note that if the needle is in the haystack it will be found; if an occurrence contained a character one thread wouldn&#039;t search and another the other wouldn&#039;t search, it would have to contain the character before p and the character after q, plus the m - 1 characters from p (inclusive) to q (inclusive), and so have length m + 1, yet it has length m.

Of course, the serial version should be run if the haystack is too small.

Generalizing this to N-threaded versions is not too difficult, and is left as an exercise for the reader.</description>
		<content:encoded><![CDATA[<p>Micro-optimizations are all well and good, but you can beat grep by 100% on dual-core systems for haystacks that are large in comparison to the needles being searched for in them:</p>
<p>If the haystack length is n and the needle length is m, let p = (n &#8211; m)/2 and q = p + m &#8211; 2. Now spawn two threads, each doing Boyer-Moore, one from 0 to q and the other from p to n &#8211; 1 in your big char array. If one thread finds a match, halt both.</p>
<p>This parallelizes the job and divides it exactly in two. Note that if the needle is in the haystack it will be found; if an occurrence contained a character one thread wouldn&#8217;t search and another the other wouldn&#8217;t search, it would have to contain the character before p and the character after q, plus the m &#8211; 1 characters from p (inclusive) to q (inclusive), and so have length m + 1, yet it has length m.</p>
<p>Of course, the serial version should be run if the haystack is too small.</p>
<p>Generalizing this to N-threaded versions is not too difficult, and is left as an exercise for the reader.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sonic</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-610</link>
		<dc:creator>Sonic</dc:creator>
		<pubDate>Tue, 13 May 2008 13:40:46 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-610</guid>
		<description>Hi I want to recommend you very useful rapidshare search  http://loadingvault.com. You can find there a lot of new movies, games and music. Enjoy it!</description>
		<content:encoded><![CDATA[<p>Hi I want to recommend you very useful rapidshare search  <a href="http://loadingvault.com" rel="nofollow">http://loadingvault.com</a>. You can find there a lot of new movies, games and music. Enjoy it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-609</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Wed, 06 Jun 2007 23:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-609</guid>
		<description>test</description>
		<content:encoded><![CDATA[<p>test</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bart Massey</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-608</link>
		<dc:creator>Bart Massey</dc:creator>
		<pubDate>Wed, 11 Oct 2006 08:14:03 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-608</guid>
		<description>I&#039;m here with Mike Haertel, GNU grep author and the author of the performance hack that bedeviled you so.  He Googled your article somehow a while ago and was highly amused.

Mike wants you (and the very first commenter) to know that the sequence of skips he chose was carefully tuned by timing a grep for &quot;vt100&quot; in /etc/termcap.  At the time, this was a very important benchmark.

Mike has lots of grep speed tricks left up his sleeve, and has promised to share some with me at some point.  I&#039;ll keep you posted.</description>
		<content:encoded><![CDATA[<p>I&#8217;m here with Mike Haertel, GNU grep author and the author of the performance hack that bedeviled you so.  He Googled your article somehow a while ago and was highly amused.</p>
<p>Mike wants you (and the very first commenter) to know that the sequence of skips he chose was carefully tuned by timing a grep for &#8220;vt100&#8243; in /etc/termcap.  At the time, this was a very important benchmark.</p>
<p>Mike has lots of grep speed tricks left up his sleeve, and has promised to share some with me at some point.  I&#8217;ll keep you posted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jason</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-591</link>
		<dc:creator>jason</dc:creator>
		<pubDate>Sat, 19 Aug 2006 19:33:01 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-591</guid>
		<description>Is  http://crm114.sf.net  kind of a  &quot;reformed grep&quot; ? (... an easier way though may be to use NSStringRegEx, http://homepage.mac.com/jrc/contrib/ )</description>
		<content:encoded><![CDATA[<p>Is  <a href="http://crm114.sf.net" rel="nofollow">http://crm114.sf.net</a>  kind of a  &#8220;reformed grep&#8221; ? (&#8230; an easier way though may be to use NSStringRegEx, <a href="http://homepage.mac.com/jrc/contrib/" rel="nofollow">http://homepage.mac.com/jrc/contrib/</a> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: singulair</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-590</link>
		<dc:creator>singulair</dc:creator>
		<pubDate>Thu, 10 Aug 2006 08:24:34 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-590</guid>
		<description>&lt;strong&gt;singulair&lt;/strong&gt;

singulair side effects weight gain advair singulair asthma medicine singulair

singulair and weight gain weight gain singulair pediatric gain singulair weight</description>
		<content:encoded><![CDATA[<p><strong>singulair</strong></p>
<p>singulair side effects weight gain advair singulair asthma medicine singulair</p>
<p>singulair and weight gain weight gain singulair pediatric gain singulair weight</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Papadakis</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-588</link>
		<dc:creator>Mark Papadakis</dc:creator>
		<pubDate>Tue, 25 Jul 2006 09:00:05 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-588</guid>
		<description>Hm, turns out wordpress is cutting off the entries / code:) oh, well</description>
		<content:encoded><![CDATA[<p>Hm, turns out wordpress is cutting off the entries / code:) oh, well</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Papadakis</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-589</link>
		<dc:creator>Mark Papadakis</dc:creator>
		<pubDate>Tue, 25 Jul 2006 08:58:30 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-589</guid>
		<description>I thought about giving it a shot.

assuming that:
char *buffer      haystack
size_t length     the length of haystack


        int needleLen = Strlen(needle), k;
        register char *p;

        switch (needleLen)
        {
                case 0:
                return NULL;

                case 1:
                for (p = buffer; *p; p++)
                {
                        if (*p == *needle)
                                return p;
                }
                return NULL;
                break;

        }

        register const int needleSafetyBouncer = needleLen - 1;
        register int i;
        register byte delta[256];
        register const char *end = buffer + length;
        for (i = 0; i =0 ; k++, i--)
        {
                if (delta[(byte)needle[i]] == needleLen)
                        delta[(byte)needle[i]] = k;
        }


        for (p = buffer; p  X where X around 48 or so, and use Duff&#039;s device to reduce the checks for i going down to zero, in order to speed it up even more.</description>
		<content:encoded><![CDATA[<p>I thought about giving it a shot.</p>
<p>assuming that:<br />
char *buffer      haystack<br />
size_t length     the length of haystack</p>
<p>        int needleLen = Strlen(needle), k;<br />
        register char *p;</p>
<p>        switch (needleLen)<br />
        {<br />
                case 0:<br />
                return NULL;</p>
<p>                case 1:<br />
                for (p = buffer; *p; p++)<br />
                {<br />
                        if (*p == *needle)<br />
                                return p;<br />
                }<br />
                return NULL;<br />
                break;</p>
<p>        }</p>
<p>        register const int needleSafetyBouncer = needleLen &#8211; 1;<br />
        register int i;<br />
        register byte delta[256];<br />
        register const char *end = buffer + length;<br />
        for (i = 0; i =0 ; k++, i&#8211;)<br />
        {<br />
                if (delta[(byte)needle[i]] == needleLen)<br />
                        delta[(byte)needle[i]] = k;<br />
        }</p>
<p>        for (p = buffer; p  X where X around 48 or so, and use Duff&#8217;s device to reduce the checks for i going down to zero, in order to speed it up even more.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yoda</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-584</link>
		<dc:creator>yoda</dc:creator>
		<pubDate>Sun, 16 Jul 2006 03:19:20 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-584</guid>
		<description>Fish wrote: &quot;I imagine the author of grep, Ultimate Unix Geek, squinting at vi; the glow of a dozen xterms is the only light to fall on his ample frame...&quot;

You imagine wrong: grep was developed long before vi (vi came from Berkeley Unix), and very long before X Windows.  The developer of grep probably used the &quot;ed&quot; editor and a 80x24 CRT display.</description>
		<content:encoded><![CDATA[<p>Fish wrote: &#8220;I imagine the author of grep, Ultimate Unix Geek, squinting at vi; the glow of a dozen xterms is the only light to fall on his ample frame&#8230;&#8221;</p>
<p>You imagine wrong: grep was developed long before vi (vi came from Berkeley Unix), and very long before X Windows.  The developer of grep probably used the &#8220;ed&#8221; editor and a 80&#215;24 CRT display.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: the daniel</title>
		<link>http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/comment-page-1/#comment-583</link>
		<dc:creator>the daniel</dc:creator>
		<pubDate>Tue, 11 Jul 2006 20:13:42 +0000</pubDate>
		<guid isPermaLink="false">http://ridiculousfish.com/blog/archives/2006/04/30/old-age-and-treachery/#comment-583</guid>
		<description>This was interesting reading.  Thanks for writing it up!</description>
		<content:encoded><![CDATA[<p>This was interesting reading.  Thanks for writing it up!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
