From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58558: 29.0.50; re-search-forward is slow in some buffers Date: Tue, 13 Dec 2022 08:27:34 -0500 Message-ID: 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> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6226"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 58558@debbugs.gnu.org, Lars Ingebrigtsen , Eli Zaretskii To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 13 14:28:15 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 1p55KR-0001Mn-1q for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Dec 2022 14:28:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p55KI-00066z-2V; Tue, 13 Dec 2022 08:28:06 -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 1p55KF-00064h-Oo for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2022 08:28:03 -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 1p55KE-0006U7-05 for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2022 08:28:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p55KD-0001JS-Rf for bug-gnu-emacs@gnu.org; Tue, 13 Dec 2022 08:28:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Dec 2022 13:28:01 +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.16709380655037 (code B ref 58558); Tue, 13 Dec 2022 13:28:01 +0000 Original-Received: (at 58558) by debbugs.gnu.org; 13 Dec 2022 13:27:45 +0000 Original-Received: from localhost ([127.0.0.1]:60380 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p55Jx-0001JB-1g for submit@debbugs.gnu.org; Tue, 13 Dec 2022 08:27:45 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19375) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p55Jv-0001J5-He for 58558@debbugs.gnu.org; Tue, 13 Dec 2022 08:27:43 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 4957544220F; Tue, 13 Dec 2022 08:27:37 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BDF3E44221E; Tue, 13 Dec 2022 08:27:35 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1670938055; bh=Q7FBVUqjaY03YnxQjg0cUIWvTQoZXzPmDBGebUnbscg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=i1HLel5N0AMI7eGR0SZO9x/1KEddDKU/k9SdoziLu3Sj1uctChFkTFBEcNExUNSY0 EuxU7Q+0uQPBtWuSA6mJa/qMdE7N6ka0M7dqNlHQb4kZDmwHLE0PbjQ4M76dbLqpZb DIX/IIJdFE9hp+H2Eoq1fnxADfFEu0SwLXKOi4/Odofo6jBdlcbUmwL1nzyXlzB4nn yFaGD94RSZBZ0ymQvZ7Nb4QBXbAh9njl3oY3ZLmV7YcX3jMfRQAQWa7l9XF4cgz+dV eboYeSBxWYYnSeB9XsZhgA6qtJyFE0uCY+UZrBs1AoRt+2O8DJWUOns7GKzohOwV22 SNABpQaBM7NZw== Original-Received: from pastel (unknown [45.72.193.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 911331201E4; Tue, 13 Dec 2022 08:27:35 -0500 (EST) In-Reply-To: <87tu1zd2c6.fsf@localhost> (Ihor Radchenko's message of "Tue, 13 Dec 2022 10:28:57 +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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:250833 Archived-At: > The fraction of buf_bytepos_to_charpos increases over repeated benchmark > runs. [...] > Any ideas what I can do further? As usual, the problem is either that we call this function too often or that it takes too much time every time we call it so: - Try and figure out who is the most frequent caller of `buf_bytepos_to_charpos` during your benchmark. Most calls to this function can usually be eliminated by changing the code to keep track of both bytes and chars at the same time. Actually, most of the time we already have the char info somewhere nearby, so it might be a simple change. `gprof` can often give that info. - Try and figure out why `buf_bytepos_to_charpos` is so slow. Last time we tweaked that code, AFAIK, is commit b300052fb4ef1261519b0fd57f5eb186c2d10295. My debugging approach for those cases is the following: DEFVAR_LISP a new variable in which you put a vector of N integers (initialized to 0), and then at various "interesting" points in the `buf_bytepos_to_charpos`, increment one of the vector elements. This way you can see from ELisp how many times each "interesting" point was executed. IOW, I do the profiling counters by hand. Stefan