emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Very long lines in shell-mode


From: Stefan Monnier
Subject: Re: Very long lines in shell-mode
Date: Wed, 06 Dec 2006 13:10:49 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux)

> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]