LeanAPI gets 33% faster after tracing the ~2k req/s ceiling to Lean's Std.Http
hargup13 · x · 2026-09-28
LeanAPI now serves requests 33% faster thanks to a community contribution by keithadler, who traced the bottleneck in a detailed GitHub issue.
- The 2,000 req/s ceiling wasn't LeanAPI's code or macOS — it was Lean 4.33's Std.Http: TCP.Socket.Client.recvSelector blocked on recv? inside the selector race, parking a task-pool worker per socket read. With 50 keep-alive connections this spawned 60+ threads all contending on the task manager's single mutex (95% of time spent contending).
- The fix has already landed on Lean master: bare Std.Http jumped from 1,624 to 5,383 req/s (M2 Pro, ab -k, 50 connections), and 4,575 req/s with LeanAPI on top.
- A separate macOS issue with connection bursts remains open. For reference, a raw Std.Async TCP loop with recv? hits 45,900 req/s.
More from coding & agent
- Manus 2.0 pivots to a full AI workspace with Cue agent identities, cuts tokens 23.2% — aziz4ai · 2026-09-29
- Models don't have agency, systems do: how shaped tokens become function calls — sethjuarez · 2026-09-29
- Cua launches Perception: pixel-reading for computer-use agents, parsed locally on CPU — iamrobotbear · 2026-09-29
- Harness device hands-on: a $149 desk command center for all your AI agents — dee_hw · 2026-09-29
- INT21 claims 20 AI-generated inference engines in 2 weeks, MiMo hits 1,308 tok/s — bingxu_ · 2026-09-29
- A Weekly Self-Maintenance Loop: Making the Muse Harness Manage Its Own Sessions — brandon_galang · 2026-09-29