tree-sitter-clojure icon indicating copy to clipboard operation
tree-sitter-clojure copied to clipboard

Cost of use of `inline` unknown

Open sogaiu opened this issue 2 years ago • 3 comments
trafficstars

There's a claim that using inline can be costly in some cases: https://github.com/tree-sitter/tree-sitter/issues/2078#issuecomment-1421932361

We started using inline recently: https://github.com/sogaiu/tree-sitter-clojure/blob/262d6d60f39f0f77b3dd08da8ec895bd5a044416/grammar.js#L208-L215

I think we speculated about using inline further, for example, for things like this: https://github.com/sogaiu/tree-sitter-clojure/blob/262d6d60f39f0f77b3dd08da8ec895bd5a044416/grammar.js#L357-L361

So may be we'll remember to think of the potential cost issue when considering and experimenting with carrying out such changes.

Not sure how to asses it, but perhaps it's worth investigating it at some point.

sogaiu avatar Feb 08 '23 03:02 sogaiu

Maybe we run some performance tests with and without that inline directive, see what they turn up?

dannyfreeman avatar Feb 08 '23 15:02 dannyfreeman

That sounds reasonable.

We might not notice a difference but it could be that the generate subcommand duration might differ as well.

I suspect that for our small grammar it's not likely to be a big deal, but I've seen tree-sitter-c-sharp's case take more than 4 minutes. Memory use was over 50GB as well.

sogaiu avatar Feb 08 '23 15:02 sogaiu

We're lucky that clojure has such simple syntax rules I think. Ours is one of the smallest grammars I have encountered, and probably one of the fastest.

dannyfreeman avatar Feb 13 '23 18:02 dannyfreeman