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#58558: 29.0.50; re-search-forward is slow in some buffers Date: Wed, 14 Dec 2022 12:00:45 +0000 Message-ID: <877cyuurde.fsf@localhost> References: <877d10r21x.fsf@localhost> <87zgdwyvkt.fsf@gnus.org> <87ilkk6ri5.fsf@localhost> <87v8okjei9.fsf@gnus.org> <87tu44jdce.fsf@localhost> <87czasjd9j.fsf@gnus.org> <87k050nio5.fsf@localhost> <87zgdwhw0z.fsf@gnus.org> <83sfjo3tfw.fsf@gnu.org> <878rlfjmjh.fsf@localhost> <87mt9tbbbp.fsf@gnus.org> <8335bl18lo.fsf@gnu.org> <87wn8x9eqb.fsf@gnus.org> <87tu1zd2c6.fsf@localhost> <83h6xzphxm.fsf@gnu.org> <87wn6vbfaa.fsf@localhost> <838rjbpecw.fsf@gnu.org> <87fsdjwb4e.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3988"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58558@debbugs.gnu.org, Eli Zaretskii , larsi@gnus.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 14 13:02:36 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 1p5QT5-0000mI-F1 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 14 Dec 2022 13:02:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5QRs-0004CP-1R; Wed, 14 Dec 2022 07:01:20 -0500 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 1p5QRd-000469-A7 for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 07:01:12 -0500 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 1p5QRa-0007AR-Dl for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 07:01:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5QRa-0005Sw-23 for bug-gnu-emacs@gnu.org; Wed, 14 Dec 2022 07:01:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Dec 2022 12:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58558 X-GNU-PR-Package: emacs Original-Received: via spool by 58558-submit@debbugs.gnu.org id=B58558.167101925920995 (code B ref 58558); Wed, 14 Dec 2022 12:01:02 +0000 Original-Received: (at 58558) by debbugs.gnu.org; 14 Dec 2022 12:00:59 +0000 Original-Received: from localhost ([127.0.0.1]:38713 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5QRW-0005SZ-TR for submit@debbugs.gnu.org; Wed, 14 Dec 2022 07:00:59 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:60107) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5QRV-0005SS-5m for 58558@debbugs.gnu.org; Wed, 14 Dec 2022 07:00:57 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 2168A240029 for <58558@debbugs.gnu.org>; Wed, 14 Dec 2022 13:00:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1671019251; bh=znobLa5hj6Ao2zoLoifo/z/Ms6QlHR9lLTxaGBVuk9Y=; h=From:To:Cc:Subject:Date:From; b=eu54QDB45VpKToGQpuUHc4huRlcdGXVkW/xzTSJGYNag6fjWaoY0umLUsEny65BRT R8B3bFIjhvBUo9zcf5aXSZm0mQDW4zH4dhdb5dAJvqAf9ijBsVkb0eNFwGAjCj5t87 uSbkD6Dk8X36s4z6AtKTUMto0hR3YV57hGF6C1RBefwC2fOEOwGHAam52XfFuXWbdg lSf0xusf1UVV2V/9OvmkMsdn9HG31OgefeunGZJFWgnxe5DNmHOsHxHzIcrWfu6EDW y/Q+3OMxFKkJSdwlJ3tfWExDTmRRnzP5+ih6oG0N79/NSRtEM+9Bot2FO9n4hh7VvI 73AlnABSPAcjA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NXDTW1mjhz6tml; Wed, 14 Dec 2022 13:00:46 +0100 (CET) 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:250928 Archived-At: Stefan Monnier writes: >> My guess: number of markers is growing somehow? > > `buf_bytepos_to_charpos` itself creates markers (using them as a cache > of previous conversions), so that might be why. > > But we only look at the first N markers where N*50 is the distance to > the closest marker found so far. So growth is not sufficient (it's > clearly a part of the reason, tho). What about the following degenerate case: - Most of the buffer markers are located near point-min; - We are searching for position near point-max; - point-max is in order of 21,677,448 (this is my actual file I use for testing) The number of for loop cycles is then min(21,677,448/50 = ~400k, BUF_MARKERS.size()) Of course, my above argument should not matter in theory, when recent search matches are cached by build_marker, but my break build_marker _never_ triggered for some reason. How can build_marker not be triggered? >From my reading of the code, it happens when the following switch does not fire. bool record = bytepos - best_below_byte > 5000; I note that this condition will not trigger if all the markers are above. On the other hand, this particular condition is there for the last 25 years or so. Just brainstorming... -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at