all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Theodor Thornhill <theo@thornhill.no>
To: Yuan Fu <casouri@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>,
	Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Re: Tree-sitter indentation for js-mode & cc-mode
Date: Fri, 28 Oct 2022 11:10:18 +0200	[thread overview]
Message-ID: <87mt9ggvph.fsf@thornhill.no> (raw)
In-Reply-To: <425E0075-3F44-4832-BA2E-61E7D0A26FF4@gmail.com>

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!
>
> Yuan


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?

The js-file [0] is taken from [1] and duplicated and messed up
indentation. Report [2] was messed up by dpaste it seems.  Gmail didn't
want the files as attachments, so paste it is :-)

Hope this is useful!

Theo


[0]: https://dpaste.org/dwj3Q
[1]: https://raw.githubusercontent.com/TheAlgorithms/JavaScript/master/Search/BinarySearch.js
[2]: https://dpaste.org/aogkm
Theo



  parent reply	other threads:[~2022-10-28  9:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27  1:43 Tree-sitter indentation for js-mode & cc-mode Yuan Fu
2022-10-27  9:11 ` Theodor Thornhill
2022-10-27  9:28   ` Theodor Thornhill
2022-10-27  9:58     ` Theodor Thornhill
2022-10-27 15:21   ` Yuan Fu
2022-10-27 18:36     ` Theodor Thornhill
2022-10-28  8:15       ` Yuan Fu
2022-10-28  8:59         ` Theodor Thornhill
2022-10-28  9:10         ` Theodor Thornhill [this message]
2022-10-28 19:43           ` Yuan Fu
2022-10-28 19:49             ` Theodor Thornhill
2022-10-29  1:05               ` Yuan Fu
2022-10-29  5:53             ` Eli Zaretskii
2022-10-29  6:54               ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mt9ggvph.fsf@thornhill.no \
    --to=theo@thornhill.no \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.