emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree-sitter indentation for js-mode & cc-mode


From: Theodor Thornhill
Subject: Re: Tree-sitter indentation for js-mode & cc-mode
Date: Fri, 28 Oct 2022 10:59:22 +0200

Yuan Fu <casouri@gmail.com> writes:

>> 
>>>> looking up way to much the root of the tree, but you know the internals
>>>> here better than me.  Is this something we can optimize away? See the
>>>> attached report at the bottom.
>>> 
>>> This is very strange, I need to look into it.
>>> 
>> 
>> I'm happy to provide more info and profiling, as well as testing if
>> need be!
>
> I just tried running treesit-buffer-root-node and treesit-node-at
> 10000 times in the end of buffer and they are pretty fast, so I don’t
> know why the benchmark says 99% time is spent in
> treesit-buffer-root-node. Could you share the benchmark code and test
> file? Thanks!

Absolutely.  I ran the test again - see test file and new report in
attachments.

You need to `M-x eval-buffer` in `treesit.el` to avoid the compiled
functions to get better profile report, then in the testfile:

M-x profiler-start
C-x h ;; (mark-whole-buffer)
C-i   ;; (indent-for-tab-command)
;; --- waaaaait
M-x profiler-stop
M-x profiler-report

There's no test code for this, just running the commands sequentially
and get the report :-)

Are we parsing the whole file over and over in treesit-buffer-root-node?
Do we for some reason not hit the early return?

Code is taken from [0] and duplicated and messed up indentation.

Theo

[0] 
https://raw.githubusercontent.com/TheAlgorithms/JavaScript/master/Search/BinarySearch.js

Attachment: foo.js
Description: Text Data

Attachment: cpu.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]