all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock
@ 2023-05-21  3:14 Tom Gillespie
  2023-05-21  4:53 ` bug#63622: source of problem identified to be python-font-lock-extend-region Tom Gillespie
  2023-05-21  6:08 ` bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock Eli Zaretskii
  0 siblings, 2 replies; 17+ messages in thread
From: Tom Gillespie @ 2023-05-21  3:14 UTC (permalink / raw)
  To: 63622

The changes in 4915ca5dd4245a909c046e6691e8d4a1919890c8 have
introduced a significant performance regression when editing python
code that contains dictionary structures across multiple lines.

The current behavior makes Emacs unusable when editing python
dictionaries with more than 20 or so lines. I would suggest reverting
the commit until the performance issue can be addressed.

If I had to guess, this is probably being caused by a double
zero-or-more pattern (possibly implicit) in the new regexps that were
added/changed.

The literal dictionary below is sufficient to demonstrate the issue
and if you bisect and compare the behavior to the immediately prior
commit 31e32212670f5774a6dbc0debac8854fa01d8f92 the difference is
clear. Open the file and hit enter a couple of times and the lag is
obvious (if you can't detect the issue try doubling the number of
lines at the deepest nesting level from 25 to 50).

By profiling and varying the number of repeated lines (e.g. by
doubling them) it appears that the issue is some lurking quadratic
behavior in syntax-ppss as a result of the changes in 4914ca. In my
testing 25, 50, and 100 lines take 100ms, 800ms, and 5 seconds
respectively to insert a new line while the cursor is inside the outer
most paren.

Collapsing all the structures into one line hides the issue. The
longer each individual line the more rapid the slowdown.

The example below is not syntactically correct python, however it
highlights the issue in a way that is clearer than it would be
otherwise.

Examples that trigger the issue (repeat the 2nd line 50 or 100 times
to see the effect). Any combination of paren types will cause the
issue.  The closing paren does not have to be present and does not
prevent the issue.

#+begin_src python
[''
'' []
#+end_src
#+begin_src python
[''
[] ''
#+end_src
#+begin_src python
[''
'' {}
#+end_src
#+begin_src python
{''
'' ()
#+end_src
#+begin_src python
[""
'' []
#+end_src

Examples that are do not cause the issue.
#+begin_src python
[a
'' []
#+end_src
#+begin_src python
[''
'' a
#+end_src
#+begin_src python
[''
'' ''
#+end_src
#+begin_src python
[[]
[] []
#+end_src
#+begin_src python
[[]
[] ''
#+end_src

Example of syntactically correct python that causes the issue.
#+begin_src python
{'':
 {
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
  '': {'': ''},
 },
 '': ['']}
#+end_src





^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-05-26 10:01 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-21  3:14 bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock Tom Gillespie
2023-05-21  4:53 ` bug#63622: source of problem identified to be python-font-lock-extend-region Tom Gillespie
2023-05-21  6:08 ` bug#63622: lisp/progmodes/python.el: performance regression introduced by multiline font-lock Eli Zaretskii
2023-05-21  7:13   ` Tom Gillespie
2023-05-21  9:31     ` kobarity
2023-05-21 15:16       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-22 14:58         ` kobarity
2023-05-22 15:08           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-23 15:45             ` kobarity
2023-05-23 17:08               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-23 19:04               ` Tom Gillespie
2023-05-23 23:21                 ` kobarity
2023-05-24 18:53                   ` Tom Gillespie
2023-05-23 23:41               ` Ruijie Yu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-24 15:05                 ` kobarity
2023-05-26 10:01                   ` Eli Zaretskii
2023-05-21 15:44       ` kobarity

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.