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#63040: 30.0.50; Performance of buf_bytepos_to_charpos when a buffer has large number of markers Date: Mon, 24 Apr 2023 05:24:26 +0300 Message-ID: <83wn22xbj9.fsf@gnu.org> References: <878reiwfm3.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13904"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63040@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 24 04:25:25 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 1pqltN-0003UL-14 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Apr 2023 04:25:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqlt2-0008Un-R4; Sun, 23 Apr 2023 22:25: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 1pqlt0-0008Ud-U8 for bug-gnu-emacs@gnu.org; Sun, 23 Apr 2023 22:25: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 1pqlt0-0008PH-DL for bug-gnu-emacs@gnu.org; Sun, 23 Apr 2023 22:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pqlsz-0002G6-TD for bug-gnu-emacs@gnu.org; Sun, 23 Apr 2023 22:25: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: Mon, 24 Apr 2023 02:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63040 X-GNU-PR-Package: emacs Original-Received: via spool by 63040-submit@debbugs.gnu.org id=B63040.16823030548622 (code B ref 63040); Mon, 24 Apr 2023 02:25:01 +0000 Original-Received: (at 63040) by debbugs.gnu.org; 24 Apr 2023 02:24:14 +0000 Original-Received: from localhost ([127.0.0.1]:47243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqlsD-0002Ez-MG for submit@debbugs.gnu.org; Sun, 23 Apr 2023 22:24:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52892) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pqlsA-0002Ei-K7 for 63040@debbugs.gnu.org; Sun, 23 Apr 2023 22:24:12 -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 1pqls4-0008MO-6O; Sun, 23 Apr 2023 22:24:04 -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=uCMuouM3gMsSktLW5BgIsVMewcAuvrz0IBEpWuc6mr0=; b=iQ1a7NXkY3UM 8JDMmU80R2QqP5uQOAL5//ZUJte88hBx8hAAe3728OmyDD7CbZnMhQuckRddrSIHSYJ8zS8B9o+Bb CFxA0xNIWo+U1IRtPkXQocFwGoqUQwSW8lHbp8s+Dpb5thu7DIUdaruok3XT5ETIz99d5HIBA52AU ebIRrXZyM6HejzgKq2v7DtCuiqHgZHlVAOM5kaGyQe0pj8sUeW01E292dXOCAmd1BOFtZ1/hkfmMC xKtY7x1g3O6zqu/fHKqH97B+LNvI21b7e5RJfVuhcUs2nZo5AnDLKcepx6tcI2ROP3ODyK2QtaM6P s0UXkFCccn4Tqb2e5mdqbw==; 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 1pqls3-0006vg-HO; Sun, 23 Apr 2023 22:24:03 -0400 In-Reply-To: <878reiwfm3.fsf@localhost> (message from Ihor Radchenko on Sun, 23 Apr 2023 19:41:40 +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:260546 Archived-At: > From: Ihor Radchenko > Date: Sun, 23 Apr 2023 19:41:40 +0000 > > When investigating `re-search-forward' performance in > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58558 (bug#58558), I > noticed that buf_bytepos_to_charpos is taking most of the CPU time, > according to perf stats. > > This was partially caused by `parse-sexp-lookup-properties', but even > after working around the text property issue, buf_bytepos_to_charpos > still shows up on top of the perf profile. > > Since one of the apparent bottlenecks in buf_bytepos_to_charpos is > > for (tail = BUF_MARKERS (b); tail; tail = tail->next) > > which obviously scales with the number of markers in buffer, I decided > to add a cut-off parameter, as in the attached patch (number 50 has no > particular motivation underneath). > > Surprisingly, this simple change reduced my Org agenda generation times > from 20 seconds down to 3-4 seconds! > > I am sure that my dumb approach is not the best way to improve the > performance, but this place in buf_bytepos_to_charpos is clearly > something that can be optimized. Interesting. Would it be possible to show the effect of different values of the cut-off on the performance, so we could decide which value to use? Thanks.