<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://adagradschool.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://adagradschool.com/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-11-25T13:25:29+05:30</updated><id>https://adagradschool.com/feed.xml</id><title type="html">adagradschool</title><subtitle>Essays and notes by Rohan Mishra.</subtitle><author><name>Rohan Mishra</name></author><entry><title type="html">rayfast: a faster, leaner launcher</title><link href="https://adagradschool.com/rayfast/" rel="alternate" type="text/html" title="rayfast: a faster, leaner launcher" /><published>2026-11-25T00:00:00+05:30</published><updated>2026-11-25T00:00:00+05:30</updated><id>https://adagradschool.com/rayfast</id><content type="html" xml:base="https://adagradschool.com/rayfast/"><![CDATA[<p>I was trying the alpha of <a href="https://ladybird.org">Ladybird</a> and noticed how little memory it used. The browser was using less memory than Raycast, which I mostly use to open other apps.</p>

<p>I use Raycast for a few things: hotkeys for common apps, opening apps by name, and short conversions like time zones, units and currency. I don’t use it to resize windows, and I don’t use its AI features. It was using about 230 MB.</p>

<p>I opened Codex and Claude Code and gave both the same task. The launcher had to:</p>

<ul>
  <li>meet those functional needs,</li>
  <li>have a UX similar to Raycast’s,</li>
  <li>use as little memory as possible when idle,</li>
  <li>use as little memory as possible when open,</li>
  <li>take as little time as possible from keypress to first render.</li>
</ul>

<p>Both kept iterating for a few hours. Codex built QuickKey and Claude built rayfast. Partway through, I gave each one the other’s benchmark results.</p>

<h2 id="benchmarks">Benchmarks</h2>

<p>Both were measured with the same tool, which Codex wrote. It posts the real shortcut and records the screen until the panel matches its finished frame, so the time includes key delivery, the window server and the display refresh. Runs alternated between apps on an M5 Mac.</p>

<table>
  <thead>
    <tr>
      <th> </th>
      <th style="text-align: right">Raycast</th>
      <th style="text-align: right">QuickKey (Codex)</th>
      <th style="text-align: right">rayfast (Claude)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Open after idle, median</td>
      <td style="text-align: right">95.3 ms</td>
      <td style="text-align: right">52.5 ms</td>
      <td style="text-align: right">50.1 ms</td>
    </tr>
    <tr>
      <td>Rapid reopen, median</td>
      <td style="text-align: right">60.6 ms</td>
      <td style="text-align: right">46.4 ms</td>
      <td style="text-align: right">49.2 ms</td>
    </tr>
    <tr>
      <td>Slowest open</td>
      <td style="text-align: right">127 ms</td>
      <td style="text-align: right">77.5 ms</td>
      <td style="text-align: right">61 ms</td>
    </tr>
    <tr>
      <td>Memory at rest</td>
      <td style="text-align: right">~180 MB</td>
      <td style="text-align: right">~14 MB</td>
      <td style="text-align: right">~12 MB</td>
    </tr>
  </tbody>
</table>

<p>QuickKey and rayfast are about even. About 37 ms of each open is the window server taking two 60 Hz refreshes to put a new window on screen, which neither app controls. Each app’s own work is a few milliseconds.</p>

<p>I now use rayfast on ⌘Space and have removed Raycast.</p>

<h2 id="how-rayfast-keeps-memory-and-latency-low">How rayfast keeps memory and latency low</h2>

<p>Claude found most of these by measuring with <code class="language-plaintext highlighter-rouge">footprint</code> and <code class="language-plaintext highlighter-rouge">vmmap</code> and turning one thing off at a time.</p>

<ul>
  <li><strong>Plain Objective-C.</strong> No Swift runtime, nibs, web views or Dock icon. The app is a single 167 KB binary.</li>
  <li><strong>Restarting after each use.</strong> After the window closes, the allocator still holds about 10 MB of fragmented memory. Four seconds after the launcher hides, rayfast calls <code class="language-plaintext highlighter-rouge">execv()</code> on itself. It keeps the same process ID and hotkeys and starts with a clean heap.</li>
  <li><strong><code class="language-plaintext highlighter-rouge">MallocSpaceEfficient=1</code>.</strong> This saves about 1 MB. macOS reads it only at process start, so rayfast sets it and re-execs once on launch.</li>
  <li><strong>No view draws.</strong> The open window used 84 MB. About 40 MB was a GPU memory pool that Core Animation gives any window larger than roughly 200×100 that draws through AppKit. The rest grew because drawing a colour gradient on a wide-colour display switched the window to 8-byte float pixels, doubling each buffer. rayfast instead draws each frame on the CPU into two 1-byte grayscale IOSurfaces (about 2.8 MB total) and assigns them to a layer. App icons and the logo are small separate colour layers. The open window now uses about 14 MB.</li>
  <li><strong>A separate caret layer.</strong> The caret blinks with a keyframe animation, so blinking doesn’t redraw the window.</li>
  <li><strong>Memory-mapped icon cache.</strong> Read-only file-backed pages don’t count toward the process footprint, so the 78 KB icon cache costs nothing at rest.</li>
  <li><strong>Currency rates via <code class="language-plaintext highlighter-rouge">/usr/bin/curl</code>.</strong> The networking stack is never loaded into the app.</li>
  <li><strong>A custom search field.</strong> <code class="language-plaintext highlighter-rouge">NSTextField</code> set up a full text system and cost about 30 ms on a cold open. A small view that handles text input itself is enough for one line and still supports IME and accented characters.</li>
  <li><strong>Showing the window once at startup.</strong> After launch and after each restart, rayfast draws the window and shows it once at zero opacity, off-screen, so macOS’s first-display work is already done.</li>
  <li><strong>Redrawing on hide.</strong> The empty launcher is redrawn right after it closes, so a keypress only has to put the window on screen. This reduced rayfast’s own share of each open from about 17 ms to about 3 ms.</li>
</ul>

<p>QuickKey uses a similar approach to latency: it stays running with the panel drawn and focused, and frees caches four seconds after it’s dismissed. It keeps one long-running process instead of restarting, which is why it uses a few MB more at rest.</p>

<h2 id="what-didnt-help">What didn’t help</h2>

<p>Removing the window shadow, changing the window level, forcing an early commit, keeping the window on screen while invisible and further allocator tuning made no measurable difference, so Claude removed them.</p>

<p>An earlier version of rayfast used about 4 MB at rest by loading the UI only when needed, but the first open took about 70 ms. For reference, a process that does nothing uses about 1 MB on macOS. I preferred faster opens, so that mode was removed.</p>

<h2 id="code">Code</h2>

<p>rayfast is MIT-licensed: <a href="https://github.com/adagradschool/rayfast">github.com/adagradschool/rayfast</a>. Run <code class="language-plaintext highlighter-rouge">make install</code> to install it and start it at login.</p>]]></content><author><name>Rohan Mishra</name></author><summary type="html"><![CDATA[Notes on rebuilding the parts of Raycast I use as a native macOS launcher, with two coding agents working on the same brief.]]></summary></entry></feed>