How ast-grep Rewrote Tree-sitter in Rust and Made It 30% Faster
I used AI to rewrite Tree-sitter's C core in Rust, achieving a 30% speed boost in parsing. While the new runtime is faster, it trades some memory efficiency for performance. This project proves that AI can handle complex system rewrites, turning a previously impossible task into a reality for structural code search tools like ast-grep.
It was a Herculean task wearing a header file.
- trickypr
> incremental old-tree reuse were removed
Maybe I am missing what they meant here, but isn’t the entire point of tree-sitter that you can reuse old trees to make edit updates faster? It is seems quite probable that all the performance gains came from optimising for fixed files with no error recovery, at the cost of how ts is actually used.
- AlexeyBrin
Reading the article is like climbing a load-bearing wall to quote their last phrase.
- nullbio
ast-grep is a great tool. Really helps with agentic work. I wish the LLMs were trained to use it by default. Would make them incredibly powerful.