<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Low Latency Trading Insights]]></title><description><![CDATA[Fresh insights on low latency and high frequency trading. Mostly new relevant technology, C++, FPGA, Verilog, tutorials, short notes and of course, rants. 
Problem subscribing? Try https://lucisqr.lemonsqueezy.com/buy/c78e2dd6-81c0-44cd-bfa3-13db7158a050]]></description><link>https://lucisqr.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png</url><title>Low Latency Trading Insights</title><link>https://lucisqr.substack.com</link></image><generator>Substack</generator><lastBuildDate>Tue, 12 May 2026 15:38:26 GMT</lastBuildDate><atom:link href="https://lucisqr.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Henrique Bucher]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[sales@vitorian.com]]></webMaster><itunes:owner><itunes:email><![CDATA[sales@vitorian.com]]></itunes:email><itunes:name><![CDATA[Henrique Bucher]]></itunes:name></itunes:owner><itunes:author><![CDATA[Henrique Bucher]]></itunes:author><googleplay:owner><![CDATA[sales@vitorian.com]]></googleplay:owner><googleplay:email><![CDATA[sales@vitorian.com]]></googleplay:email><googleplay:author><![CDATA[Henrique Bucher]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Source Code Generation: The Technique That Separates Amateurs from Professionals]]></title><description><![CDATA[Why the Best Trading Firms Never Write Protocol Code by Hand]]></description><link>https://lucisqr.substack.com/p/source-code-generation-the-technique</link><guid isPermaLink="false">https://lucisqr.substack.com/p/source-code-generation-the-technique</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Sun, 10 May 2026 03:48:54 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!KWkv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb7f0e76-bc53-4a9e-a192-03ea7f64d9b2_1146x365.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>There&#8217;s a pattern I&#8217;ve watched play out at every trading firm I&#8217;ve worked with. A new exchange format drops &#8212; CME updates MDP3 to version 13, or Euronext ships a new Optiq schema, or NASDAQ tweaks IT&#8230;</p>
      <p>
          <a href="https://lucisqr.substack.com/p/source-code-generation-the-technique">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Three CPU Generations That Changed Everything: A Latency-Focused History of x86]]></title><description><![CDATA[The year was 2011.]]></description><link>https://lucisqr.substack.com/p/three-cpu-generations-that-changed</link><guid isPermaLink="false">https://lucisqr.substack.com/p/three-cpu-generations-that-changed</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Wed, 06 May 2026 15:23:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!kuc1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0764a47e-c99e-4a51-9922-f44bd9f342a9_2080x584.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The year was 2011. On Wall Street, <strong>high-frequency trading firms were measuring success in microseconds</strong>. The Flash Crash of May 2010 had just demonstrated that markets could lose a trillion dollars in&#8230;</p>
      <p>
          <a href="https://lucisqr.substack.com/p/three-cpu-generations-that-changed">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The PREEMPT_RT Surprise: Why Isolation Alone Isn’t Enough for HFT]]></title><description><![CDATA[September 2024.]]></description><link>https://lucisqr.substack.com/p/the-preempt_rt-surprise-why-isolation</link><guid isPermaLink="false">https://lucisqr.substack.com/p/the-preempt_rt-surprise-why-isolation</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Sat, 02 May 2026 16:01:08 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!jsSk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe2e4dde4-4a5d-4fd0-8178-221641d83c85_1121x314.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>September 2024. After 20 years in development, PREEMPT_RT finally merged into Linux 6.12 mainline. The real-time community celebrated. Trade press covered it for weeks. Automotive engineers opened champagne.</p><p>And HFT developers? We shrugged.</p><p>Not because PREEMPT_RT is bad. It&#8217;s excellent for what it does. But if you&#8217;re running a trading system, <strong>the kernel is not your bottleneck</strong>. Your data structures are.</p><p>Before I show you the benchmarks that prove this, you need to understand what PREEMPT_RT actually does and why it took two decades to get here.</p><h2><strong>The Twenty-Year Journey</strong></h2><p>Back in 2004, real-time Linux was a mess. Several groups were working on incompatible approaches to the same problem: how do you make Linux guarantee response times? The efforts were uncoordinated, the patches incomplete, the mailing list discussions legendary in their toxicity.</p><p>Then <strong>Ingo Molnar</strong> did something unexpected. The RedHat kernel scheduler maintainer took pieces from various patch sets, rewrote most of them from scratch, and combined them into something coherent. <strong>Thomas Gleixner</strong>, who had been working with Dr. Doug Niehaus from Kansas University on the KURT real-time extension, joined forces with Molnar. <strong>Steven Rostedt</strong> (of ftrace fame) became another major contributor. Within months, they had a &#8220;halfway usable Real-Time solution.&#8221;</p><p>The goal was never &#8220;as fast as possible.&#8221; As Gleixner puts it: <strong>&#8220;Real-Time is not as fast as possible; it is as fast as specified.&#8221;</strong> The difference matters. Real-time means guaranteed completion within defined timeframes. Miss that deadline in a car&#8217;s braking system or a medical device, and people die.</p><p>The companies who funded this work read like a who&#8217;s-who of embedded systems: ARM, BMW, Intel, National Instruments, Texas Instruments, RedHat. Former supporters included Google, IBM, and NXP. Gleixner has been candid about the funding model resembling Jenga: &#8220;companies build key products depending on these technologies...seem to take the availability...for granted.&#8221;</p><p>Why twenty years to merge? Not because the code didn&#8217;t work. Because <strong>the changes touch core kernel infrastructure</strong>. Spinlocks. Interrupt handling. Scheduler internals. Every patch had to be designed so it &#8220;does not get in the way of other interests.&#8221; Incremental improvements went in quickly. Foundational changes required years of polishing and community alignment.</p><h2><strong>Why Normal Kernels Have Unbounded Latency</strong></h2><p>To understand what PREEMPT_RT fixes, you need to understand why standard Linux has terrible worst-case latency.</p><p><strong>The latency formula</strong> is deceptively simple:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CptF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CptF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png 424w, https://substackcdn.com/image/fetch/$s_!CptF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png 848w, https://substackcdn.com/image/fetch/$s_!CptF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png 1272w, https://substackcdn.com/image/fetch/$s_!CptF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CptF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png" width="1146" height="190" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:190,&quot;width&quot;:1146,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 1&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 1" title="Code Block 1" srcset="https://substackcdn.com/image/fetch/$s_!CptF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png 424w, https://substackcdn.com/image/fetch/$s_!CptF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png 848w, https://substackcdn.com/image/fetch/$s_!CptF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png 1272w, https://substackcdn.com/image/fetch/$s_!CptF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ecb244e-dc10-4454-8945-8c36764f1314_1146x190.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Each term can explode. Here&#8217;s why.</p><p><strong>Spinlocks disable preemption.</strong> When kernel code acquires a spinlock, it disables interrupts on that CPU. Any pending interrupt, including your trading thread&#8217;s timer, waits until the spinlock is released. The problem: <strong>critical section duration is unbounded</strong>. Some driver holding a spinlock for 500 microseconds delays everything behind it.</p><p><strong>Interrupt handlers run with interrupts disabled.</strong> Linux splits interrupt handling into two parts. The top-half runs immediately when hardware triggers an interrupt, with that interrupt line masked so nothing else can fire on it. The bottom-half (softirq, tasklet, or workqueue) runs later to do the heavy lifting. The problem is the top-half: if it takes 200 microseconds, nothing else on that interrupt line runs for 200 microseconds. Priority doesn&#8217;t matter. Your SCHED_FIFO thread with priority 99 waits for a USB driver&#8217;s interrupt handler to finish its top-half.</p><p><strong>The kernel is not preemptible by default.</strong> When your high-priority thread wakes up, it can&#8217;t run until the current kernel code path reaches a voluntary preemption point. System calls run to completion. A memcpy() of 10MB in kernel space? Your thread waits.</p><p><strong>Priority inversion destroys guarantees.</strong> Thread A (high priority) needs a lock. Thread B (low priority) holds it. Thread C (medium priority) preempts B. Now A is blocked behind C, even though A has higher priority. Without priority inheritance, your carefully tuned priorities are meaningless.</p><p>The result: a standard kernel might respond in 5 microseconds under no load, then spike to 500+ microseconds when a USB device enumerates or a filesystem flushes. <strong>You cannot bound the worst case.</strong></p><h2><strong>What PREEMPT_RT Actually Does</strong></h2><p>PREEMPT_RT attacks each source of unbounded latency.</p><p><strong>Spinlocks become sleeping locks.</strong> In a PREEMPT_RT kernel, <code>spinlock_t</code> doesn&#8217;t spin at all. It&#8217;s implemented on top of <code>rt_mutex</code>, which means a task waiting for a &#8220;spinlock&#8221; goes to sleep instead of burning CPU cycles. When the lock is released, the waiter wakes up. Preemption is not disabled while holding these locks.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DmR4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DmR4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png 424w, https://substackcdn.com/image/fetch/$s_!DmR4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png 848w, https://substackcdn.com/image/fetch/$s_!DmR4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png 1272w, https://substackcdn.com/image/fetch/$s_!DmR4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DmR4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png" width="1146" height="256" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:256,&quot;width&quot;:1146,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 2&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 2" title="Code Block 2" srcset="https://substackcdn.com/image/fetch/$s_!DmR4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png 424w, https://substackcdn.com/image/fetch/$s_!DmR4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png 848w, https://substackcdn.com/image/fetch/$s_!DmR4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png 1272w, https://substackcdn.com/image/fetch/$s_!DmR4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e9f9c28-07f5-42d6-b887-39eb4a6e9a72_1146x256.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Interrupt handlers become kernel threads.</strong> Almost all interrupt handlers in PREEMPT_RT run in process context, not hardware interrupt context. They&#8217;re scheduled like any other thread, with priorities you control. A USB driver&#8217;s interrupt handler can&#8217;t preempt your trading thread if your thread has higher priority.</p>
      <p>
          <a href="https://lucisqr.substack.com/p/the-preempt_rt-surprise-why-isolation">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Citadel Securities Presents: The C++26 Sales Pitch]]></title><description><![CDATA[Herb Sutter &#8212; long-time ISO C++ committee chair, principal author of Exceptional C++ &#8212; joined Citadel as a Technical Fellow on November 11, 2024.]]></description><link>https://lucisqr.substack.com/p/citadel-securities-presents-the-c26</link><guid isPermaLink="false">https://lucisqr.substack.com/p/citadel-securities-presents-the-c26</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Fri, 01 May 2026 05:21:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Herb Sutter</strong> &#8212; long-time ISO C++ committee chair, principal author of Exceptional C++ &#8212; joined Citadel as a Technical Fellow on November 11, 2024. Eighteen months later, his employer is releasing branded, polished marketing content with the ISO C++ committee chair as the on-screen spokesperson, pitching C++26 to a developer audience.<br><br>The previous fact-check on this site &#8212; published two months ago, after Sutter's March 2026 C++26 Is Done keynote in London-Croydon &#8212; concluded that he was "mostly correct and rhetorically overconfident, delivered by a partisan in a room of partisans." The keynote got most of the facts right. It oversold the conclusions. It earned its keep on the performance-per-watt thesis, the CWE Top 25 analysis, and the AI-as-cost-shift framing. It overshot on the Nvidia "first CPU" line and the implicit declaration of victory on memory safety. That is a fair-and-balanced fact-check.<br><br>This piece is a different piece. The Citadel video isn't the keynote. The same speaker, two months later, in a different setting, makes different claims, drops different hedges, and foregrounds different features. <br><br>Reading the two side by side is the most useful exercise this author can offer.<br><br>Article - https://hftuniversity.com/post/citadel-securities-presents-the-c-26-sales-pitch <br>Article is free to read but you need to login first - to keep the bots away.<br><strong><a href="https://www.linkedin.com/search/results/all/?keywords=%23cpp&amp;origin=HASH_TAG_FROM_FEED">#cpp</a></strong> <strong><a href="https://www.linkedin.com/search/results/all/?keywords=%23cplusplus&amp;origin=HASH_TAG_FROM_FEED">#cplusplus</a></strong> <strong><a href="https://www.linkedin.com/search/results/all/?keywords=%23programming&amp;origin=HASH_TAG_FROM_FEED">#programming</a></strong> <strong><a href="https://www.linkedin.com/search/results/all/?keywords=%23citadel&amp;origin=HASH_TAG_FROM_FEED">#citadel</a></strong></p>]]></content:encoded></item><item><title><![CDATA[When "Modern C++" su... ahem, returns std::unexpected{BadTimings}.]]></title><description><![CDATA[Alexis King's "Parse, Don't Validate" is making the rounds on Reddit.]]></description><link>https://lucisqr.substack.com/p/when-modern-c-su-ahem-returns-stdunexpectedbadti</link><guid isPermaLink="false">https://lucisqr.substack.com/p/when-modern-c-su-ahem-returns-stdunexpectedbadti</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Thu, 30 Apr 2026 03:59:53 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><br><br>Alexis King's "Parse, Don't Validate" is making the rounds on Reddit. Its discipline says invalid input shouldn't be representable in the parsed type. Beautiful in Haskell, beautiful in a date-of-birth toy parser. What happens when the spec demands you keep malformed messages and forward them flagged &#8212; like every market-data protocol actually does?<br><br>I just did what every nerd would do - I built five FIX parsers &#8212; Rodriguez's four C++ eras (98 / 11-exceptions / 17-optional / 23-expected) plus a deliberately na&#239;ve baseline &#8212; and ran them on the HFTU Challenge 09 workload. Every cycle, every instruction, every malloc counted. Pinned cores. 11 runs per cell.<br><br>One of them is much faster than the other four. It is not the one you'd guess from looking at the syntax. And the reason isn't what most engineers' first guess would suggest.<br><br>Full measurement, disassembly diffs, and an LD_PRELOAD malloc audit in the post: <a href="https://hftuniversity.com/post/parse-don-t-validate-through-a-fix-feed-where-c-98-wins">https://hftuniversity.com/post/parse-don-t-validate-through-a-fix-feed-where-c-98-wins</a><br><br>Post is free to read but requires login to keep the pesky Ai bots away.<br><strong><a href="https://www.linkedin.com/search/results/all/?keywords=%23cpp&amp;origin=HASH_TAG_FROM_FEED">#cpp</a></strong> <strong><a href="https://www.linkedin.com/search/results/all/?keywords=%23cplusplus&amp;origin=HASH_TAG_FROM_FEED">#cplusplus</a></strong> <strong><a href="https://www.linkedin.com/search/results/all/?keywords=%23programming&amp;origin=HASH_TAG_FROM_FEED">#programming</a></strong></p>]]></content:encoded></item><item><title><![CDATA[L1 Cache Doesn't Care Which dtoa You Picked]]></title><description><![CDATA[When Benchmarks Measure Scenarios That Never Happen]]></description><link>https://lucisqr.substack.com/p/l1-cache-doesnt-care-which-dtoa-you</link><guid isPermaLink="false">https://lucisqr.substack.com/p/l1-cache-doesnt-care-which-dtoa-you</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Tue, 28 Apr 2026 10:25:09 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!6iHp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4dcfa033-6beb-4645-8861-860ea8ea84c4_1146x365.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A few weeks ago I published <a href="https://lucisqr.substack.com/p/googles-v8-javascript-engine-just">a piece on the fifty-year history of float-to-string conversion</a> -- from Steele and White&#8217;s Dragon4 in 1971 through Dragonbox in 2024. The practical advice was simple: use &#8230;</p>
      <p>
          <a href="https://lucisqr.substack.com/p/l1-cache-doesnt-care-which-dtoa-you">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Stop Chasing Cache Misses in perf — Find Them Before You Compile]]></title><description><![CDATA[Your Structs Are Bleeding Nanoseconds and You Don&#8217;t Even Know It]]></description><link>https://lucisqr.substack.com/p/stop-chasing-cache-misses-in-perf</link><guid isPermaLink="false">https://lucisqr.substack.com/p/stop-chasing-cache-misses-in-perf</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Sat, 25 Apr 2026 13:44:45 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every latency-sensitive shop has the same workflow. You write code, it goes to production, someone notices the P99 drifting, and then you spend three days in <code>perf record</code> trying to figure out which struct is ping-ponging across cores. By the time you&#8217;ve confirmed it&#8217;s <strong>false sharing in your sequence tracker</strong>, you&#8217;ve already shipped the bug, the traders are annoyed, and your fix is going through a rushed review cycle.</p><p>The fundamental problem with runtime profilers is that they require runtime. You need load, you need the right access patterns, and you need the problem to actually manifest in your profiling window. A false sharing issue that only appears under specific market conditions &#8212; say, when two feeds update simultaneously &#8212; might never show up in your Tuesday afternoon perf session. But it&#8217;s there, lurking in the struct layout, waiting for the <strong>MESI protocol to ruin your day</strong> during the opening auction.</p><p><code>perf</code>, VTune, <code>cachegrind</code> &#8212; these tools answer the question &#8220;what is slow right now?&#8221; The question they can&#8217;t answer is &#8220;what structural patterns in my code will be slow when the conditions are right?&#8221; </p><p></p><p><a href="https://hftuniversity.com/post/stop-chasing-cache-misses-in-perf">Article continues on HFT University</a></p>]]></content:encoded></item><item><title><![CDATA[The Sutter Keynote Fact-Check: What Survives Primary Sources, What Doesn't]]></title><description><![CDATA[Herb Sutter just gave a C++26 victory-lap keynote where he was the celebrant at his own party.]]></description><link>https://lucisqr.substack.com/p/the-sutter-keynote-fact-check-what</link><guid isPermaLink="false">https://lucisqr.substack.com/p/the-sutter-keynote-fact-check-what</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Thu, 23 Apr 2026 03:56:43 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Herb Sutter just gave a C++26 victory-lap keynote where he was the celebrant at his own party. Half the room walked out convinced C++ has permanently won the memory-safety, power-efficiency and AI debates of the last five years.</p><p>I went through the talk claim by claim and pulled the source documents. Some of it survives. A fair bit doesn&#8217;t &#8212; including a flat-wrong &#8220;Nvidia ships its first CPU&#8221; line, a slightly massaged 79% CrowdStrike stat, and a &#8220;Twitter still works&#8221; hand-wave that an HFT audience should never let pass.</p><p>The good news for those of us shipping latency-sensitive C++: the macro thesis on power and performance-per-watt is real, and the ACM Queue paper showing 0.3% overhead for libc++ hardening at Google scale is the single most actionable number in the entire keynote.</p><p>The full fact-check, what to keep, what to discount, and four things HFT shops should do Monday morning:</p><p>Article is free for logged in users.</p><p><a href="https://hftuniversity.com/post/let-s-be-real-about-herb-sutter-s-c-26-victory-lap">https://hftuniversity.com/post/let-s-be-real-about-herb-sutter-s-c-26-victory-lap </a></p>]]></content:encoded></item><item><title><![CDATA[Stop Vibing, Start Measuring: Real Best Practices for AI-Assisted Development]]></title><description><![CDATA[Jason Turner recently gave a talk at a C++ conference about best practices for AI tool use.]]></description><link>https://lucisqr.substack.com/p/stop-vibing-start-measuring-real</link><guid isPermaLink="false">https://lucisqr.substack.com/p/stop-vibing-start-measuring-real</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Mon, 20 Apr 2026 11:55:38 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Jason Turner recently gave a talk at a C++ conference about best practices for AI tool use. Given that most of us are now either mandated or strongly encouraged to use these tools, his timing couldn&#8217;&#8230;</p>
      <p>
          <a href="https://lucisqr.substack.com/p/stop-vibing-start-measuring-real">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Remember the Vasa: When C++ Advocacy Becomes Dangerous]]></title><description><![CDATA[A response to &#8220;Designated Initializers, the best feature of C++20&#8221;]]></description><link>https://lucisqr.substack.com/p/remember-the-vasa-when-c-advocacy</link><guid isPermaLink="false">https://lucisqr.substack.com/p/remember-the-vasa-when-c-advocacy</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Fri, 17 Apr 2026 11:47:59 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>On August 10, 1628, the Swedish warship Vasa set sail from Stockholm harbor on its maiden voyage. Twenty minutes later, it lay on the seafloor. The ship had been overloaded with cannons, ornate sculp&#8230;</p>
      <p>
          <a href="https://lucisqr.substack.com/p/remember-the-vasa-when-c-advocacy">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Anatomy of Quant Snake Oil: A Technical Refutation]]></title><description><![CDATA[A recent Substack article titled &#8220;Building micro-trading machines&#8221; wraps fundamental technical errors in scientific-sounding language&#8212;and potentially generates substantial revenue doing so.]]></description><link>https://lucisqr.substack.com/p/the-anatomy-of-quant-snake-oil-a</link><guid isPermaLink="false">https://lucisqr.substack.com/p/the-anatomy-of-quant-snake-oil-a</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Tue, 14 Apr 2026 14:58:42 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A recent Substack article titled &#8220;Building micro-trading machines&#8221; wraps <strong>fundamental technical errors</strong> in scientific-sounding language&#8212;and potentially generates substantial revenue doing so. The presentation looks sophisticated. The content is wrong.</p><p>Rather than just critique, I ran the article&#8217;s code and benchmarked the claims. The results are illuminating.</p><p><a href="https://hftuniversity.com/post/the-anatomy-of-quant-snake-oil-a">Complete article in HFT University</a></p>]]></content:encoded></item><item><title><![CDATA[C++26 Contracts: Zero Cost, Zero Gain]]></title><description><![CDATA[Part Three: Inside the Compiler]]></description><link>https://lucisqr.substack.com/p/c26-contracts-zero-cost-zero-gain</link><guid isPermaLink="false">https://lucisqr.substack.com/p/c26-contracts-zero-cost-zero-gain</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Sat, 11 Apr 2026 23:37:06 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Part 2, we saw that contracts with <code>ignore</code> semantic have essentially zero overhead. Good. But we also found that <code>__builtin_assume()</code> produces dramatically faster code than contracts expressing the same condition. The queue benchmark showed <strong>96% speedup</strong> with assume hints versus zero improvement with contracts.</p><p>This part is about understanding why. The investigation took me through Clang source code, LLVM optimization passes, and eventually to a series of C++ committee papers that reveal an intentional design decision. <strong>Contracts and assumes are deliberately kept separate.</strong></p><p><a href="https://hftuniversity.com/post/c26-contracts-zero-cost-zero-gain3">Continue article on HFT University</a></p>]]></content:encoded></item><item><title><![CDATA[C++26 Contracts: Zero Cost/Zero Gain]]></title><description><![CDATA[Part Two - The Benchmark Results]]></description><link>https://lucisqr.substack.com/p/c26-contracts-zero-costzero-gain</link><guid isPermaLink="false">https://lucisqr.substack.com/p/c26-contracts-zero-costzero-gain</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Wed, 08 Apr 2026 23:35:36 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In Part 1 we built a contracts-enabled Clang and set up the benchmark infrastructure. Now let&#8217;s see what happens when we actually measure contract overhead on HFT-style code.</p><p>The executive summary is this: <strong>contracts with </strong><code>ignore</code><strong> semantic have near-zero overhead</strong>. Sometimes they&#8217;re faster than no checks at all. But the real surprise came from comparing contracts against manual validation&#8212;that&#8217;s where the dramatic numbers live.</p><p><a href="https://hftuniversity.com/post/c26-contracts-zero-costzero-gain2">Article continues&#8230;</a></p>]]></content:encoded></item><item><title><![CDATA[Eviscerated by Rust: Overcoming C++'s 58x Standard Library Handicap]]></title><description><![CDATA[The C++ standard library's default containers are a performance disaster.]]></description><link>https://lucisqr.substack.com/p/eviscerated-by-rust-overcoming-cs</link><guid isPermaLink="false">https://lucisqr.substack.com/p/eviscerated-by-rust-overcoming-cs</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Wed, 08 Apr 2026 02:21:22 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/fb369fbc-2633-4c01-926d-f5496f2b72c0_275x183.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><br>The C++ standard library's default containers are a performance disaster. Not a minor inconvenience. Not a "it depends on the workload" caveat. A 58x P99 latency penalty compared to Rust's standard library, on an identical order book workload, with the same seed, same venue, same CPU cores.</p><p>Or switch to Rust, where the standard library ships the right defaults and you don't need to know any of this. A junior Rust developer using HashMap, BTreeMap, and VecDeque &#8212; the first containers they'll find in any tutorial &#8212; gets 5,177 cycles P99 on a workload that punishes bad containers mercilessly. A junior C++ developer using the standard library gets 302,653.</p><p>That's not a skill gap. That's a standard library gap. And after 28 years of C++ standardization, the committee still hasn't closed it.</p><p><a href="https://hftuniversity.com/post/eviscerated-by-rust-58x-stdlib-handicap">Article is free for logged in users (log in with Google)</a></p><p></p>]]></content:encoded></item><item><title><![CDATA[A Rust SPSC Queue That "Beats Every C++ Implementation" — Let's Check]]></title><description><![CDATA[A recent LinkedIn post recently claimed a Rust SPSC queue that "beats every C++ implementation I could find." Not by a little &#8212; by 2-8x on burst workloads.]]></description><link>https://lucisqr.substack.com/p/a-rust-spsc-queue-that-beats-every</link><guid isPermaLink="false">https://lucisqr.substack.com/p/a-rust-spsc-queue-that-beats-every</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Tue, 07 Apr 2026 04:05:25 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A recent LinkedIn post recently claimed a Rust SPSC queue that "beats every C++ implementation I could find." Not by a little &#8212; by 2-8x on burst workloads. Bold claim. I love to roast bold claims though.<br><br>I took a deep look at the code and the benchmarks, then ran the queue through a proper two-thread benchmark on isolated cores alongside real C++ contenders - our <strong>TOP HFT UNIVERSITY</strong> ring buffers! What a carnage! Spoiler: it finished 2.4x behind the best C++ implementation, not ahead. <br><br>Here is why the original numbers were wrong, and what the real ones look like.<br><br><a href="https://hftuniversity.com/post/the-mantis-spsc-queue-a-case-study-in-how-not-to-benchmark">The post is free to read for logged in users</a> (log in with Google).</p><p>For all other articles, consider subscribing: <a href="https://hftuniversity.com/pricing">https://hftuniversity.com/pricing</a></p>]]></content:encoded></item><item><title><![CDATA[C++26 Contracts: Zero Cost, Zero Gains]]></title><description><![CDATA[Part One - Building the Beast]]></description><link>https://lucisqr.substack.com/p/c26-contracts-zero-cost-zero-gains</link><guid isPermaLink="false">https://lucisqr.substack.com/p/c26-contracts-zero-cost-zero-gains</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Sun, 05 Apr 2026 11:33:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!eUd2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>So you&#8217;ve heard about C++26 contracts. The committee finally shipped something that promises <strong>zero-cost validation</strong> in production while catching bugs in development. Sounds too good to be true, right?</p><p>I had to find out for myself. What follows is a journey through building a contracts-enabled compiler, running real benchmarks on HFT-style code, and discovering some uncomfortable truths about what contracts can and cannot do for your hot paths.</p><div><hr></div><h2><strong>The State of Play (January 2026)</strong></h2><p>Here&#8217;s the thing nobody tells you upfront: <strong>C++26 contracts are not in mainline GCC or Clang</strong>. Not yet. If you want to actually test this stuff, you need to build an experimental compiler fork. The standards committee ratified P2900R14, but compiler vendors are still implementing it.</p><p>GCC has a tracking issue at PR119061. Clang has Eric Fiselier&#8217;s experimental branch. That&#8217;s what we&#8217;re working with.</p><p>This means everything I&#8217;m about to show you comes with the usual &#8220;experimental implementation&#8221; caveats. But the semantics are locked in, and the performance characteristics we measured should hold when this lands in production compilers.</p><div><hr></div><h2><strong>What You Actually Get</strong></h2><p>Before we dive into building compilers, let me show you what contracts look like in real code. The syntax is clean:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-hNZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-hNZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png 424w, https://substackcdn.com/image/fetch/$s_!-hNZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png 848w, https://substackcdn.com/image/fetch/$s_!-hNZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png 1272w, https://substackcdn.com/image/fetch/$s_!-hNZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-hNZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png" width="1142" height="278" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/89341741-502f-47b9-8519-1b60767a179e_1142x278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:278,&quot;width&quot;:1142,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 1&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 1" title="Code Block 1" srcset="https://substackcdn.com/image/fetch/$s_!-hNZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png 424w, https://substackcdn.com/image/fetch/$s_!-hNZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png 848w, https://substackcdn.com/image/fetch/$s_!-hNZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png 1272w, https://substackcdn.com/image/fetch/$s_!-hNZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89341741-502f-47b9-8519-1b60767a179e_1142x278.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Three things happen here. The <code>pre</code> clause declares a precondition&#8212;the caller&#8217;s responsibility. The <code>post</code> clause declares a postcondition where <code>r</code> binds to the return value. Inside the function you can use <code>contract_assert</code> for internal invariants.</p><p>The magic is in <strong>evaluation semantics</strong>. You compile with a flag that controls what happens:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!eUd2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!eUd2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png 424w, https://substackcdn.com/image/fetch/$s_!eUd2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png 848w, https://substackcdn.com/image/fetch/$s_!eUd2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png 1272w, https://substackcdn.com/image/fetch/$s_!eUd2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!eUd2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png" width="820" height="314" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:314,&quot;width&quot;:820,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Table 1&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Table 1" title="Table 1" srcset="https://substackcdn.com/image/fetch/$s_!eUd2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png 424w, https://substackcdn.com/image/fetch/$s_!eUd2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png 848w, https://substackcdn.com/image/fetch/$s_!eUd2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png 1272w, https://substackcdn.com/image/fetch/$s_!eUd2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F416ab660-41a1-4f9b-9137-b0782897d20e_820x314.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>Same source code, different behavior at compile time. In production you get zero overhead. In testing you catch violations. This is the promise.</p><div><hr></div><h2><strong>Building Your Own Contracts Compiler</strong></h2><p>The canonical way to test native contracts is through Eric Fiselier&#8217;s fork&#8212;the same one powering Compiler Explorer&#8217;s contracts compilers. Here&#8217;s the full process, pain points included.</p><p>First, the dependencies. On Ubuntu/Debian:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hhuq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hhuq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png 424w, https://substackcdn.com/image/fetch/$s_!hhuq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png 848w, https://substackcdn.com/image/fetch/$s_!hhuq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png 1272w, https://substackcdn.com/image/fetch/$s_!hhuq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hhuq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png" width="1146" height="212" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:212,&quot;width&quot;:1146,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 2&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 2" title="Code Block 2" srcset="https://substackcdn.com/image/fetch/$s_!hhuq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png 424w, https://substackcdn.com/image/fetch/$s_!hhuq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png 848w, https://substackcdn.com/image/fetch/$s_!hhuq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png 1272w, https://substackcdn.com/image/fetch/$s_!hhuq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc4d6d680-e38e-4e6b-a794-8ecc0cec4b0c_1146x212.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Then clone the experimental branch. Use <code>--depth 1</code> unless you want to wait an hour for git history:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1m7j!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1m7j!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png 424w, https://substackcdn.com/image/fetch/$s_!1m7j!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png 848w, https://substackcdn.com/image/fetch/$s_!1m7j!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png 1272w, https://substackcdn.com/image/fetch/$s_!1m7j!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1m7j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png" width="1143" height="190" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:190,&quot;width&quot;:1143,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 3&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 3" title="Code Block 3" srcset="https://substackcdn.com/image/fetch/$s_!1m7j!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png 424w, https://substackcdn.com/image/fetch/$s_!1m7j!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png 848w, https://substackcdn.com/image/fetch/$s_!1m7j!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png 1272w, https://substackcdn.com/image/fetch/$s_!1m7j!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bce1f33-a579-4edc-924b-7e9ea51b2df0_1143x190.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>The CMake configuration is straightforward but the choices matter:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TuEi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TuEi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png 424w, https://substackcdn.com/image/fetch/$s_!TuEi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png 848w, https://substackcdn.com/image/fetch/$s_!TuEi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png 1272w, https://substackcdn.com/image/fetch/$s_!TuEi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TuEi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png" width="1145" height="278" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:278,&quot;width&quot;:1145,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 4&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 4" title="Code Block 4" srcset="https://substackcdn.com/image/fetch/$s_!TuEi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png 424w, https://substackcdn.com/image/fetch/$s_!TuEi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png 848w, https://substackcdn.com/image/fetch/$s_!TuEi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png 1272w, https://substackcdn.com/image/fetch/$s_!TuEi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff37042d4-c492-4486-b6c4-f2d422e9bcbb_1145x278.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Build time is 30-60 minutes</strong> on a modern machine. The <code>LLVM_PARALLEL_LINK_JOBS=2</code> matters&#8212;without it, linking will eat all your RAM and the OOM killer will ruin your day.</p><div><hr></div><h2><strong>The First Surprise: Missing Runtime Handler</strong></h2><p>After building the compiler, I tried to compile some benchmark code with <code>enforce</code> semantic. Linker error:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!VoP4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!VoP4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png 424w, https://substackcdn.com/image/fetch/$s_!VoP4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png 848w, https://substackcdn.com/image/fetch/$s_!VoP4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png 1272w, https://substackcdn.com/image/fetch/$s_!VoP4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!VoP4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png" width="1146" height="168" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:168,&quot;width&quot;:1146,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 5&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 5" title="Code Block 5" srcset="https://substackcdn.com/image/fetch/$s_!VoP4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png 424w, https://substackcdn.com/image/fetch/$s_!VoP4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png 848w, https://substackcdn.com/image/fetch/$s_!VoP4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png 1272w, https://substackcdn.com/image/fetch/$s_!VoP4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1927658b-8a6d-4c70-9460-12bcd307308a_1146x168.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Turns out the compiler generates calls to a runtime handler when contracts need checking, but <strong>the runtime library doesn&#8217;t provide it</strong>. You need to write your own:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!g6zS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!g6zS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png 424w, https://substackcdn.com/image/fetch/$s_!g6zS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png 848w, https://substackcdn.com/image/fetch/$s_!g6zS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png 1272w, https://substackcdn.com/image/fetch/$s_!g6zS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!g6zS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png" width="1145" height="584" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:584,&quot;width&quot;:1145,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 6&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 6" title="Code Block 6" srcset="https://substackcdn.com/image/fetch/$s_!g6zS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png 424w, https://substackcdn.com/image/fetch/$s_!g6zS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png 848w, https://substackcdn.com/image/fetch/$s_!g6zS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png 1272w, https://substackcdn.com/image/fetch/$s_!g6zS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec714502-2d79-45f8-9d80-d4621346cf3e_1145x584.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>This is the kind of implementation detail you only discover by doing. The committee specified the behavior but left the ABI to implementations, and Fiselier&#8217;s fork expects you to provide the handler.</p><div><hr></div><h2><strong>The HFT Problem Contracts Solve</strong></h2><p>Why do we even care about this? Let me show you a pattern that exists in every trading system I&#8217;ve worked on:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!R4XV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!R4XV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png 424w, https://substackcdn.com/image/fetch/$s_!R4XV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png 848w, https://substackcdn.com/image/fetch/$s_!R4XV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png 1272w, https://substackcdn.com/image/fetch/$s_!R4XV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!R4XV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png" width="1140" height="278" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:278,&quot;width&quot;:1140,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 7&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 7" title="Code Block 7" srcset="https://substackcdn.com/image/fetch/$s_!R4XV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png 424w, https://substackcdn.com/image/fetch/$s_!R4XV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png 848w, https://substackcdn.com/image/fetch/$s_!R4XV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png 1272w, https://substackcdn.com/image/fetch/$s_!R4XV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5a54167e-5f76-4c75-ada0-c923facaeab1_1140x278.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Three branches on the hot path. Each one pollutes the branch predictor. The checks are almost always redundant because callers are well-behaved. But removing them is unsafe&#8212;one bad call and you&#8217;re looking at a Knight Capital situation.</p><p>Contracts let you have it both ways:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mfQL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mfQL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png 424w, https://substackcdn.com/image/fetch/$s_!mfQL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png 848w, https://substackcdn.com/image/fetch/$s_!mfQL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png 1272w, https://substackcdn.com/image/fetch/$s_!mfQL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mfQL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png" width="1140" height="321" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:321,&quot;width&quot;:1140,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 8&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 8" title="Code Block 8" srcset="https://substackcdn.com/image/fetch/$s_!mfQL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png 424w, https://substackcdn.com/image/fetch/$s_!mfQL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png 848w, https://substackcdn.com/image/fetch/$s_!mfQL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png 1272w, https://substackcdn.com/image/fetch/$s_!mfQL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62e21f5d-d49d-4ea7-9f35-7386cc12c2c1_1140x321.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>With <code>ignore</code> semantic, those preconditions generate no code whatsoever. With <code>enforce</code> semantic during testing, every violation triggers your handler. Same source, different compilation targets.</p><div><hr></div><h2><strong>What I Set Out to Measure</strong></h2><p>The benchmark suite I built covers 16 HFT-style scenarios. The core question for each one: <strong>what&#8217;s the overhead of contracts compared to manual if-checks and compared to no checks at all?</strong></p><p>The scenarios include:</p><ul><li><p>Order book bounds checking</p></li><li><p>Division safety (divide by zero protection)</p></li><li><p>Queue invariant validation (ring buffers)</p></li><li><p>Market data integrity checks</p></li><li><p>Risk manager pre-trade validation</p></li><li><p>Black-Scholes input/output validation</p></li><li><p>SIMD alignment verification</p></li><li><p>Lock-free algorithm invariants</p></li><li><p>Protocol parsing validation</p></li></ul><p>Each scenario has three variants:</p><ol><li><p><strong>No checks</strong> (baseline&#8212;undefined behavior if invariants violated)</p></li><li><p><strong>Manual if-checks</strong> (traditional defensive programming)</p></li><li><p><strong>With contracts</strong> (C++26 contracts with configurable semantic)</p></li></ol><p>We also tested an additional variant using <code>__builtin_assume()</code> to see whether compiler hints provide optimization benefits&#8212;a question that became far more interesting than I initially expected.</p><div><hr></div><h2><strong>Setting Up the Benchmark Infrastructure</strong></h2><p>The benchmark harness uses high-resolution timing with warmup runs and statistical aggregation. Nothing fancy, but it works:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HUvL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HUvL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png 424w, https://substackcdn.com/image/fetch/$s_!HUvL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png 848w, https://substackcdn.com/image/fetch/$s_!HUvL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png 1272w, https://substackcdn.com/image/fetch/$s_!HUvL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HUvL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png" width="1143" height="453" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:453,&quot;width&quot;:1143,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Code Block 9&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="Code Block 9" title="Code Block 9" srcset="https://substackcdn.com/image/fetch/$s_!HUvL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png 424w, https://substackcdn.com/image/fetch/$s_!HUvL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png 848w, https://substackcdn.com/image/fetch/$s_!HUvL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png 1272w, https://substackcdn.com/image/fetch/$s_!HUvL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89fb57ac-ebaa-4bd3-a8bb-dc8ae019acf9_1143x453.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The <code>do_not_optimize</code> barrier prevents the compiler from optimizing away the computation entirely. <strong>Every benchmark lies</strong> in some way, but these lies are consistent across all variants, which is what matters for comparison.</p><p>The test machine is a dedicated benchmark server (aorus) running the contracts-enabled Clang 22.0 with <code>-O3 -march=native</code>. All benchmarks run with CPU frequency scaling disabled.</p><div><hr></div><h2><strong>Coming Up: The Results That Surprised Me</strong></h2><p>In Part 2, we&#8217;ll look at the actual benchmark numbers. Spoiler: contracts with <code>ignore</code> semantic show essentially <strong>zero overhead</strong>&#8212;sometimes they&#8217;re even faster than the no-checks baseline. But the story gets more interesting when we compare <code>enforce</code> semantic and start asking whether contracts provide optimization hints.</p><p>The data revealed something the committee papers don&#8217;t emphasize: the gap between what contracts <em>could</em> do for optimization and what they <em>actually</em> do in current implementations. That investigation led me deep into the Clang source code, and what I found there explains a lot about the C++ standards committee&#8217;s philosophy on contracts.</p><p>But that&#8217;s for Part 3. First, let&#8217;s see the numbers.</p><div><hr></div><p><em>Next: <a href="https://file+.vscode-resource.vscode-cdn.net/articles/part2-benchmark-results.md">Part 2 - The Benchmark Results</a></em></p>]]></content:encoded></item><item><title><![CDATA[The 80/20 of CPU Optimization: What Actually Works on Every Chip Since 2008]]></title><description><![CDATA[Two decades analyzing instruction latencies reveals a counterintuitive truth: the most reliable optimizations are the ones that haven&#8217;t changed. While RDTSC latencies swing by 4,600% and MFENCE costs&#8230;]]></description><link>https://lucisqr.substack.com/p/the-8020-of-cpu-optimization-what</link><guid isPermaLink="false">https://lucisqr.substack.com/p/the-8020-of-cpu-optimization-what</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Thu, 02 Apr 2026 14:27:56 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!wcny!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb4a43847-a312-4b3c-a44b-1c40b2d83655_1146x387.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Two decades analyzing instruction latencies reveals a counterintuitive truth: <strong>the most reliable optimizations are the ones that haven&#8217;t changed</strong>. While RDTSC latencies swing by 4,600% and MFENCE costs&#8230;</p>
      <p>
          <a href="https://lucisqr.substack.com/p/the-8020-of-cpu-optimization-what">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Lock-Free Is a Lie (When You Don’t Count the Fences)]]></title><description><![CDATA[Lock-free data structures are supposed to be fast.]]></description><link>https://lucisqr.substack.com/p/lock-free-is-a-lie-when-you-dont</link><guid isPermaLink="false">https://lucisqr.substack.com/p/lock-free-is-a-lie-when-you-dont</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Sun, 29 Mar 2026 17:29:41 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!opKu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbe2a3551-6414-4ce3-b505-3de3310de07a_1146x300.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lock-free data structures are supposed to be fast. No mutexes, no blocking, no waiting for other threads. The literature talks about wait-free guarantees and theoretical throughput bounds. What the l&#8230;</p>
      <p>
          <a href="https://lucisqr.substack.com/p/lock-free-is-a-lie-when-you-dont">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Important: Content Moving to hftuniversity.com]]></title><description><![CDATA[Starting this week, all new articles and course content will be published primarily on hftuniversity.com. Here&#8217;s why and what it means for you.]]></description><link>https://lucisqr.substack.com/p/important-content-moving-to-hftuniversitycom</link><guid isPermaLink="false">https://lucisqr.substack.com/p/important-content-moving-to-hftuniversitycom</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Sat, 28 Mar 2026 05:23:11 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Starting this week, all new articles and course content will be published primarily on<strong><a href="https://hftuniversity.com/"> hftuniversity.com</a></strong>. Here&#8217;s why and what it means for you.</p><p><strong>Why the change</strong></p><p>Substack does not handle <a href="https://gist.github.com/HFTrader/29ff234a29d4396ace44f8ab4d9438f8">VAT for international subscribers</a>. As our subscriber base has grown to 115+ countries, this creates a compliance gap we can no longer ignore. Our payment processors on hftuniversity.com (Paddle and LemonSqueezy) handle VAT automatically for every country &#8212; receipts, tax IDs, everything.</p><p><strong>What changes for you</strong></p><ul><li><p><strong>Paid Substack subscribers</strong>: Your account is synced daily to hftuniversity.com. You already have full access there &#8212; log in with the same email. All articles, challenges, and badges are available. Nothing breaks.</p></li><li><p><strong>Paddle / LemonSqueezy subscribers</strong>: Your articles are on hftuniversity.com only. You actually get a better reading experience &#8212; full-width code blocks, syntax highlighting, and no Substack sidebar clutter.</p></li><li><p><strong>Free Substack subscribers</strong>: You&#8217;ll continue to receive free posts here. Premium content will link to hftuniversity.com.</p></li></ul><p><strong>What stays the same</strong></p><ul><li><p>The newsletter email still comes from Substack (for now)</p></li><li><p>Past articles remain available on hftuniversity.com primarily. </p></li><li><p>Your subscription price doesn&#8217;t change</p></li><li><p>C++ challenges, badges, and rankings are unaffected (they were always on hftuniversity.com)</p></li></ul><p><strong>What&#8217;s better on hftuniversity.com</strong></p><ul><li><p>Full-width code blocks with proper syntax highlighting</p></li><li><p>C++ challenge integration &#8212; your benchmark scores appear alongside articles</p></li><li><p>Forum for discussion (instead of Substack&#8217;s limited comments)</p></li><li><p>Verified badges on your profile</p></li></ul><p>If you have any questions,  reach out at <a href="mailto:support@vitorian.com">support@vitorian.com</a>.</p><p>&#8212; Henrique</p>]]></content:encoded></item><item><title><![CDATA[glibc’s Cleanup Year: What Deleting 20 Years of Code Did for Performance]]></title><description><![CDATA[Somewhere around December 2025, a series of commits landed in glibc that did something nobody expected: the entire fastbin infrastructure got deleted.]]></description><link>https://lucisqr.substack.com/p/glibcs-cleanup-year-what-deleting</link><guid isPermaLink="false">https://lucisqr.substack.com/p/glibcs-cleanup-year-what-deleting</guid><dc:creator><![CDATA[Henrique Bucher]]></dc:creator><pubDate>Wed, 25 Mar 2026 12:35:43 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!tJCI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7a9a2081-c4de-4045-ab66-1752bab755b7_559x559.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Somewhere around December 2025, a series of commits landed in glibc that did something nobody expected: the entire fastbin infrastructure got deleted. Not deprecated, not hidden behind a flag &#8212; delet&#8230;</p>
      <p>
          <a href="https://lucisqr.substack.com/p/glibcs-cleanup-year-what-deleting">
              Read more
          </a>
      </p>
   ]]></content:encoded></item></channel></rss>