Microsoft's ai-driven rewrite of copilot runtime boosts performance by 15.9x
Microsoft utilized AI agents to migrate the GitHub Copilot runtime from TypeScript to Rust, a project costing $120,000 in token expenses and three weeks of developer labor. The rewrite, detailed by Microsoft Distinguished Engineer Stephen Toub, transformed 430,000 lines of TypeScript into 800,000 lines of Rust, spanning 14.5 weeks and 135 releases. The migration significantly improved performance, achieving a 15.9x speedup in certain workloads and reducing memory usage from 1383MB to 126MB. Toub noted that AI agents spent more time gathering information than writing code, emphasizing an iterative process of investigation and modification.
The project faced challenges, including dozens of regressions and the need for careful validation. Toub criticized the reliance on compiler checks alone, stating, "If passing the compiler means correctness, then that statement is only fit for a joke." Lisa Crossman, a Rust consultant, also warned against treating the compiler as an oracle. Meanwhile, Jarred Sumner’s similar project using Claude agents to rewrite Anthropic’s JS runtime to Rust, costing $165,000, passed 99.8% of tests, though still facing scrutiny from Zig creator Andrew Kelley.