* Very long lines in shell-mode
@ 2006-12-06 17:44 Romain Francoise
2006-12-06 18:10 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Romain Francoise @ 2006-12-06 17:44 UTC (permalink / raw)
We recently fixed a similar issue in sgml-mode so we might want to have
a look at this one, it's been around for ever: very very long lines in
shell-mode cause Emacs to slow down considerably, eating CPU constantly.
For example, try:
emacs -Q -f shell
perl -e 'print "a" x 2000000; print "\n"'
This is probably due to the font-lock keywords set up by shell mode.
Unfortunately, they probably can't be anchored properly. (And they're
very useful, so we can't just get rid of them...)
(This is not a regression compared to Emacs 21.)
--
Romain Francoise <romain@orebokech.com> | The sea! the sea! the open
it's a miracle -- http://orebokech.com/ | sea! The blue, the fresh, the
| ever free! --Bryan W. Procter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Very long lines in shell-mode
2006-12-06 17:44 Very long lines in shell-mode Romain Francoise
@ 2006-12-06 18:10 ` Stefan Monnier
2006-12-07 4:59 ` Richard Stallman
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2006-12-06 18:10 UTC (permalink / raw)
Cc: emacs-devel
> We recently fixed a similar issue in sgml-mode so we might want to have
> a look at this one, it's been around for ever: very very long lines in
> shell-mode cause Emacs to slow down considerably, eating CPU constantly.
This may be due to something completely different: font-lock works on
a line-by-line basis.
> emacs -Q -f shell
> perl -e 'print "a" x 2000000; print "\n"'
Most likely the 2MB line will be inserted in the buffer in many little
chunks of maybe 4KB or so: for each chunk font-lock may decide to refontify
the whole line. Each fontification step takes time proportional to the
length of the line, so you get O(n^2) behavior.
And this is without even considering the regexps involved which may very
likely add a factor of n to that.
Maybe for such cases, font-lock should have a "sanity check" and either not
fontify the line at all, or fontify only a part of it at a time.
In either case it's probably not a good idea to try such a thing at
this stage.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Very long lines in shell-mode
2006-12-06 18:10 ` Stefan Monnier
@ 2006-12-07 4:59 ` Richard Stallman
2006-12-07 9:23 ` Kim F. Storm
0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2006-12-07 4:59 UTC (permalink / raw)
Cc: romain, emacs-devel
Most likely the 2MB line will be inserted in the buffer in many little
chunks of maybe 4KB or so: for each chunk font-lock may decide to refontify
the whole line. Each fontification step takes time proportional to the
length of the line, so you get O(n^2) behavior.
And this is without even considering the regexps involved which may very
likely add a factor of n to that.
Maybe for such cases, font-lock should have a "sanity check" and either not
fontify the line at all, or fontify only a part of it at a time.
A possible simple solution: in Shell mode, don't fontify a line that
doesn't end in a newline. If that solves the problem, it would be
simple enough to install now.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-12-08 5:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-06 17:44 Very long lines in shell-mode Romain Francoise
2006-12-06 18:10 ` Stefan Monnier
2006-12-07 4:59 ` Richard Stallman
2006-12-07 9:23 ` Kim F. Storm
2006-12-08 5:04 ` Richard Stallman
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).