RC RANDOM CHAOS

100K Lines of Rust with AI: Building a Modern Paxos Engine in 3 Months

· via Hacker News

Original source

Learnings from 100K lines of Rust with AI (2025)

Hacker News →

An engineer rebuilt Azure’s Replicated State Library (RSL) — the multi-Paxos consensus backbone behind much of Azure — from scratch in Rust, writing roughly 130K lines in about six weeks and pushing throughput from 23K to 300K ops/sec on a laptop. The motivation was that the original RSL predates modern hardware realities: it lacks pipelining, NVM support, and RDMA awareness, all of which now constrain latency and throughput in Azure datacenters. The work leaned heavily on Claude Code and Codex CLI, with a second ChatGPT subscription added to dodge rate limits.

The most interesting technical claim is that correctness on something as subtle as Paxos came from AI-generated code contracts. The author asks models (GPT-5 High outperformed Opus 4.1 here) to write preconditions, postconditions, and invariants, then generates targeted unit tests and property-based tests from those contracts. One AI-written contract caught a real Paxos safety violation that could have caused replication inconsistency. The test suite grew to 1,300+ tests across unit, partial-integration, and multi-replica failure-injection layers.

The author abandoned heavyweight spec-driven development — requirement, design, and task markdowns kept drifting out of sync — in favor of a lighter loop: generate a spec with user stories, use a /clarify step to make the model self-critique, then plan one user story at a time. Performance tuning followed a similar agent-driven loop: instrument, measure, let the model analyze quantiles in Python, propose an optimization, repeat. Rust’s safety guarantees made aggressive lock removal, zero-copy, and allocation cuts tractable without the usual memory-corruption risk.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.