File: performance

package info (click to toggle)
emacs 1%3A30.1%2B1-6~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 187,092 kB
  • sloc: lisp: 1,367,417; ansic: 466,479; objc: 19,117; cpp: 8,817; java: 8,780; sh: 8,119; makefile: 7,283; python: 3,788; perl: 1,788; xml: 1,720; yacc: 1,566; asm: 1,150; php: 1,035; pascal: 1,011; awk: 937; cs: 880; ada: 725; ruby: 658; javascript: 187; erlang: 153; tcl: 16
file content (25 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
TREE-SITTER PERFORMANCE NOTES -*- org -*-

* Facts

Incremental parsing of a few characters worth of edit usually takes
less than 0.1ms.  If it takes longer than that, something is wrong.
There’s one time where I found tree-sitter-c takes ~30ms to
incremental parse.  Updating to the latest version of tree-sitter-c
solves it, so I didn’t investigate further.

The ranges set for a parser doesn’t grow when you insert text into a
range, so you have to update the ranges every time before
parsing.  Fortunately, changing ranges doesn’t invalidate incremental
parsing, so there isn’t any performance lost in update ranges
frequently.

* Experiments

Using regexp by default in treesit-simple-indent-rules seems wasteful,
so I tried replacing all string-match-p to equal in
treesit-simple-indent-presets, and indent xdisp.c for a comparison.
Turns out using regexp by default is faster: regexp-based indent took
45s and equal-based indent took 75s.

I could be missing something, further experiments are welcome.