How AST-grep Rewrote Tree-sitter in Rust to Boost Performance by 30%
Key point
AST-grep rewrote Tree-sitter's C core in Rust to improve performance for AI coding agent optimization.
Details
ast-grep, a structural code search tool, has significantly improved performance by rewriting the existing Tree-sitter C core in Rust.
The key performance metrics are as follows:
- Raw parsing: Throughput improved by approximately 29.74%
- Tree traversal: Throughput improved by approximately 10.16%
- End-to-end (ast-grep): Overall execution time (User CPU) decreased by approximately 22.2%
This rewrite was not simply a language change, but focused on building a runtime optimized for workloads where AI coding agents analyze entire file snapshots. To achieve this, the native loading of WebAssembly-compiled languages and incremental tree reuse features from the existing implementation were removed, but the new version shows much more efficient performance for agent workloads.
There has also been significant progress in memory usage. In TypeScript stress test environments, the peak memory usage that previously exceeded 1 GiB is now managed at approximately 91.2 MiB.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.