* bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode
@ 2021-10-04 12:54 Simen Heggestøyl
2021-10-04 13:24 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Simen Heggestøyl @ 2021-10-04 12:54 UTC (permalink / raw)
To: 51006
The following recipe makes Emacs freeze, starting from 'emacs -Q':
1. Type 'M-x run-python RET'.
2. In the inferior-python-mode buffer that pops up, insert the following:
{
"foo-1": "bar-1",
"foo-2": "bar-2",
"foo-3": "bar-3",
"foo-4": "bar-4",
"foo-5": "bar-5",
"foo-6": "bar-6",
"foo-7": "bar-7",
"foo-8": "bar-8",
"foo-9": "bar-9",
}
3. Navigate up and down inside this structure by running 'next-line' and
'previous-line' in quick succession, alternating between them.
4. The movement appears slower and slower, eventually freezing up Emacs.
I've observed this in Emacs 27.2 as well, so it doesn't seem new to
Emacs 28.
Here's the report from a quick profiling I did in Emacs 28:
13447 94% - python-shell-font-lock-post-command-hook
13444 94% - font-lock-ensure
13444 94% - #<compiled -0x19f3968dc99b6307>
13444 94% - font-lock-fontify-region
13444 94% - font-lock-default-fontify-region
13420 94% - font-lock-fontify-syntactically-region
13420 94% - python-font-lock-syntactic-face-function
13412 94% - python-info-docstring-p
13396 94% + python-nav-beginning-of-statement
4 0% + python-info-assignment-statement-p
8 0% + font-lock-fontify-keywords-region
3 0% + font-lock-mode
529 3% + ...
183 1% + command-execute
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode
2021-10-04 12:54 bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode Simen Heggestøyl
@ 2021-10-04 13:24 ` Eli Zaretskii
2021-10-04 19:21 ` Simen Heggestøyl
[not found] ` <87mtno8ujv.fsf@simenheg@gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Eli Zaretskii @ 2021-10-04 13:24 UTC (permalink / raw)
To: Simen Heggestøyl; +Cc: 51006
> From: Simen Heggestøyl <simenheg@runbox.com>
> Date: Mon, 04 Oct 2021 14:54:24 +0200
>
> Here's the report from a quick profiling I did in Emacs 28:
>
> 13447 94% - python-shell-font-lock-post-command-hook
> 13444 94% - font-lock-ensure
> 13444 94% - #<compiled -0x19f3968dc99b6307>
> 13444 94% - font-lock-fontify-region
> 13444 94% - font-lock-default-fontify-region
> 13420 94% - font-lock-fontify-syntactically-region
> 13420 94% - python-font-lock-syntactic-face-function
> 13412 94% - python-info-docstring-p
> 13396 94% + python-nav-beginning-of-statement
> 4 0% + python-info-assignment-statement-p
> 8 0% + font-lock-fontify-keywords-region
> 3 0% + font-lock-mode
> 529 3% + ...
> 183 1% + command-execute
Please repeat the profiling experiment, but after loading python.el
(NOT python.elc). This should produce a more detailed profile that
would pinpoint the culprit more accurately. Based on skimming the
source code, my first suspect is syntax-ppss, but that could be a bad
guess.
Thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode
2021-10-04 13:24 ` Eli Zaretskii
@ 2021-10-04 19:21 ` Simen Heggestøyl
[not found] ` <87mtno8ujv.fsf@simenheg@gmail.com>
1 sibling, 0 replies; 7+ messages in thread
From: Simen Heggestøyl @ 2021-10-04 19:21 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 51006
[-- Attachment #1: Type: text/plain, Size: 637 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
> Please repeat the profiling experiment, but after loading python.el
> (NOT python.elc). This should produce a more detailed profile that
> would pinpoint the culprit more accurately. Based on skimming the
> source code, my first suspect is syntax-ppss, but that could be a bad
> guess.
Hi Eli, thanks for the quick response.
I repeated the experiment after deleting python.elc to avoid loading it
on startup (maybe there's a simpler way of preventing that?). The new
profiler report is attached.
Another detail: This doesn't happen in the ordinary python-mode, only in
inferior-python-mode.
[-- Attachment #2: CPU-Profiler-Report-2021-10-04-21-13-53.txt --]
[-- Type: text/plain, Size: 7325 bytes --]
47639 95% - python-shell-font-lock-post-command-hook
47639 95% - let
47639 95% - if
47639 95% - progn
47635 95% - let*
47627 95% - let
47623 95% - save-current-buffer
47623 95% - save-current-buffer
47615 95% - let
47611 95% - if
47611 95% - funcall
47611 95% - font-lock-ensure
47611 95% - #<compiled -0x15f49b30cf8ae947>
47611 95% - font-lock-fontify-region
47611 95% - font-lock-default-fontify-region
47400 94% - font-lock-fontify-syntactically-region
47400 94% - python-font-lock-syntactic-face-function
47400 94% - if
47400 94% - if
47399 94% - python-info-docstring-p
47387 94% - save-excursion
47096 94% - python-nav-beginning-of-statement
47072 94% - let*
44158 88% - cond
44151 88% - python-nav-beginning-of-statement
44127 88% - let*
41183 82% - cond
41175 82% - python-nav-beginning-of-statement
41133 82% - let*
38429 76% - cond
38421 76% - python-nav-beginning-of-statement
38409 76% - let*
35842 71% - cond
35838 71% - python-nav-beginning-of-statement
35806 71% - let*
33257 66% - cond
33177 66% - python-nav-beginning-of-statement
32662 65% - let*
32414 64% syntax-ppss
124 0% cond
20 0% or
76 0% - save-excursion
68 0% - python-info-line-ends-backslash-p
64 0% - save-excursion
56 0% - while
56 0% - and
56 0% - nth
56 0% - or
52 0% syntax-ppss
2525 5% - syntax-ppss
12 0% #<compiled 0xb89c315bc3a37ea>
20 0% - or
8 0% nth
8 0% - let
4 0% and
2551 5% syntax-ppss
4 0% - or
4 0% nth
2672 5% - syntax-ppss
4 0% #<compiled 0xb89c315bc3a37ea>
4 0% or
4 0% - save-excursion
4 0% - python-info-line-ends-backslash-p
4 0% - save-excursion
4 0% - while
4 0% - and
4 0% - nth
4 0% - or
4 0% syntax-ppss
2916 5% - syntax-ppss
4 0% #<compiled 0xb89c315bc3a37ea>
8 0% - or
4 0% nth
2886 5% syntax-ppss
4 0% - or
4 0% nth
271 0% - let
217 0% - if
213 0% - and
173 0% - not
169 0% - python-info-assignment-statement-p
165 0% - save-excursion
165 0% - let
137 0% - if
133 0% - python-nav-beginning-of-statement
113 0% - let*
77 0% - cond
65 0% - save-excursion
61 0% - python-info-line-ends-backslash-p
48 0% - save-excursion
36 0% - while
32 0% - and
28 0% - nth
28 0% - or
28 0% syntax-ppss
8 0% - if
4 0% equal
24 0% syntax-ppss
8 0% or
20 0% - while
20 0% - and
8 0% re-search-forward
24 0% looking-at-p
4 0% concat
8 0% if
84 0% - font-lock-fontify-keywords-region
84 0% - #<lambda -0xaef49294dba7a2c>
84 0% - let
4 0% - if
4 0% - or
4 0% - nth
4 0% - or
4 0% syntax-ppss
8 0% - if
8 0% - progn
8 0% - font-lock-mode
8 0% - font-lock-default-function
8 0% - font-lock-mode-internal
8 0% - font-lock-unfontify-buffer
8 0% - font-lock-default-unfontify-buffer
8 0% font-lock-unfontify-region
4 0% python-shell-get-process-or-error
8 0% - while
8 0% - let*
4 0% or
4 0% set-text-properties
2364 4% + ...
47 0% + command-execute
3 0% + redisplay_internal (C function)
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode
[not found] ` <87mtno8ujv.fsf@simenheg@gmail.com>
@ 2021-10-04 19:52 ` Eli Zaretskii
2022-07-22 9:41 ` Simen Heggestøyl
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2021-10-04 19:52 UTC (permalink / raw)
To: Simen Heggestøyl, Stefan Monnier; +Cc: 51006
> From: Simen Heggestøyl <simenheg@runbox.com>
> Cc: 51006@debbugs.gnu.org
> Date: Mon, 04 Oct 2021 21:21:56 +0200
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > Please repeat the profiling experiment, but after loading python.el
> > (NOT python.elc). This should produce a more detailed profile that
> > would pinpoint the culprit more accurately. Based on skimming the
> > source code, my first suspect is syntax-ppss, but that could be a bad
> > guess.
>
> Hi Eli, thanks for the quick response.
>
> I repeated the experiment after deleting python.elc to avoid loading it
> on startup (maybe there's a simpler way of preventing that?). The new
> profiler report is attached.
>
> Another detail: This doesn't happen in the ordinary python-mode, only in
> inferior-python-mode.
Thanks. So yes, it's syntax-ppss. Time to bring Stefan (CC'ed) on
board of this discussion.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode
2021-10-04 19:52 ` Eli Zaretskii
@ 2022-07-22 9:41 ` Simen Heggestøyl
2022-07-22 11:22 ` Eli Zaretskii
0 siblings, 1 reply; 7+ messages in thread
From: Simen Heggestøyl @ 2022-07-22 9:41 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Lars Ingebrigtsen, 51006
This seems to have been fixed on master by:
commit ab34293d849086a67effc52800e18bab1400ce72
Author: Lars Ingebrigtsen <larsi@gnus.org>
Date: Wed Oct 13 18:44:35 2021 +0200
Fix problem with multiline fontification in interactive Python
* lisp/progmodes/python.el
(python-shell-font-lock-post-command-hook): When doing multi-line
(`C-c SPC') inputs, remove all the preceding lines when doing
fontification (bug#47657).
Should it be backported to emacs-28 as the problem still exists there?
Otherwise I think this bug can be closed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode
2022-07-22 9:41 ` Simen Heggestøyl
@ 2022-07-22 11:22 ` Eli Zaretskii
2022-07-22 20:06 ` Lars Ingebrigtsen
0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2022-07-22 11:22 UTC (permalink / raw)
To: Simen Heggestøyl; +Cc: larsi, 51006
> From: Simen Heggestøyl <simenheg@runbox.com>
> Cc: 51006@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
> Date: Fri, 22 Jul 2022 11:41:13 +0200
>
> This seems to have been fixed on master by:
>
> commit ab34293d849086a67effc52800e18bab1400ce72
> Author: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Wed Oct 13 18:44:35 2021 +0200
>
> Fix problem with multiline fontification in interactive Python
>
> * lisp/progmodes/python.el
> (python-shell-font-lock-post-command-hook): When doing multi-line
> (`C-c SPC') inputs, remove all the preceding lines when doing
> fontification (bug#47657).
>
> Should it be backported to emacs-28 as the problem still exists there?
Fine by me.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode
2022-07-22 11:22 ` Eli Zaretskii
@ 2022-07-22 20:06 ` Lars Ingebrigtsen
0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-07-22 20:06 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Simen Heggestøyl, 51006
Eli Zaretskii <eliz@gnu.org> writes:
>> Should it be backported to emacs-28 as the problem still exists there?
>
> Fine by me.
If I remember correctly, it's not a regression, but a long-standing bug,
so I don't think backporting is warranted here.
Simen Heggestøyl <simenheg@runbox.com> writes:
> Otherwise I think this bug can be closed.
OK; done.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-07-22 20:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-04 12:54 bug#51006: 28.0.60; Slowness while navigating in inferior-python-mode Simen Heggestøyl
2021-10-04 13:24 ` Eli Zaretskii
2021-10-04 19:21 ` Simen Heggestøyl
[not found] ` <87mtno8ujv.fsf@simenheg@gmail.com>
2021-10-04 19:52 ` Eli Zaretskii
2022-07-22 9:41 ` Simen Heggestøyl
2022-07-22 11:22 ` Eli Zaretskii
2022-07-22 20:06 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).