very slow parens-matching in big XML files
- Dominant language
- Emacs Lisp
- Stars
- 3.9k
- Forks
- 307
- PR merge metrics
- No merged PRs in 30d
Description
Originally reported by: **Kevin Brubeck Unhammer (Bitbucket: [unhammer](https://bitbucket.org/unhammer), GitHub: [unhammer](https://github.com/unhammer))**
----------------------------------------
Versions:
```
#!bash
$ hg log|head -5
changeset: 1850:f2648b841f9b
tag: tip
user: duianto
date: Thu Aug 25 20:43:46 2016 +0000
summary: evil-commands.el, spelling corrections on 5 lines
$ emacs --version|head -1
GNU Emacs 26.0.50.2
```
To reproduce:
```
#!bash
$ wget -q https://svn.code.sf.net/p/apertium/svn/languages/apertium-nno/apertium-nno.nno.dix
$ make emacs
```
and eval
```
#!emacs-lisp
(setq rng-nxml-auto-validate-flag nil)
(show-paren-mode)
```
then open the downloaded file `apertium-nno.nno.dix`, and there are two slow cases you can try:
1. Go to e.g. line 4555 and hit `%`. This takes forever, I end up C-g-ing it. Many times.
2. When Emacs is responsive again, try `o a< RET b< ESC k $ x`, ie. enter some lines with just opening brackets, and try deleting one of them. Again, Emacs becomes unresponsive for a while.
It seems that case 2. requires 1. to have happened at least once, I'm not sure.
I've started using `(setq evil-highlight-closing-paren-at-point-states nil)` as a workaround for case 2., but haven't yet looked at what causes the slowness in case 1.
It might be possible to make the show-paren-function advice faster, or perhaps simply not use it when the file is over a certain size? I haven't had time to profile *within* that function itself.
----------------------------------------
- Bitbucket: https://bitbucket.org/lyro/evil/issue/736
Contributor guide
Research direction
Reproduce the slowdown with the downloaded apertium-nno.nno.dix file, show-paren-mode, and rng-nxml-auto-validate-flag disabled. Start by profiling the show-paren-function advice while pressing % at line 4555, then investigate the deletion case and the evil-highlight-closing-paren-at-point-states workaround. Done means paren matching and deletion remain responsive in the reported large XML file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- emacs-lisp
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100