← Back to Tech Radar
Hacker News tech

How AST-grep Rewrote Tree-sitter in Rust and Made It 30% Faster

Trending on Hacker News: How AST-grep Rewrote Tree-sitter in Rust and Made It 30% Faster (25 points / 1 comments, via astgrep.com)

In one line

ast-grep(sg) is a lightning fast and user friendly tool for code searching, linting, rewriting at large scale.

Opening excerpt

ast-grep rewrote Tree-sitter’s C core in Rust, with AI writing the code. The new core is faster at parsing, faster at reading the completed tree, and faster in ast-grep itself. (The title’s “30%” is the parser-only number; end-to-end, ast-grep runs about 22% faster.)

Two quick introductions before the numbers. ast-grep — the structural code-search tool this blog belongs to — searches code by syntax rather than by text, so every file it touches must first become a syntax tree. Tree-sitter is the parser framework that builds that tree: you give it a grammar definition, and it generates a fast parser for that language. Born in the editor world, it now powers an enormous ecosystem of grammars and tools.

Performance and peak RSS. Throughput is normalized so the unmodified C build (“C / normal”) scores 100; higher is better. RSS is peak resident memory, and the raw-parsing row shows it as a range because it varies across the benchmark’s language fixtures.

Rust won every parser and traversal fixture, and ast-grep produced exactly the same outline.

(Excerpted from the original; full article via the source link below.)

This story hit the Hacker News front page today (25 points / 1 comments, via astgrep.com). Our Tech Radar aggregates daily signals on AI engineering, backend architecture and DevOps — browse the related services and further reading below, or get in touch with our team.

Source: Hacker News

Related Services

Related Reading