From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.devel Subject: Re: Making font-lock handle long lines better Date: Sun, 12 Feb 2017 00:06:41 +0100 Message-ID: References: <83wpcy2eun.fsf@gnu.org> <83lgtc3215.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114e1ce27876910548494490 X-Trace: blaine.gmane.org 1486854413 11745 195.159.176.226 (11 Feb 2017 23:06:53 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 11 Feb 2017 23:06:53 +0000 (UTC) Cc: Wilfred Hughes , public@ryanb.org, emacs-devel To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 12 00:06:49 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ccgki-0002dA-GS for ged-emacs-devel@m.gmane.org; Sun, 12 Feb 2017 00:06:48 +0100 Original-Received: from localhost ([::1]:49911 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccgko-0001O4-6D for ged-emacs-devel@m.gmane.org; Sat, 11 Feb 2017 18:06:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccgkh-0001Ny-Km for emacs-devel@gnu.org; Sat, 11 Feb 2017 18:06:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccgkg-0005rk-AS for emacs-devel@gnu.org; Sat, 11 Feb 2017 18:06:47 -0500 Original-Received: from mail-vk0-x232.google.com ([2607:f8b0:400c:c05::232]:32775) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ccgke-0005rW-Dk; Sat, 11 Feb 2017 18:06:44 -0500 Original-Received: by mail-vk0-x232.google.com with SMTP id k127so44847279vke.0; Sat, 11 Feb 2017 15:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tPYu5d/Svx7ab4/QoyxHhSdtL4EVGLNreteC209+8Co=; b=q/Ke9igrjR8v9omEqfZQD2shwBEX+1bElH0i1j8lSI+suD6YuRIPakOq/m/VZ+gNTZ E3eo/WwPXvyBLNmuKECi2KrZZQGbdTOHDeN8o9DRa3NKQ+qHUN7zxPFPsoa0ADADcKxp 1qo30sLREGzyr5Fp4JqICsU0/ru5UP3LF4z3IV4gn0f+QqJ2C3WY7bdlWRLeI4MhgwYw Z/uGkYOA45GnTWIO5sKzKeL3keiInuLFLrLB1cZ1DOt+fz9yyfD0cAh6F5oKtUzzhyTh 1SpCz71M/JhykuF1dYX8lVkHysPWsTb78DBgTVff80uOjI6QpI4u4EsfbvC27Qc+YWiJ Gz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tPYu5d/Svx7ab4/QoyxHhSdtL4EVGLNreteC209+8Co=; b=WWRQppDL+y605vI1bwIGiGaDZ6dULTswfJ9eVlZE1f7tGx+D+i1o8GG/W9og643rhG cbNIL639VQ5mKQIBUdqruA097tlP0qbvHP3HgVBfiljX5dtmfFB+lhtImC8rsb302iCS WQZC3d27gSs2cygWJSyr0kA+g1Nf/KMnoqIKeNfFeO/9vUBS0t3QQoKKPJqJxsbUfCB/ cCB+YIlciSl0Py0RiXsCELg8fUnrwX+UrKQDD64bpMOwQ/O6cZMzLq+3tFG2QTWLbcCN 4YlnVJ0KBRDqoiRLTRDD2gn1J1eoV2LbbdGjvEwLuj3WvufAetqp5mi7q60TwdBp266f kHVA== X-Gm-Message-State: AMke39n2Op1n+SctE2ZjE+AuwnT5HQ93Kt+NZ5hpBKEmGqEbKlKrTPm6kUhaTfuBmNh3qFXvEX9AnBldJlR5dw== X-Received: by 10.31.208.133 with SMTP id h127mr8024489vkg.96.1486854402108; Sat, 11 Feb 2017 15:06:42 -0800 (PST) Original-Received: by 10.31.52.129 with HTTP; Sat, 11 Feb 2017 15:06:41 -0800 (PST) In-Reply-To: <83lgtc3215.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c05::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212250 Archived-At: --001a114e1ce27876910548494490 Content-Type: text/plain; charset=UTF-8 > > Since it's slow in Fundamental mode as well, it's unrelated to > font-lock, and thus to this thread. Display of very long lines is > known to be slow in Emacs. > I believe this is a font-lock problem. If you disable global-font-lock-mode before you open the file, it opens in seconds. If global-font-lock-mode is active Emacs stops responding (I gave up after a few minutes). A quick experiment suggested that the problem is the member `font-lock-extend-region-wholelines' of `font-lock-extend-region-functions' that ensures that whenever font-lock highlights keywords in a region, the full line is rehighlighted (in the case of the example, the full 18M). By removing it, font-locking the file is done in seconds. (I assume that only the visible parts of the buffer is highlighted.) Clearly, simple dropping the function is not a good idea, as keyword fontification could start anywhere on the line, e.g. in the middle of identifiers. A better approach would be to extend the region to include 10KB in either direction, plus ensure that the region isn't split in the middle of identifiers. / Anders Ps. In case anybody is interested in looking further into this, you can use the tool https://github.com/Lindydancer/highlight-refontification to get visual feedback on the font-lock refontification process. --001a114e1ce27876910548494490 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Since it's slow in Fundam= ental mode as well, it's unrelated to
font-lock, and thus to this thread.=C2=A0 Display of very long lines is
known to be slow in Emacs.

I believe th= is is a font-lock problem. If you disable global-font-lock-mode before you = open the file, it opens in seconds. If global-font-lock-mode is active Emac= s stops responding (I gave up after a few minutes).

A quick experiment suggested that the problem is the member `font-lock-ex= tend-region-wholelines' of `font-lock-extend-region-functions' that= ensures that whenever font-lock highlights keywords in a region, the full = line is rehighlighted (in the case of the example, the full 18M). By removi= ng it, font-locking the file is done in seconds. (I assume that only the vi= sible parts of the buffer is highlighted.)

Clearly= , simple dropping the function is not a good idea, as keyword fontification= could start anywhere on the line, e.g. in the middle of identifiers. A bet= ter approach would be to extend the region to include 10KB in either direct= ion, plus ensure that the region isn't split in the middle of identifie= rs.

=C2=A0 =C2=A0/ Anders

Ps. In case anybody is interested in looking further into this, you can us= e the tool=C2=A0https://github.com/Lindydancer/highlight-refontification to g= et visual feedback on the font-lock refontification process.

=
--001a114e1ce27876910548494490--