<?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: What I learned from my first c coding challenge</title>
	<atom:link href="http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/</link>
	<description>Stuff I did for you.</description>
	<lastBuildDate>Thu, 25 Oct 2012 19:03:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Rubén Romero</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-3126</link>
		<dc:creator>Rubén Romero</dc:creator>
		<pubDate>Wed, 19 Sep 2012 21:21:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-3126</guid>
		<description>Maybe the Varnish Modules overview  should be updated now that you have a winner? 

And... Congrats to the winnng code: https://github.com/vimeo/libvmod-boltsor

:-)</description>
		<content:encoded><![CDATA[<p>Maybe the Varnish Modules overview  should be updated now that you have a winner? </p>
<p>And&#8230; Congrats to the winnng code: <a href="https://github.com/vimeo/libvmod-boltsor" rel="nofollow">https://github.com/vimeo/libvmod-boltsor</a></p>
<p> <img src='http://blog.jasonmooberry.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dieter</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-3096</link>
		<dc:creator>Dieter</dc:creator>
		<pubDate>Tue, 18 Sep 2012 12:21:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-3096</guid>
		<description>Great writeup Jason, hope to join in next time!
I don&#039;t quite understand the &quot;Testing for zero&quot; part. So, if I understand correctly, these are the two approaches:
A) given number X, subtract numbers y1, y2, ...y5 to arrive at Y, then check whether Y == 0
B) check whether X == Y (with Y already given, and equaling y1+y2+ ... +y5)
(5 is an example and denotes amount of loop iterations)

