From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#71644: 30.0.50; Severe slowdown in larger files with markers beginning in emacs 29+ Date: Fri, 21 Jun 2024 06:19:01 +0000 Message-ID: <87h6dmbyy2.fsf@localhost> References: <86ed8tozub.fsf@gnu.org> <86jzijmo5a.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27934"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 71644@debbugs.gnu.org To: Mitchell Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 21 08:18:16 2024 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 1sKXbD-00070p-Tv for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 21 Jun 2024 08:18:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sKXay-0002F3-8S; Fri, 21 Jun 2024 02:18:00 -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 1sKXaw-0002E7-8P for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 02:17:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sKXav-0004ns-Sn for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 02:17:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sKXaz-0002i2-UA for bug-gnu-emacs@gnu.org; Fri, 21 Jun 2024 02:18:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 21 Jun 2024 06:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71644 X-GNU-PR-Package: emacs Original-Received: via spool by 71644-submit@debbugs.gnu.org id=B71644.171895065110379 (code B ref 71644); Fri, 21 Jun 2024 06:18:01 +0000 Original-Received: (at 71644) by debbugs.gnu.org; 21 Jun 2024 06:17:31 +0000 Original-Received: from localhost ([127.0.0.1]:56675 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKXaU-0002hK-U8 for submit@debbugs.gnu.org; Fri, 21 Jun 2024 02:17:31 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:56271) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sKXaS-0002h4-CW for 71644@debbugs.gnu.org; Fri, 21 Jun 2024 02:17:29 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 45632240028 for <71644@debbugs.gnu.org>; Fri, 21 Jun 2024 08:17:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1718950638; bh=p/bafi0s/IVL59N0a7/DDyV67Fu2QwH8eF99U0uh2YE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=EVA9jjZPI9AS/yNpksmwxYnhmqMFV+w0ka0KLA1z7FPH6Ar2PZsnDi8HsA5FgR00n k9/0eLvJC+kSsIT1frBWSsgrUJ5cz1aO5Q6lWqxX8EYEmL8F43syYScRBxJzFzUVAP jomODkajm0bwOY0HnpvL+z6xBclawcXkBgJYwgGzc8rCU+gl/udqXxAwIvUL1Lkx+d di049qcdXUTFCUAZKX0r3rc2/OcsXpJ4V6S41ToX0slaZRPLJBHspkF8PXIp8edTVt bNf1C3yb4nhTqVHfxjR/7qVdGGWGlV8RxZkPDDINbdds0e8GwTEO04n+kgNL6Qu53C 2LIpgSuO9MYOQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4W56b13G9lz9rxR; Fri, 21 Jun 2024 08:17:17 +0200 (CEST) In-Reply-To: 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:287612 Archived-At: --=-=-= Content-Type: text/plain Mitchell writes: >> If you remove all the non-ASCII characters from the Org file, does the >> slowdown go away? > > Eli, that solved it! The new test file is at > https://gist.github.com/kings2u/2ef0e145f2b42d0a13605b0dc9b6e6e2. I > replaced every non-ASCII character with an "a" so the file still has the > same number of total characters, and in my emacs 30.0 50 build (as of > 2024-05-25), doing Steps 1 to Step 7 gives me abbrev expansions that are as > lighting fast as in emacs 28.2! Hmm. Then, does the attached patch help? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-src-marker.c-buf_bytepos_to_charpos-Limit-marker-sea.patch >From 0bafd288faee8cae33fe4a122f6e3ac73ec10d60 Mon Sep 17 00:00:00 2001 Message-ID: <0bafd288faee8cae33fe4a122f6e3ac73ec10d60.1718950719.git.yantar92@posteo.net> From: Ihor Radchenko Date: Sun, 23 Apr 2023 21:31:46 +0200 Subject: [PATCH] * src/marker.c (buf_bytepos_to_charpos): Limit marker search Limit searching across buffer markers to first 50 markers and thus avoid performance scaling with the number of markers. I got 5x `re-search-forward' speed improvement in my setup with this dumb change. --- src/marker.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/marker.c b/src/marker.c index f016bf9c088..4d7d6621513 100644 --- a/src/marker.c +++ b/src/marker.c @@ -354,8 +354,10 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos) if (b == cached_buffer && BUF_MODIFF (b) == cached_modiff) CONSIDER (cached_bytepos, cached_charpos); - for (tail = BUF_MARKERS (b); tail; tail = tail->next) + int i = 0; + for (tail = BUF_MARKERS (b); tail && i < 50; tail = tail->next) { + i++; CONSIDER (tail->bytepos, tail->charpos); /* If we are down to a range of 50 chars, -- 2.45.1 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--