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#63040: 30.0.50; Performance of buf_bytepos_to_charpos when a buffer has large number of markers Date: Mon, 24 Apr 2023 11:17:59 +0000 Message-ID: <87ildlttp4.fsf@localhost> References: <878reiwfm3.fsf@localhost> <83wn22xbj9.fsf@gnu.org> <87bkjdzt0o.fsf@localhost> <83r0s9y22y.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6249"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 63040@debbugs.gnu.org, Stefan Monnier To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 24 13:16:40 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 1pquBT-0001Rj-Dr for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Apr 2023 13:16:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pquAy-0007NF-Dr; Mon, 24 Apr 2023 07:16:13 -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 1pquAt-0007MD-Ej for bug-gnu-emacs@gnu.org; Mon, 24 Apr 2023 07:16:04 -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 1pquAt-0003Hp-1m for bug-gnu-emacs@gnu.org; Mon, 24 Apr 2023 07:16:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pquAs-0005pG-Fm for bug-gnu-emacs@gnu.org; Mon, 24 Apr 2023 07:16:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Apr 2023 11:16:02 +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.168233492222331 (code B ref 63040); Mon, 24 Apr 2023 11:16:02 +0000 Original-Received: (at 63040) by debbugs.gnu.org; 24 Apr 2023 11:15:22 +0000 Original-Received: from localhost ([127.0.0.1]:47682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pquAE-0005o6-20 for submit@debbugs.gnu.org; Mon, 24 Apr 2023 07:15:22 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:35967) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pquAC-0005nt-0C for 63040@debbugs.gnu.org; Mon, 24 Apr 2023 07:15:20 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C9F38240228 for <63040@debbugs.gnu.org>; Mon, 24 Apr 2023 13:15:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1682334913; bh=dgctnNN88xqCvIDk1fUULel8YCKpMB48bXRnTtWQH2g=; h=From:To:Cc:Subject:Date:From; b=NcFmOJgiiJ5DRg2YWiQydOqJ/ZFx8SyEliFcT9Ijcv7nqg9pppZWUVSqkqvel0n70 zd0AsZUebzJE0h04pOay+m0vEjrSNnBXnU73ILpUWqLUb4ipuYrIK18D0q1NAVWw/r 5yfW4WNzFtD8eK37v61u581zLLccqnl8mhDpSsBKUq3if6wLGJyJuggdc1iAEuSYiV AYK9/rwjJIk/e5HMREvCbOlr1XZE/aUAPyWMSVZ7Elo8YADkyUtps5ENs8HvoIlZXc szXYBhdyHoxkJ1BD9IjXPBUmqo8ref8Wasy0B3K0BsXxmXcWWWh5EZ865fxJVqCQeP 34uINqyB4SUBQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Q4jGS51Yqz9rxT; Mon, 24 Apr 2023 13:15:12 +0200 (CEST) In-Reply-To: <83r0s9y22y.fsf@gnu.org> 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:260559 Archived-At: Eli Zaretskii writes: >> Now, it is clearly not efficient enough for my large file. > > Why do you say that? Did you try something and the results were > unsatisfactory? And what is not efficient enough -- the cutoff based > on the number of markers tested or based on the distance? Sorry for not being clear. I was referring to the existing code. "BYTECHAR_DISTANCE_INCREMENT" alone is clearly not efficient in my use case because introducing an addition 50 cut-off improved the performance significantly. Hence, there is some room for improvement in this area. >> Further, the later code creates markers to cache recent results and >> cutting too early may waste this cache. > > And the technique that you tried doesn't waste the cache? I was talking about my technique. It is wasting the cache, and it is the reason why I think that we should find a better approach; not the one I used in the patch. >> Another idea could be moving the cache markers into a separate >> array, so that we can examine them without mixing with all other >> buffer markers. > > Why would that separation be useful? Because the markers created by buf_bytepos_to_charpos are at least 5000 bytes apart. There is no such guarantee for other buffer markers. The while loops "while (best_below_byte < bytepos)" used as fallback (when no nearby marker is found) traverse the buffer char-by-char "("best_below_byte += buf_next_char_len (b, best_below_byte);" and should be strictly inferior compared to well-spaced marker list. However, when the marker list is not well-spaced, looping over all the buffer markers can be a waste. And it looks like I hit exactly such scenario in my setup. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at