DEV Community

Cover image for Anthropic Messages API Rust Rewrite Cuts CPU 70% — Dual-Track WASAPI Still Owns the Overlay Floor
devs
devs

Posted on

Anthropic Messages API Rust Rewrite Cuts CPU 70% — Dual-Track WASAPI Still Owns the Overlay Floor

On 25 November 2026 Anthropic published the engineering post on migrating the Messages API from Python to Rust. Traffic had grown roughly 1,800× since early 2024. Claude wrote a first version of the core request path in about a week. The hard part was verification: shadowing live production traffic against the Python service, fixing divergences, and shipping without downtime. Result: ~70% less CPU per request, >80% less memory, and ~20% lower median time-to-first-token on Claude Code requests.

Rust programming language logo

That is a clean infrastructure win. Lower CPU and memory per request means denser packing and less headroom pressure on the API tier. The TTFT improvement is real for agents that wait on a full model turn. It does not move the floor if the agent is also supposed to produce short, timely suggestions while a technical interview or sales call is happening live in another language on Windows.

Where the delay actually lives on Windows

A usable dual-track overlay still needs two clean PCM streams that stay separate:

  1. Local microphone — what you say.
  2. Loopback of the render endpoint — what the remote party says through Teams, Zoom, Meet, or the browser.

Both must stay in shared-mode WASAPI so the call client keeps the device. Exclusive mode would break the call. The Windows Audio Engine (audiodg.exe + audioeng.dll) mixes, applies any enabled communications enhancements or vendor APOs, and delivers buffers on a fixed period. Typical shared-mode period is 10 ms; the engine often ignores smaller requests under load.

Audio waveforms diagram

Rough additive budget once samples leave the callback (modern laptop, enhancements off):

Stage Typical cost
WASAPI shared period 10 ms
Callback → lock-free SPSC ring + format convert 1–3 ms
Resample to 16 kHz mono + lightweight VAD 2–5 ms
Streaming STT first partial (local or remote) 40–150 ms
Optional local polish / suggestion model 20–80 ms
Overlay paint <16 ms

Even if the translation or suggestion model itself returns usable text in a few hundred milliseconds, the capture period and the first partial still dominate the user-visible lag. A cloud API that now starts tokens 20% faster is fine for a backend orchestration loop; for a tight overlay that should show a short suggestion while the other person is still talking, you need the partials much earlier.

Practical capture shape that ships

// Shared-mode capture client (mic or loopback).
// Callback does nothing but copy into a lock-free SPSC ring.
// Consumer thread owns resampling, VAD, and the STT or model call.

HRESULT hr = pAudioClient->Initialize(
    AUDCLNT_SHAREMODE_SHARED,
    flags,  // AUDCLNT_STREAMFLAGS_LOOPBACK for render endpoint
    hnsPeriod,  // request 10 ms or smaller; engine may ignore
    0, mixFormat, NULL);

// In the callback:
// Copy GetBuffer samples into ring, ReleaseBuffer, return S_OK.
// Zero allocations, zero model work on the audio thread.
Enter fullscreen mode Exit fullscreen mode

From the ring you can feed:

  • A streaming STT (AssemblyAI-style, Deepgram, or local faster-whisper / Whisper.cpp / Windows ML Speech Recognition Task).
  • A small local GGUF for translation polish or short suggestion generation.
  • Or, if you own the whole stack, an end-to-end model that still has to wait on the same capture path.

The Rust rewrite is useful if your local agent has a large set of suggestion templates or tool schemas and you want lower host cost or faster turnaround on the cloud side. It does not shrink the 10 ms period or the time until the first usable partial leaves the audio engine.

Tradeoffs that actually matter for overlays

  • Shared vs exclusive: Shared is mandatory if the call app must keep the device. You live with the engine period and any residual APO latency.
  • Local vs remote STT: Local removes RTT and keeps audio on-device. Remote can be faster on pure model time but still waits on the same buffers plus network.
  • Partial quality: Aggressive first-partials are noisy. You usually want a short confirmation window or a cheap local polish model before painting a suggestion.
  • CPU budget: The 70% API win is irrelevant if your laptop is already thermal-throttling on dual WASAPI clients + resample + local STT + overlay.

Anthropic’s migration shows that verification against live traffic is now the bottleneck once agents write the bulk of the code. For a dual-track overlay the equivalent bottleneck is still the audio path: get the two streams clean, keep the callback trivial, and measure the first partial end-to-end before you optimize the model.

I'm building Talkaside, a Windows app for job interviews and calls in another language.
Drafted with AI assistance from this project's code and logs.

Top comments (0)