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.bugs Subject: bug#56682: Fix the long lines font locking related slowdowns Date: Fri, 29 Jul 2022 18:35:21 +0300 Message-ID: <83h7306ifa.fsf@gnu.org> References: <837d46mjen.fsf@gnu.org> <174616cd5c33bfc14b1f@heytings.org> <837d44jr4p.fsf@gnu.org> <83bktghrn0.fsf@gnu.org> <8a3eaeef010995a5da8d@heytings.org> <837d40ds09.fsf@gnu.org> <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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8743"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, 56682@debbugs.gnu.org, larsi@gnus.org, monnier@iro.umontreal.ca To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 29 17:39:16 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 1oHS55-00023B-HP for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Jul 2022 17:39:15 +0200 Original-Received: from localhost ([::1]:47018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oHS54-0000br-KZ for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Jul 2022 11:39:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHS1y-0005SK-Ot for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 11:36:14 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43505) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oHS1y-0005e2-88 for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 11:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oHS1y-0001Y9-2j for bug-gnu-emacs@gnu.org; Fri, 29 Jul 2022 11:36:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Jul 2022 15:36:02 +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.16591089205888 (code B ref 56682); Fri, 29 Jul 2022 15:36:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 29 Jul 2022 15:35:20 +0000 Original-Received: from localhost ([127.0.0.1]:33251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHS1H-0001Wu-Fc for submit@debbugs.gnu.org; Fri, 29 Jul 2022 11:35:19 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:35012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oHS1G-0001We-Hh for 56682@debbugs.gnu.org; Fri, 29 Jul 2022 11:35:18 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:41506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oHS1B-0005UG-8Q; Fri, 29 Jul 2022 11:35:13 -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=UQApwy4MoVV8NO7tk9PUKcpsKgEdISYTwFIBJZC4wT0=; b=rjcAeUi7JP+h TqBHhHIKhLhRLWkMmCAdGqWAM8jDTNc1Q/poiMeO3Yye0sWJJtxzuYxC6Exrf2vgGtThAKj5tm6he nxSgbGSFlp8mmAPBzYVehRRZxIzMvOcMbg4mpFB2JrhD/KBKrX0AIwB38EH6pE6dNmlhx0nQzRKhz UuV9tdyCBQiD8NjaoQkB3w8rKdCriGjNZ8+21D1weRfwEa+GGPN2+M7M3/AuPtms/9RtMOVRXjnuO xpl7gpDKhWLJ1+Kh/p0Eo90KM0TusMqjCldqYbO+sorvdQlGnjzTtN3RuaDSmp9guUZ4ZFBupkcoI pNRsU0YCEIWTlQ+b/NPiqg==; Original-Received: from [87.69.77.57] (port=4222 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 1oHS17-0001wp-UO; Fri, 29 Jul 2022 11:35:13 -0400 In-Reply-To: (message from Gregory Heytings on Fri, 29 Jul 2022 15:19:49 +0000) 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:238192 Archived-At: > Date: Fri, 29 Jul 2022 15:19:49 +0000 > From: Gregory Heytings > cc: gerd.moellmann@gmail.com, 56682-done@debbugs.gnu.org, larsi@gnus.org, > monnier@iro.umontreal.ca > > > Hmm... I'm bothered by this code in handle_fontified_prop: > > > > if (it->narrowed_begv) > > Fnarrow_to_region (make_fixnum (it->narrowed_begv), > > make_fixnum (it->narrowed_zv), Qt); > > > > Hmmm... that code has been on the branch for a week, and I didn't see > particular bugs. Which doesn't mean there are none, of course. It depends on what kind of bugs we expect. I've seen in a debugger that fontification-functions are called with POS outside the narrowed region. But since jit-lock simply does nothing in that case, this is silently ignored. > > This narrows the buffer around window's point position (since this is > > how narrowed_begv and narrowed_zv are computed), but the display > > iterator can be called for position outside this range. This is unlikely > > to happen when the function is called as part of actual redisplay of a > > window, but it can easily happen when the display code is used by other > > primitives, for example vertical-motion or pos-visible-in-window-p. > > What happens then is that fontification-functions are called with the > > argument POS that is outside of the restriction, and that can cause > > errors. (jit-lock simply does nothing in that case, AFAICT.) > > > > Is this intended? > > I'm not sure I understand how this could happen. Can a non-visible part > of the buffer be fontified by fontification-functions when for example > pos-visible-in-window-p is called and eventually returns nil? Yes. Whenever the display code is called, it fontifies the portions of the buffer that it moves through. And that is in general justified: if we didn't fontify, we could produce wrong results from pos-visible-in-window-p, due to faces that change the font height. > At least if I do (pos-visible-in-window-p (point-max)), they are > not: handle_fontified_prop is not even called with it at point-max. > Even with (pos-visible-in-window-p (1+ (window-end))) > fontification-functions are not called. Try with vertical-motion. Visit long-line.xml, go to position 20000, and then do "C-u 200 C-n" or "M-: (vertical-motion 200) RET. Sooner or later you will see that it->current in handle_fontified_prop will be outside of the narrowing. > Should we perhaps be extra careful and add not apply the narrowing when > IT_CHARPOS is not between narrowed_begv and narrowed_zv? I'd rather narrow around IT_CHARPOS in that case. That would be also consistent with what the doc string of fontification-functions now says. Perhaps we should also change what init_iterator does: if the start position with which it's called is outside of the restriction, recompute the restriction using the start point instead of the window's point position. WDYT?