you&#039;re saying A is faster? this is weird because it has 5 subtractions and a comparision to 0.
B compares two arbitrary ints, and if that is so slow, the compiler could turn it into one subtraction and comparison to 0: (X-Y) == 0</description>
		<content:encoded><![CDATA[<p>Great writeup Jason, hope to join in next time!<br />
I don&#8217;t quite understand the &#8220;Testing for zero&#8221; part. So, if I understand correctly, these are the two approaches:<br />
A) given number X, subtract numbers y1, y2, &#8230;y5 to arrive at Y, then check whether Y == 0<br />
B) check whether X == Y (with Y already given, and equaling y1+y2+ &#8230; +y5)<br />
(5 is an example and denotes amount of loop iterations)</p>
<p>you&#8217;re saying A is faster? this is weird because it has 5 subtractions and a comparision to 0.<br />
B compares two arbitrary ints, and if that is so slow, the compiler could turn it into one subtraction and comparison to 0: (X-Y) == 0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gordon</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-3071</link>
		<dc:creator>Gordon</dc:creator>
		<pubDate>Sat, 15 Sep 2012 18:03:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-3071</guid>
		<description>Perhaps this could help you get a few more obscure optimizations?
http://graphics.stanford.edu/~seander/bithacks.html</description>
		<content:encoded><![CDATA[<p>Perhaps this could help you get a few more obscure optimizations?<br />
<a href="http://graphics.stanford.edu/~seander/bithacks.html" rel="nofollow">http://graphics.stanford.edu/~seander/bithacks.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sv</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-3056</link>
		<dc:creator>sv</dc:creator>
		<pubDate>Fri, 14 Sep 2012 16:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-3056</guid>
		<description>I think a lot of what you ran into is cases where the optimizations you thought would work only work when dealing with things on a larger scale, e.g. the url&#039;s involve only had a handful of query parameters.  If there were thousands of parameters involved, qsort would have kicked your insertion sort&#039;s butt.

And loop unrolling is most effective when what is done what is done in the loop is trivial compared to the loop overhead and when you don&#039;t introduce any additional branching.</description>
		<content:encoded><![CDATA[<p>I think a lot of what you ran into is cases where the optimizations you thought would work only work when dealing with things on a larger scale, e.g. the url&#8217;s involve only had a handful of query parameters.  If there were thousands of parameters involved, qsort would have kicked your insertion sort&#8217;s butt.</p>
<p>And loop unrolling is most effective when what is done what is done in the loop is trivial compared to the loop overhead and when you don&#8217;t introduce any additional branching.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Sutton</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-3055</link>
		<dc:creator>Dan Sutton</dc:creator>
		<pubDate>Fri, 14 Sep 2012 16:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-3055</guid>
		<description>Interesting. Just for the sake of it, here it is in C#: .Net gives us a few things which come in handy... I know all you C purists are going to get at me for not writing my own code but using the built-in .Net stuff instead... however, it works: the point here is that sometimes C just isn&#039;t the right language if you want a decent development time:

private string Format(string Url)
{
  string[] Sects = Url.Split(&#039;?&#039;);
  try
  {
    string[] Parms = Sects[1].Split(&#039;&amp;&#039;);
    Array.Sort(Parms);
    return Sects[0] + &#039;?&#039; + String.Join(&quot;&amp;&quot;, Parms);
  }
  catch { return Url; }
}</description>
		<content:encoded><![CDATA[<p>Interesting. Just for the sake of it, here it is in C#: .Net gives us a few things which come in handy&#8230; I know all you C purists are going to get at me for not writing my own code but using the built-in .Net stuff instead&#8230; however, it works: the point here is that sometimes C just isn&#8217;t the right language if you want a decent development time:</p>
<p>private string Format(string Url)<br />
{<br />
  string[] Sects = Url.Split(&#8216;?&#8217;);<br />
  try<br />
  {<br />
    string[] Parms = Sects[1].Split(&#8216;&amp;&#8217;);<br />
    Array.Sort(Parms);<br />
    return Sects[0] + &#8216;?&#8217; + String.Join(&#8220;&amp;&#8221;, Parms);<br />
  }<br />
  catch { return Url; }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: indrora</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-3053</link>
		<dc:creator>indrora</dc:creator>
		<pubDate>Fri, 14 Sep 2012 15:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-3053</guid>
		<description>On the topic of optimizations, I&#039;ve seen some evil things done by compilers. The problem is that Loop unrolling causes great performance on x86 (since it uses nothing but a program counter and some memory for what its worth) but the entire point of loop unrolling becomes blown apart on the world of ARM.

Why? because ARM likes small code sizes. Its actually optimized for small code sizes, as it uses a L1 cache that tries to look-ahead just a bit. GCC will add bust-out lines in unrolled loops so that if something happens (e.g. you increment by too much) it can bail. Duff&#039;s Devices are cool and all, but they still fail on devices like ARM.

I found this out while writing a CRC (I know, its CRC) algorithm for an ARM chip I&#039;m working with.</description>
		<content:encoded><![CDATA[<p>On the topic of optimizations, I&#8217;ve seen some evil things done by compilers. The problem is that Loop unrolling causes great performance on x86 (since it uses nothing but a program counter and some memory for what its worth) but the entire point of loop unrolling becomes blown apart on the world of ARM.</p>
<p>Why? because ARM likes small code sizes. Its actually optimized for small code sizes, as it uses a L1 cache that tries to look-ahead just a bit. GCC will add bust-out lines in unrolled loops so that if something happens (e.g. you increment by too much) it can bail. Duff&#8217;s Devices are cool and all, but they still fail on devices like ARM.</p>
<p>I found this out while writing a CRC (I know, its CRC) algorithm for an ARM chip I&#8217;m working with.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lol</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-2762</link>
		<dc:creator>lol</dc:creator>
		<pubDate>Wed, 05 Sep 2012 09:59:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-2762</guid>
		<description>How do you do the benchmark timing? Have you excluded the I/O time? It seems you are using stdio with a small buffer, which takes quite some time.</description>
		<content:encoded><![CDATA[<p>How do you do the benchmark timing? Have you excluded the I/O time? It seems you are using stdio with a small buffer, which takes quite some time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edwin Martin</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-2757</link>
		<dc:creator>Edwin Martin</dc:creator>
		<pubDate>Wed, 05 Sep 2012 08:49:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-2757</guid>
		<description>I think the loop unrolling has no effect is not due to better compiler optimizations, but better processors. Processors use branche prediction and know to jump to the top of the loop instead of the next instruction below.</description>
		<content:encoded><![CDATA[<p>I think the loop unrolling has no effect is not due to better compiler optimizations, but better processors. Processors use branche prediction and know to jump to the top of the loop instead of the next instruction below.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-2727</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Wed, 05 Sep 2012 01:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-2727</guid>
		<description>Interesting work.

I am not sure about the compiler and platform for test.  If it is gcc, the &quot;likely&quot; macro might help with branch predictor.  But I haven&#039;t profiled it personally.

Example from :

const char *home;

home = getenv (&quot;HOME&quot;);
if (likely (home))
        printf (&quot;Your home directory is %s\n&quot;, home);
else
        fprintf (stderr, &quot;Environment variable HOME not set!\n&quot;);</description>
		<content:encoded><![CDATA[<p>Interesting work.</p>
<p>I am not sure about the compiler and platform for test.  If it is gcc, the &#8220;likely&#8221; macro might help with branch predictor.  But I haven&#8217;t profiled it personally.</p>
<p>Example from :</p>
<p>const char *home;</p>
<p>home = getenv (&#8220;HOME&#8221;);<br />
if (likely (home))<br />
        printf (&#8220;Your home directory is %s\n&#8221;, home);<br />
else<br />
        fprintf (stderr, &#8220;Environment variable HOME not set!\n&#8221;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nico</title>
		<link>http://blog.jasonmooberry.com/2012/09/what-i-learned-from-my-first-c-coding-challenge/comment-page-1/#comment-2710</link>
		<dc:creator>Nico</dc:creator>
		<pubDate>Tue, 04 Sep 2012 22:34:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jasonmooberry.com/?p=342#comment-2710</guid>
		<description>I know sorting was the challenge, but knowing what it&#039;s going to be used for, is it really necessary to sort it? Maybe you could have a hash function such that hash(&quot;b=b&amp;c=bb&amp;a=3&amp;a=4&quot;) == hash(&quot;a=3&amp;a=4&amp;b=b&amp;c=bb&quot;). I guess that&#039;s exactly what sorting does, but I wonder if there might be faster functions that have the same property, without necessarily having to sort.</description>
		<content:encoded><![CDATA[<p>I know sorting was the challenge, but knowing what it&#8217;s going to be used for, is it really necessary to sort it? Maybe you could have a hash function such that hash(&#8220;b=b&amp;c=bb&amp;a=3&amp;a=4&#8243;) == hash(&#8220;a=3&amp;a=4&amp;b=b&amp;c=bb&#8221;). I guess that&#8217;s exactly what sorting does, but I wonder if there might be faster functions that have the same property, without necessarily having to sort.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.099 seconds -->
<!-- Cached page served by WP-Cache -->
