How AST-grep Rewrote Tree-sitter in Rust and Made It 30% Faster
Hacker News 热议:How AST-grep Rewrote Tree-sitter in Rust and Made It 30% Faster(25 赞 / 1 评论,来源 astgrep.com)
一句话概要
ast-grep(sg) is a lightning fast and user friendly tool for code searching, linting, rewriting at large scale.
原文开头节选
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.
(以上为原文节选,完整内容见下方”原文来源”)
这条动态今日登上 Hacker News 首页(25 赞 / 1 评论,来源 astgrep.com)。技术雷达每日自动聚合 AI 工程、后端架构、DevOps 方向的前沿动态;相关工程落地可浏览下方的相关服务与延伸阅读,或直接与我们团队交流。
原文来源: Hacker News