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#57207: 29.0.50; Fontification is slow after e7b5912b23 (Improvements to long lines handling) Date: Sun, 14 Aug 2022 20:31:03 +0300 Message-ID: <83bksmka08.fsf@gnu.org> References: <87bksmx1j1.fsf@localhost> <5900f208367791fbdfe2@heytings.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17368"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 57207@debbugs.gnu.org, yantar92@gmail.com To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 14 19:32:11 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 1oNHT8-0004Kk-Tl for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Aug 2022 19:32:11 +0200 Original-Received: from localhost ([::1]:55278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNHT7-00009B-NY for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Aug 2022 13:32:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNHT0-00008Y-6K for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 13:32:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNHSz-0004DQ-SZ for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 13:32:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oNHSz-0007Im-O1 for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 13:32:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Aug 2022 17:32:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57207 X-GNU-PR-Package: emacs Original-Received: via spool by 57207-submit@debbugs.gnu.org id=B57207.166049828828029 (code B ref 57207); Sun, 14 Aug 2022 17:32:01 +0000 Original-Received: (at 57207) by debbugs.gnu.org; 14 Aug 2022 17:31:28 +0000 Original-Received: from localhost ([127.0.0.1]:39819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNHSS-0007I1-9W for submit@debbugs.gnu.org; Sun, 14 Aug 2022 13:31:28 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:56620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNHSQ-0007Hl-Ag for 57207@debbugs.gnu.org; Sun, 14 Aug 2022 13:31:26 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNHSL-0004CC-1A; Sun, 14 Aug 2022 13:31:21 -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=G4JErx2jGaX5v0YlWKeQI/h8zuNG2KC5HHnk+VpZyUw=; b=QfZgnekuSWMU 0qHR6KgEKTHqx+/22zF001onrJ/e2I2ZpyjbW0kDg4nRPqQ9NwvvmduA+lU7Ss0dmbtP0X+ud98Yg qImxOdDGZmGDK+oWMSlPX4m8dFKEHz7j02Ql3KtpZhQa47dagMoKNTRSCZx3gjRQFE04y/T7oh9xq 2YDOsCpk8sGVTYUxiWAvVpaj0i4u1e2UeCCP+tI169dzhyNEfO9P6mo2oZ+zbu/4kcQMBbxkLuE4s 1NpoP7MtSowyT83OpV86HPokJUFRNYYaEFbqlLGSmp+17LyorkvfN6wyKy2dgJDoJiHOYYE9ibh7C sSAORvrXJ9VmNxnvbYZf+g==; Original-Received: from [87.69.77.57] (port=4360 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 1oNHSJ-0003Xj-SV; Sun, 14 Aug 2022 13:31:20 -0400 In-Reply-To: <5900f208367791fbdfe2@heytings.org> (message from Gregory Heytings on Sun, 14 Aug 2022 16:08:27 +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:239678 Archived-At: > Cc: 57207@debbugs.gnu.org > Date: Sun, 14 Aug 2022 16:08:27 +0000 > From: Gregory Heytings > > > I am experiencing severe performance degradation on current master. > > > > The degradation happens when working with Org files > > > > [...] > > > > I was able to trigger the slowdown when unfolding headlines hidden using > > 'invisible text property. > > > > Do you have any idea what could be going wrong or how to debug things > > further? > > Can you (a) provide a MRE so that we could track down what's going on > and/or (b) try to set long-line-threshold to a larger value (20000, 50000, > 100000) and see when the performance degradation disappears? Gregory, I suspect that the problem could be in the loop in redisplay_window, where we look for long lines. Changing visibility in Org changes text properties, and that causes MODIFF to be incremented. I actually can cause something similar without Org at all, just by scrolling fast through xdisp.c. You can put a breakpoint inside the 'if' that guards the re-evaluation of the long-lines in redisplay_window, and scroll with C-v through xdisp.c immediately after visiting it -- I hit the breakpoint from time to time, although there are no changes to the buffer except faces placed by fontifications. jit-lock runs under with-silent-modifications, but that only adjusts SAVE_MODIFF to create an illusion of unchanged buffer, it doesn't affect UNCHANGED_MODIFIED. Maybe we should measure the increment in MODIFF across the calls to fontification-functions in handle_fontified_prop, and correct UNCHANGED_MODIFIED by the same increment when fontification-functions return? Ihor, if you set long-line-threshold to a nil value, do the problems go away? If they do, can you put a breakpoint in xdisp.c here: /* Check whether the buffer to be displayed contains long lines. */ if (!NILP (Vlong_line_threshold) && !current_buffer->long_line_optimizations_p && MODIFF - UNCHANGED_MODIFIED > 8) { ptrdiff_t cur, next, found, max = 0, threshold; threshold = XFIXNUM (Vlong_line_threshold); <<<<<<<<<<<<<<<<<<<<<<<<<<< for (cur = BEG; cur < Z; cur = next) { next = find_newline1 (cur, CHAR_TO_BYTE (cur), 0, -1, 1, &found, NULL, true); if (next - cur > max) max = next - cur; if (!found || max > threshold) break; } if (max > threshold) current_buffer->long_line_optimizations_p = true; } and see how frequently this gets called in the same buffer when you do whatever shows the performance degradation?