From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Very long lines in shell-mode Date: Wed, 06 Dec 2006 13:10:49 -0500 Message-ID: References: <87zma0gbr5.fsf@pacem.orebokech.com> NNTP-Posting-Host: dough.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1165428681 15759 80.91.229.10 (6 Dec 2006 18:11:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 6 Dec 2006 18:11:21 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 06 19:11:18 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by dough.gmane.org with esmtp (Exim 4.50) id 1Gs1Ea-00060g-Qt for ged-emacs-devel@m.gmane.org; Wed, 06 Dec 2006 19:11:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gs1Ea-0002Kl-BF for ged-emacs-devel@m.gmane.org; Wed, 06 Dec 2006 13:11:08 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gs1EO-0002Kg-C8 for emacs-devel@gnu.org; Wed, 06 Dec 2006 13:10:56 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gs1EL-0002KU-SG for emacs-devel@gnu.org; Wed, 06 Dec 2006 13:10:55 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gs1EL-0002KR-Mx for emacs-devel@gnu.org; Wed, 06 Dec 2006 13:10:53 -0500 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gs1EL-0007yS-H6 for emacs-devel@gnu.org; Wed, 06 Dec 2006 13:10:53 -0500 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 212F92CF05B; Wed, 6 Dec 2006 13:10:53 -0500 (EST) Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 449343FE0; Wed, 6 Dec 2006 13:10:49 -0500 (EST) Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 2CEF56C8CA; Wed, 6 Dec 2006 13:10:49 -0500 (EST) Original-To: Romain Francoise In-Reply-To: <87zma0gbr5.fsf@pacem.orebokech.com> (Romain Francoise's message of "Wed\, 06 Dec 2006 18\:44\:30 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:63363 Archived-At: > 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