From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.bugs Subject: bug#56682: Fix the long lines font locking related slowdowns Date: Mon, 01 Aug 2022 12:51:47 +0000 Message-ID: References: <83zggwcby5.fsf@gnu.org> <83o7xccagi.fsf@gnu.org> <831qu7daxb.fsf@gnu.org> <83sfmnb7yg.fsf@gnu.org> <837d3ybh5z.fsf@gnu.org> <136c4fe0fc74196714aa@heytings.org> <83pmhp89ov.fsf@gnu.org> <136c4fe0fc39573addc9@heytings.org> <83k07x8738.fsf@gnu.org> <136c4fe0fcdf00ef9a11@heytings.org> <83h73183r7.fsf@gnu.org> <136c4fe0fc0fceb0d752@heytings.org> <838roc8ka7.fsf@gnu.org> <83tu706obt.fsf@gnu.org> <83h7306ifa.fsf@gnu.org> <83edy37pul.fsf@gnu.org> <83pmhn55sk.fsf@gnu.org> <65cb7c73fdc753518d35@heytings.org> <83fsii68o3.fsf@gnu.org> <65cb7c73fdf6704d19d5@heytings.org> <835yje62vz.fsf@gnu.org> <83r1214uz5.fsf@gnu.org> <8c7321f2f39b7a28dd18@heytings.org> <83o7x42l64.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13090"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, 56682@debbugs.gnu.org, larsi@gnus.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 01 14:52:19 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1oIUuA-0003GW-Gz for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Aug 2022 14:52:18 +0200 Original-Received: from localhost ([::1]:40478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIUu9-0000RB-Gd for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Aug 2022 08:52:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIUtv-0000Qb-Uw for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2022 08:52:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIUtt-00043D-Vs for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2022 08:52:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oIUtt-0002Ph-SP for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2022 08:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gregory Heytings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Aug 2022 12:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56682 X-GNU-PR-Package: emacs Original-Received: via spool by 56682-submit@debbugs.gnu.org id=B56682.16593583129254 (code B ref 56682); Mon, 01 Aug 2022 12:52:01 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 1 Aug 2022 12:51:52 +0000 Original-Received: from localhost ([127.0.0.1]:39633 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIUtj-0002PC-Nb for submit@debbugs.gnu.org; Mon, 01 Aug 2022 08:51:52 -0400 Original-Received: from heytings.org ([95.142.160.155]:33764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIUth-0002P3-GY for 56682@debbugs.gnu.org; Mon, 01 Aug 2022 08:51:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1659358308; bh=KX0rKNUBx0HuhumWsoB6X99/u186aJULFw3tbM5IgYk=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=W62ZEewqeQVERVBnHKyjyAn/3CnQ7gVqlmVNZ1V304L8iopAQdXVBt8+5QdwAdnkI F5UjYUos4II+xghQ3tS0ZAyP05vYbjDYHZg8DicxQyj3xToNlYMOnIkpUhQ5Vl65A+ CBioSG9bgpFw6RS1OqFYFnoZvcEMe3qNey7MEM0s2mZJKxJvHcY2qEnIZ5Cu8sYFGp zUQQvTBFgiwdC0EloXRpUmqDqyV6Nh0jDJ6FVffovx69MN7boK3rvq7vkZXY5Sh3ya ikXhmd2qvtcAWE73QixmWk0Lh2lNOF3/XFT0WX/uWREToud4K5Rz8Cr+Pm2/yJsF26 0alJ77VjAF4kw== In-Reply-To: <83o7x42l64.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:238424 Archived-At: > > You can see in the sources that both init_iterator and start_display are > many times called with 'struct it' that was used by the caller, so it > could already have the narrowed_begv and narrowed_zv members initialized > by the caller. If we discover that we want to recalculate these values, > we'd then need to restore the previous value before we return, so that > the caller will see the same values it used before the call. But we > have no easy way of doing that, and moreover, cannot even detect that > these members were initialized. The inability to detect that they were > initialized is due to the fact that we don't initialize 'struct it' > before we call init_iterator, and so these fields can originally have > any arbitrary value. > Thanks, it's much clearer now. > > Which means, for example, that tests like this: > > if (current_buffer->long_line_optimizations_p) > { > if (!it->narrowed_begv <<<<<<<<<<<<<<<<<<<<<<<<<< > || ((pos.charpos < it->narrowed_begv || pos.charpos > it->narrowed_zv) > && (!redisplaying_p || it->line_wrap == TRUNCATE))) > > are not necessarily reliable, because we never initialize narrowed_begv > to zero, AFAICT. Right? > Indeed. That wasn't a problem with the previous code in which narrowed_begv was unconditionally assigned. Now it is. I think the following change should be enough to fix this. Agreed? diff --git a/src/xdisp.c b/src/xdisp.c index 8a19b3bda9..9574d06bd5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3472,6 +3472,9 @@ init_iterator (struct it *it, struct window *w, &it->bidi_it); } + if (current_buffer->long_line_optimizations_p) + it->narrowed_begv = 0; + /* Compute faces etc. */ reseat (it, it->current.pos, true); } > > The other part of my reasoning is that callers of the display code which > are outside redisplay could legitimately move the iterator far from > point: think about pos-visible-in-window-p and its ilk. So, when we are > not called by redisplay, I think it would be preferable to update the > narrowing due to these considerations. > Thanks, this too clarifies what you meant.