All news
aiproduct

AST-grep Rewrites Tree-sitter in Rust, Gains 30% Speed

28 Jul 2026

The rewrite

AST-grep, the code-search and linting tool built on Tree-sitter, has rewritten Tree-sitter's C core in Rust. The project reports a 30% performance improvement at the parser level, and an end-to-end speedup of about 22% for ast-grep itself.

Memory usage tells a sharper story. On a TypeScript stress-test corpus, peak memory now sits at 91.2 MiB — down from over 1 GiB earlier in the project's development. That's more than a 10x reduction in peak memory on the same benchmark.

What changed under the hood

The rewrite wasn't a simple line-by-line port. According to the report, two features were removed in the process: native loading of WebAssembly-compiled languages, and incremental old-tree reuse. Both were part of the original C implementation, and their removal appears to be a tradeoff made to achieve the Rust port's performance gains — though the report doesn't specify the exact reasoning or whether these features will return.

Notably, the rewrite process itself leaned on AI assistance: an agent read both the C and Rust codebases, wrote patches, fixed compiler errors, ran tests, and investigated mismatches between the old and new implementations. This mirrors a broader pattern the report flags — AI-assisted rewrite attempts have also surfaced in other projects, including Bun, pgrust, and Roc.

Numbers at a glance

  • 30% faster — parser-only performance improvement
  • 22% faster — end-to-end ast-grep performance
  • 91.2 MiB — peak memory on the TypeScript stress corpus (new)
  • 1 GiB+ — peak memory on the same corpus (earlier in development)

Caveats

This report comes from a single source, and corroboration from other outlets or independent benchmarks is still pending. The removed features (WASM language loading, incremental tree reuse) may matter significantly to some users depending on their workflows — the report doesn't detail how many ast-grep users rely on either.

Why founders should care

For teams building dev tools, code analysis products, or CI/CD pipelines that lean on Tree-sitter or ast-grep, this rewrite likely means meaningfully faster parsing and dramatically lower memory overhead — which could matter for products running parsing at scale or in memory-constrained environments (e.g., serverless functions, CI runners, or browser-based tools).

The use of AI agents to execute a systems-level rewrite — reading legacy C code, porting it to Rust, and debugging the result — is also a signal worth watching. If this pattern holds across other infrastructure projects, founders maintaining performance-critical C/C++ codebases may increasingly have a viable, faster path to memory-safe rewrites without a purely manual, multi-quarter engineering effort. That said, with only one project cited as a detailed case study so far, it's too early to treat this as a proven, repeatable playbook — teams should watch for further examples before betting roadmap timelines on AI-driven rewrites of critical infrastructure.

Sources