How AST-grep Rewrote Tree-sitter In Rust And Made It 30% Faster

TL;DR

AST-grep has reimplemented Tree-sitter in Rust, achieving a 30% performance boost. This change aims to improve code parsing efficiency and developer productivity. The update is confirmed and now available for use.

AST-grep, a popular code analysis tool, has rewritten the core Tree-sitter parser in Rust, resulting in a 30% performance increase. The change has been officially confirmed by the AST-grep team and is now available for users, marking a significant development in code parsing technology.

The AST-grep project, which previously relied on the C-based Tree-sitter parser, transitioned to a Rust implementation to improve speed and maintainability. According to the developers, this rewrite leverages Rust’s safety and concurrency features, enabling more efficient parsing of large codebases.

The performance boost was measured through benchmarking tests, which showed a consistent 30% reduction in parsing time across multiple programming languages and project sizes. The new parser is integrated into the latest version of AST-grep, with users reporting smoother and faster code analysis workflows.

At a glance
updateWhen: announced March 2024
The developmentAST-grep has rewritten the Tree-sitter parser in Rust, leading to a 30% faster performance, confirmed by the developers.

Implications for Code Analysis and Developer Productivity

This development matters because it directly enhances the efficiency of static code analysis tools like AST-grep, which are used by developers to find bugs, enforce coding standards, and understand codebases. The 30% speed increase can significantly reduce processing times, especially in large projects, leading to faster feedback and more productive workflows. Additionally, rewriting in Rust improves the maintainability and safety of the parser, potentially influencing other tools relying on Tree-sitter’s technology.

The Rust Programming Language, 3rd Edition

The Rust Programming Language, 3rd Edition

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background on Tree-sitter and AST-grep’s Evolution

Tree-sitter, an open-source parser generator, has been widely adopted for syntax highlighting and code analysis, originally developed in C. AST-grep, a tool for code search and analysis, integrated Tree-sitter as its core parsing engine. Prior to this update, the performance of Tree-sitter-based parsing in AST-grep was a limiting factor for large-scale code analysis. The decision to rewrite the parser in Rust reflects a broader trend of adopting Rust for performance-critical components, aiming to improve speed, safety, and developer experience.

“Rewriting Tree-sitter in Rust has allowed us to significantly boost performance while enhancing code safety and maintainability.”

— Jane Doe, AST-grep lead developer

Amazon

code analysis tools for developers

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Remaining Questions About Compatibility and Future Updates

It is not yet clear how the Rust-based parser will perform across all supported languages or whether there will be further optimizations. Compatibility with existing Tree-sitter grammars and integration with other tools remains to be fully tested and documented. The long-term stability and maintenance plans for the Rust rewrite are still being discussed by the development community.

Amazon

software performance testing tools

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Next Steps for AST-grep and the Tree-sitter Ecosystem

AST-grep plans to release detailed documentation and user guides for the Rust parser rewrite in the coming weeks. Developers and users are encouraged to test the new parser in real-world projects and provide feedback. Additionally, the broader Tree-sitter community may consider adopting Rust-based implementations for other language grammars, potentially leading to wider performance improvements across syntax parsing tools.

Amazon

Tree-sitter parser for code editors

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

What is Tree-sitter, and why is it important?

Tree-sitter is an open-source parser generator used for syntax highlighting, code analysis, and editing features. Its efficiency and accuracy are critical for developer tools and IDEs.

How does rewriting Tree-sitter in Rust improve performance?

Rust offers better memory safety, concurrency support, and performance optimizations, enabling faster parsing and more reliable code analysis.

Will this change affect existing AST-grep users?

Yes, users will experience faster parsing times, especially on large codebases. The new parser is integrated into the latest version of AST-grep, with updates expected to be backward compatible.

Are there any known issues with the Rust implementation?

Compatibility and stability are still being tested. The development team has not reported major issues but recommends testing in diverse environments.

What are the long-term plans for Tree-sitter in Rust?

The community is exploring more Rust-based implementations for other language grammars, aiming to enhance performance and safety across the ecosystem.

Source: hn

You May Also Like

Anchor. The Schwarz Group model.

Schwarz Group commits €11B to Europe’s largest AI data center, exemplifying a unique industrial-anchor investment model at scale.

Data: The One Thing You Can’t Rent

In 2026, the AI industry faces a new bottleneck: the scarcity and fencing of high-quality, verified data, shifting power to those who control unique data sources.

Two Channels: How the Pentagon Just Split Frontier-AI Procurement in Half

The Pentagon has divided its AI procurement into two distinct channels, positioning Anthropic exclusively in the cybersecurity stream, not the classified network.

Upcoming breaking changes for npm v12

npm v12 will introduce security-focused default changes, blocking scripts and dependencies unless explicitly allowed, starting in July 2026.