How AST-grep Rewrote Tree-sitter in Rust and Made It 30% Faster
Posted by herrington_d 1 day ago
Comments
Comment by trickypr 1 day ago
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.
Comment by ivanjermakov 23 hours ago
Comment by gumby 22 hours ago
Comment by sweetgiorni 22 hours ago
I've used tree-sitter for a few projects, but I never touched the tree-reuse stuff. The value of tree-sitter came from the fact that grammars compile to a .so and can be easily distributed through package managers. Adding support for a new grammar in ast-grep might just mean pointing to the .so at runtime (idk, I haven't checked). So this optimization might make sense for this project.
Comment by jibal 19 hours ago
No, not for ast-grep.
Comment by AlexeyBrin 1 day ago
Comment by rayiner 22 hours ago
Comment by hidd 21 hours ago
Comment by thejazzman 19 hours ago
https://amphetamem.es/meme/?id=the-simpsons_08_08_248&text=I...
Comment by trollbridge 22 hours ago
Comment by why_only_15 19 hours ago
Comment by anitil 18 hours ago
It seems like a lot of the speedup comes from using an arena, using realloc with offsets rather than raw pointers and some change to the graph that enabled this (though I don't want to re-read it to confirm).
Comment by senderista 21 hours ago
Comment by nullbio 21 hours ago
Comment by greatsage_sh 21 hours ago
Comment by froh 1 day ago
Comment by gumby 22 hours ago