From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: How the long-lines "optimisation" breaks font locking. Date: Fri, 05 Aug 2022 14:20:39 +0300 Message-ID: <837d3n0we0.fsf@gnu.org> References: <87y1w5tahv.fsf@gnus.org> <83sfmc2mph.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30854"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, emacs-devel@gnu.org, gregory@heytings.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Aug 05 13:24:30 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oJvRN-0007tW-4j for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Aug 2022 13:24:29 +0200 Original-Received: from localhost ([::1]:57400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJvRM-0001AZ-45 for ged-emacs-devel@m.gmane-mx.org; Fri, 05 Aug 2022 07:24:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJvNj-0007Oq-RG for emacs-devel@gnu.org; Fri, 05 Aug 2022 07:20:44 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:51566) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJvNh-0002VX-RS; Fri, 05 Aug 2022 07:20:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=8yuCI5JpS2rRs4/HD6AwVDqs2fz7j0hnPQhtDYaESUk=; b=fRVTtL6Nv3l3 Gi1p9EHNQXuk95PWrGBiXnzE5xnizGnTITATJfjulPgPRA3GDJ3GnOb/pNbTXO7+QjBj1TlyNB1dc CFrgE7JIYeVZIyh295GpNVlTToqWpns6dSTGYlXN+Z1FzeRD6Pc5dpbWm7Oezi1j85erLTSjZ589e iFbWMq1Ob3P1z7FrNubOJ4i3pyDcbuzc6cAtcts9BakY2fiEDpdGaFysxjJJgcAXuzKzN49r7TONS Dk361hYA2KXUcvuj+QNA1xDaX3oLkC1209Mbc8Ceyeu9sBcgU1ByfepNpYdglssNFZzQKO7na2Ylr e7rN2kBS5X/lO+EpMV+ROA==; Original-Received: from [87.69.77.57] (port=3062 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJvNh-0000Qj-BJ; Fri, 05 Aug 2022 07:20:41 -0400 In-Reply-To: (message from Alan Mackenzie on Fri, 5 Aug 2022 10:56:20 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:293107 Archived-At: > Date: Fri, 5 Aug 2022 10:56:20 +0000 > Cc: larsi@gnus.org, emacs-devel@gnu.org, gregory@heytings.org > From: Alan Mackenzie > > > > Having loaded the file in C++ Mode (without the spiking of > > > narrow-to-region and widen), it took 90 seconds for M-> (first time). > > > And you consider that reasonable? > > No, it wasn't reasonable, but neither was it "hang indefinitely". Many/most users would never wait for 90 seconds for such a simple command. So yes, it's "indefinitely" for all practical purposes. (And imagine how long it would take in an unoptimized build that I'm running every day.) > The problem was a single font-lock clause, after whose removal, the M-> > took about 1 second (first time) in the file with a 1,000,000 long line. > This clause can be put back into CC Mode and optimised, probably by > checking for being inside a literal. > > All the other sluggishness has also vanished with that change. I still > get the overflow in the regexp engine stack on inserting text. That, > again, is a bug that surely can be fixed. Thanks. Any improvements in font-lock of any major mode is welcome. If/when enough of them get their act together, we might revisit the default value of long-line-threshold, as I already said many times. I also encourage the interested parties to submit changes to extend 'widen' so that it could optionally break the lock. Then we could allow using that option in modes whose font-lock is not misbehaving with long lines.