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#64391: 30.0.50; buffer narrowing slowdown regression in emacs 29 Date: Sat, 01 Jul 2023 10:07:00 +0300 Message-ID: <835y74rtyj.fsf@gnu.org> References: <877crkcwrm.fsf@ust.hk> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24214"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64391@debbugs.gnu.org, gregory@heytings.org To: Andrew Cohen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 01 09:07:24 2023 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 1qFUhX-00063Y-St for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 01 Jul 2023 09:07:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFUhE-00031A-EW; Sat, 01 Jul 2023 03:07:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUhC-00030m-Of for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2023 03:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFUhC-0002w4-G4 for bug-gnu-emacs@gnu.org; Sat, 01 Jul 2023 03:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qFUhC-0000c0-6Q; Sat, 01 Jul 2023 03:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bugs@gnus.org Resent-Date: Sat, 01 Jul 2023 07:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64391 X-GNU-PR-Package: emacs,gnus Original-Received: via spool by 64391-submit@debbugs.gnu.org id=B64391.16881951992321 (code B ref 64391); Sat, 01 Jul 2023 07:07:02 +0000 Original-Received: (at 64391) by debbugs.gnu.org; 1 Jul 2023 07:06:39 +0000 Original-Received: from localhost ([127.0.0.1]:56277 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qFUgo-0000bM-JP for submit@debbugs.gnu.org; Sat, 01 Jul 2023 03:06:38 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54660) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qFUgn-0000b7-0Z for 64391@debbugs.gnu.org; Sat, 01 Jul 2023 03:06:37 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFUgg-0002a5-U5; Sat, 01 Jul 2023 03:06:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=CpIbZVhOfKDQiQ4ZXhtd7jmGkTwxde0YbvUheP+GPYM=; b=DeLpDOxFOgxImHmELbIW xLUgkR9QzCthORnqmeOgpmA11JT6JXBFwDrGLZcYbPoZ3wqZ63KxUYS1ivbcipU7B4BDP5ITvkFd6 vDLHv/KbLgym5+k1mlSydPk7xdUMe5J9GprevzSy58CjBjUYYhW/HijW97PibAqQUaRUbDj2POWTg XRf3/DxggG2hzwjmutDR5tyBOW8xy1TI3LyaIfhMFYBgL3naSfp53oTKevXYTmmw6q9E4R0Z8jt8P aIrBDoiNPZxnAxnXWtmMGxt//ytkueVjWSHtow4OstwaHxewd/2YQ7lx19U7ZVqHF03L4i4LrzD3A YJLcWcv9AjR66A==; Original-Received: from [87.69.77.57] (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 1qFUge-0000BZ-Tp; Sat, 01 Jul 2023 03:06:29 -0400 In-Reply-To: <877crkcwrm.fsf@ust.hk> (message from Andrew Cohen on Sat, 01 Jul 2023 08:15:25 +0800) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264358 Archived-At: > Cc: Gregory Heytings > From: Andrew Cohen > Date: Sat, 01 Jul 2023 08:15:25 +0800 > > I have noticed a huge slowdown in parsing email headers in gnus. After > some debugging with help from Mattias EngdegÄrd, the problem has been > traced to the narrowing code introduced in > > commit ba9315b1641b483f2bf843c38dcdba0cd1643a55 (HEAD) > Merge: aef803d6c3d a3b654e069e > Author: Gregory Heytings > Date: Thu Nov 24 14:21:30 2022 +0100 > > Merge master into feature/improved-locked-narrowing. > > Gnus populates a buffer with headers from a set of email messages and > then parses them by: narrowing the buffer to the headers for an > individual message; parsing the headers; widening; and then repeating > for the next message. As part of the parsing the headers are "unfolded" > so that each header doesn't include line breaks. I noticed that for a > long list of messages (10,000) this takes between one and two orders of > magnitude more time in Emacs 30 than in Emacs 28. Unfolding all the > headers in the full buffer before the parsing process removes most of > the slowdown. The slowdown seems to grow quadratically with the size of > the buffer. > > The problem seems fairly general and Mattias has produced a simple test > case to demonstrate the issue (code at the end of this message): > > 1. Create a buffer with 100,000 lines each containing two characters "ab". > 2. Loop through the buffer narrowing to each line, and immediately widening > back to the full buffer (so no change is made to the buffer > contents). > 3. Loop through the buffer removing the first character of each line. > > This takes a very long time compared with reversing the order of 2. and 3. Does this problem go away if you set long-line-threshold to nil? Can you show a profile of the processing that takes a long time?