<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>cpu on semikolan</title>
    <link>https://semikolan.me/tags/cpu/</link>
    <description>Recent content in cpu on semikolan</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Mon, 27 Jul 2026 21:19:11 +0530</lastBuildDate>
    <atom:link href="https://semikolan.me/tags/cpu/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>The Quiet Cost of a Fast Loop</title>
      <link>https://semikolan.me/blog/quiet-cost-of-a-fast-loop/</link>
      <pubDate>Tue, 30 Jun 2026 00:00:00 +0000</pubDate>
      <guid>https://semikolan.me/blog/quiet-cost-of-a-fast-loop/</guid>
      <description>&lt;p&gt;The first time I saw a sorted array process faster than an identical unsorted one, I assumed I&amp;rsquo;d measured wrong. Same data, same instructions, same count. The only difference was order — and order, I&amp;rsquo;d been taught, doesn&amp;rsquo;t change complexity.&lt;/p&gt;&#xA;&lt;p&gt;It doesn&amp;rsquo;t. It changes the &lt;em&gt;constant&lt;/em&gt;, and the constant is a physical thing living in the branch predictor.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-branch-that-couldnt-guess&#34;&gt;The branch that couldn&amp;rsquo;t guess &lt;a class=&#34;anchor&#34; href=&#34;#the-branch-that-couldnt-guess&#34; aria-label=&#34;Link to this section&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;A modern CPU runs ahead of itself. When it hits an &lt;code&gt;if&lt;/code&gt;, it doesn&amp;rsquo;t wait to learn the answer — it bets, and speculatively executes the branch it thinks you&amp;rsquo;ll take. Guess right and the work is already done. Guess wrong and it throws away a dozen in-flight instructions and starts over.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
