PostHog SQL parser hits 70x speedup
PostHog has replaced its ANTLR-based C++ SQL parser with a hand-rolled Rust implementation written entirely by Claude Code. The new parser is 70x faster on local benchmarks and up to 454x faster in production, verified through property-based testing and shadow deployments.
This is a landmark case study showing that LLMs can write complex, high-performance systems code when paired with rigorous testing pipelines. It shifts the agentic coding narrative from simple scripting to structured, test-driven synthesis.
- –Replacing ANTLR's runtime graph-walking interpreter with native, hand-rolled Rust code yielded a massive 454x average speedup on production queries.
- –The developer's primary role shifted from writing code to building validation loops, utilizing Hypothesis for property-based testing to compare AST outputs with the old parser.
- –Brittle lookahead fixes by the LLM were solved through targeted prompt engineering, forcing the agent to load relevant grammar rules into context before editing.
- –The final result is a highly complex 16,000-line Rust parser (using a Pratt expression parser and speculative backtracking) written entirely by Claude.
- –This highlights a new development pattern: using parser generators to establish correctness (as an oracle) and letting LLMs generate the high-performance implementation.
DISCOVERED
1h ago
2026-06-24
PUBLISHED
3h ago
2026-06-24
RELEVANCE
AUTHOR
robbie-c