From unknown Sun Jun 22 04:21:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Mar 2024 15:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69775 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 69775@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171034212514780 (code B ref -1); Wed, 13 Mar 2024 15:03:01 +0000 Received: (at submit) by debbugs.gnu.org; 13 Mar 2024 15:02:05 +0000 Received: from localhost ([127.0.0.1]:47156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkQ7I-0003qJ-NA for submit@debbugs.gnu.org; Wed, 13 Mar 2024 11:02:05 -0400 Received: from lists.gnu.org ([209.51.188.17]:54176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkQ7F-0003pn-UR for submit@debbugs.gnu.org; Wed, 13 Mar 2024 11:02:03 -0400 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 1rkQ6U-0007u3-Dp for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:01:14 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkQ6R-0003xm-KQ for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:01:14 -0400 From: Spencer Baugh Date: Wed, 13 Mar 2024 11:01:05 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1710342065; bh=0dKb2rRziZA8F7lSAnUzu8Far3qakV9aYzgOJicYr4k=; h=From:To:Subject:Date; b=y9YnsPHLTQesumYxUGjBtco9HqAaJHvlF18uYk628ZJbxjWY1h8q6c/AZ+nzg8eUf sCKNLu+HAIu8DZRaHBzJzCQ+0hvaE1vCljHZzC+VVWo/jCs3u3l4fsVkTCTlPIL37U znf35o7BhVPBm5mb5In8e8odSkmgiJPmHB7NHSO3DlprrA9f13IHY/4at6c9Hb2h0t kCOxggssMWV6o1iuDSY4gQBb3p/rMacwnNC/N/zUvss0Izm/qhUvA1YJKglraYqc9L yYK4HIxWR+YkevWx2us9fTI6vJJzYl69M0Ll4ald9ABjUJd/XYoAooTr/zN95pB974 hI3DyKXxsxDJw== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Tags: patch In my benchmarking, for large dired buffers, using regexp-opt provides around a 3x speedup in omitting. regexp-opt takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use regexp-opt. (dired-omit-size-limit): Increase, since omitting is now faster. In GNU Emacs 29.2.50 (build 4, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-02-28 built on igm-qws-u22796a Repository revision: 46e23709d37943a20faa735c97af520196a443e9 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.9 (Green Obsidian) Configured using: 'configure 'CFLAGS=-O0 -g3' --with-gif=ifavailable --with-x-toolkit=lucid' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Use-regexp-opt-in-dired-omit-regexp.patch >From f8e3318cab3b3975040efc37225c79c272c4dabe Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 13 Mar 2024 10:57:44 -0400 Subject: [PATCH] Use regexp-opt in dired-omit-regexp In my benchmarking, for large dired buffers, using regexp-opt provides around a 3x speedup in omitting. regexp-opt takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use regexp-opt. (dired-omit-size-limit): Increase, since omitting is now faster. --- lisp/dired-x.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 5a494569989..aa4320a393e 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -77,12 +77,12 @@ dired-vm-read-only-folders (other :tag "non-writable only" if-file-read-only)) :group 'dired-x) -(defcustom dired-omit-size-limit 100000 +(defcustom dired-omit-size-limit 300000 "Maximum size for the \"omitting\" feature. If nil, there is no maximum size." :type '(choice (const :tag "no maximum" nil) integer) :group 'dired-x - :version "29.1") + :version "30.1") (defcustom dired-omit-case-fold 'filesystem "Determine whether \"omitting\" patterns are case-sensitive. @@ -504,14 +504,23 @@ dired-omit-expunge (re-search-forward dired-re-mark nil t)))) count))) +(defvar dired-omit--extension-regexp-cache + nil + "A cache of `regexp-opt' applied to `dired-omit-extensions'. + +This is a cons whose car is a list of strings and whose cdr is a +regexp produced by `regexp-opt'.") + (defun dired-omit-regexp () + (unless (equal dired-omit-extensions (car dired-omit--extension-regexp-cache)) + (setq dired-omit--extension-regexp-cache + (cons dired-omit-extensions (regexp-opt dired-omit-extensions)))) (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "") (if (and dired-omit-files dired-omit-extensions) "\\|" "") (if dired-omit-extensions (concat ".";; a non-extension part should exist - "\\(" - (mapconcat 'regexp-quote dired-omit-extensions "\\|") - "\\)$") + (cdr dired-omit--extension-regexp-cache) + "$") ""))) ;; Returns t if any work was done, nil otherwise. -- 2.39.3 --=-=-=-- From unknown Sun Jun 22 04:21:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Mar 2024 11:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69775 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Spencer Baugh Cc: 69775@debbugs.gnu.org Received: via spool by 69775-submit@debbugs.gnu.org id=B69775.171041405317293 (code B ref 69775); Thu, 14 Mar 2024 11:01:01 +0000 Received: (at 69775) by debbugs.gnu.org; 14 Mar 2024 11:00:53 +0000 Received: from localhost ([127.0.0.1]:48448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkipQ-0004Ur-Ms for submit@debbugs.gnu.org; Thu, 14 Mar 2024 07:00:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkipL-0004UW-W8 for 69775@debbugs.gnu.org; Thu, 14 Mar 2024 07:00:51 -0400 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 1rkiog-00087w-H7; Thu, 14 Mar 2024 07:00:06 -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=efUX4kMpyXb0Kpz3Y1MHQpce2BPQqseY3sZgbqVqRAk=; b=E8TcWBQw+bLy 94Fb8gqPm/EQKTzPyG9S0c9KjNfGA5p+iJyBMiZpbjDRa+QetUz41spopztBqaT5MSK5NM2HjlwrH lV11HSzgeqeAr6pjrdHhVMj/bnD/5hh7/mM01BJH0YU5qALv2v23C1lfnX+tbKUnr3uqS7LhPaWDi PVTz3WJeap9N1zLzXSiN2dKg/EclcMcPwPcsh3y4zTvRnGHe64eCXeYZ0tHrsFArceQx56HM7DNvv aEqdzgHFm6YXbXohbdsuzDKmgz4Go2T6HFxPlgM20SbYgBIRnbaACQNJ7GoSd9p19NtC+Attf8sFP 8VTqb3Dc8YgeAY3smegmtw==; Date: Thu, 14 Mar 2024 13:00:00 +0200 Message-Id: <86o7bh9iz3.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from Spencer Baugh on Wed, 13 Mar 2024 11:01:05 -0400) References: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Spencer Baugh > Date: Wed, 13 Mar 2024 11:01:05 -0400 > > In my benchmarking, for large dired buffers, using regexp-opt provides > around a 3x speedup in omitting. Can you show a recipe for such benchmarking? I'd like to try that on my systems. Also, what is the slowdown in the (improbable, but possible) case where dired-omit-extensions change for each call of dired-omit-regexp? > regexp-opt takes around 5 milliseconds, so to avoid slowing down > omitting in small dired buffers we cache the return value. > > Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. > > * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. > (dired-omit-regexp): Use regexp-opt. > (dired-omit-size-limit): Increase, since omitting is now faster. I'm okay with these changes, but: . the change in the default value of dired-omit-size-limit should be called out in NEWS . please document this variable in the dired-x.texi manual, where we document all the other variables relevant to dired-omit mode. . the doc string of dired-omit-size-limit is embarrassingly unhelpful, so bonus points for fixing that as well Thanks. From unknown Sun Jun 22 04:21:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Mar 2024 17:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69775 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: Spencer Baugh , 69775@debbugs.gnu.org Received: via spool by 69775-submit@debbugs.gnu.org id=B69775.171060940027310 (code B ref 69775); Sat, 16 Mar 2024 17:17:02 +0000 Received: (at 69775) by debbugs.gnu.org; 16 Mar 2024 17:16:40 +0000 Received: from localhost ([127.0.0.1]:56417 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlXeB-00076J-4E for submit@debbugs.gnu.org; Sat, 16 Mar 2024 13:16:39 -0400 Received: from s.wfbtzhsv.outbound-mail.sendgrid.net ([159.183.224.104]:21264) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rlXe8-00075q-WD for 69775@debbugs.gnu.org; Sat, 16 Mar 2024 13:16:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=0X/2cC18rCSordnagn1gr3jYm3bU7gFG1R02vT/wfto=; b=wJXFic9xscHEOboxEKV43CW9TcTLH9OyS1GTWuDoVQIuJ7R03I1wZV657X0Ih9nJfFWS dsW7N4mAFv2Wm2uEX8ktn1dwhWpwJ/ifwHO5FSYFWY0Qxiokxi9PmlonsX0xVVdl7LhjVM iSnJSDp4w5UVdrap624nHdqVjb1SABV9vUT3yiEPxxqyE/dLkncpZjSPAUzRLOY4bYmivo fu82T9S8hIq09LX9mEFKq/na0VvpV+1gIZDgVrYcSERUnBfkHAyl9Hu9oNOy8JXo/FTnVb WGmKk7v4lQfiWkUshF+DOk+j1Ilap4G8TDCRHH8rD6/qhSIdLTbDFt9o8p1GhQrQ== Received: by filterdrecv-5568fdb67c-v8fxn with SMTP id filterdrecv-5568fdb67c-v8fxn-1-65F5D3C8-14 2024-03-16 17:15:52.672183824 +0000 UTC m=+1016483.597694199 Received: from earth.catern.com (unknown) by geopod-ismtpd-2 (SG) with ESMTP id 7q8QUkgeQ9qvYPCBwm8PVw Sat, 16 Mar 2024 17:15:52.433 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=68.160.221.150; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gnu.org Received: from localhost (pool-68-160-221-150.nycmny.fios.verizon.net [68.160.221.150]) by earth.catern.com (Postfix) with ESMTPSA id 0F9C760170; Sat, 16 Mar 2024 17:14:44 +0000 (UTC) From: sbaugh@catern.com In-Reply-To: <86o7bh9iz3.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Mar 2024 13:00:00 +0200") References: <86o7bh9iz3.fsf@gnu.org> Date: Sat, 16 Mar 2024 17:15:52 +0000 (UTC) Message-ID: <8734sqjdyz.fsf@catern.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: u001.v6RTqHFpv1T6krEot6UFAVAJmQ+4h1t8/TfqqE2B07PaXOxtK13VR5j9EFry4QA+eG3SJHI0nnxCQ6apmcQDypHdmeEqFwrpYf4uMG35ybDctg4s4YwR5DSJM0nHrJttlVYHrBFwOWKFxOvRwIBxcoJANK7NqHjpWu+VTb0AIg5YuLJ73EkKS3yHxOa2LDsnGtxI30CDno1kYk1011utMw== X-Entity-ID: u001.oW4JupFKOzCccZAQN2OOFQ== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eli Zaretskii writes: >> From: Spencer Baugh >> Date: Wed, 13 Mar 2024 11:01:05 -0400 >> >> In my benchmarking, for large dired buffers, using regexp-opt provides >> around a 3x speedup in omitting. > > Can you show a recipe for such benchmarking? I'd like to try that on > my systems. > > Also, what is the slowdown in the (improbable, but possible) case > where dired-omit-extensions change for each call of dired-omit-regexp? Yes, run the following after applying the patch: (require 'dired) (require 'dired-x) (require 'cl-lib) (defun dired-omit-regexp-old () (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "") (if (and dired-omit-files dired-omit-extensions) "\\|" "") (if dired-omit-extensions (concat ".";; a non-extension part should exist "\\(" (mapconcat 'regexp-quote dired-omit-extensions "\\|") "\\)$") ""))) (defun my-do-omit (mode) (let ((regexp (cl-case mode (new (dired-omit-regexp)) (old (dired-omit-regexp-old)) (new-uncached (let ((dired-omit--extension-regexp-cache nil)) (dired-omit-regexp))) (t (error "Bad mode %s" mode))))) (dired-mark-if (let ((fn (dired-get-filename nil t))) (and fn (string-match-p regexp fn))) nil))) (defun my-bench-omit (nfiles ntimes) (let ((default-directory (expand-file-name "test-dired-list"))) (make-directory default-directory t) (dolist (file (directory-files "." t "test-file")) (delete-file file)) (dotimes (i nfiles) (write-region "" nil (format "test-file%s" i) nil 'nomessage nil 'excl)) (let ((dired-omit-mode nil)) (with-current-buffer (let ((inhibit-message t)) (dired-noselect default-directory)) (revert-buffer) (message "files %s, ntimes %s: new %s old %s new-uncached %s" nfiles ntimes (car (benchmark-call (lambda () (my-do-omit 'new)) ntimes)) (car (benchmark-call (lambda () (my-do-omit 'old)) ntimes)) (car (benchmark-call (lambda () (my-do-omit 'new-uncached)) ntimes))) )))) (my-bench-omit 1 100) (my-bench-omit 10 100) (my-bench-omit 100 100) (my-bench-omit 1000 100) (my-bench-omit 10000 100) For me, I get: $ ./src/emacs -Q --batch -l ../emacs-29/bench-omit.elc files 1, ntimes 100: new 0.008839979999999999 old 0.018162129 new-uncached 0.031399762 files 10, ntimes 100: new 0.012037615 old 0.040232355000000004 new-uncached 0.037990543 files 100, ntimes 100: new 0.07368538100000001 old 0.314905271 new-uncached 0.10006527300000001 files 1000, ntimes 100: new 0.669103498 old 3.076339984 new-uncached 0.693134644 files 10000, ntimes 100: new 6.336211434 old 30.926320486 new-uncached 6.442762152999999 So the performance improvement is quite substantial for large directories. new-uncached is the performance if dired-omit-extensions changes on each call of dired-omit-regexp. For a directory of 1 file, the overhead of recomputing regexp-opt every time makes the performance perhaps 2x-3x worse, but around 10 files the performance improvement from regexp-opt exceeds the overhead, and above that the uncached version still outperforms the old version substantially. If dired-omit-extensions doesn't change every time, the performance is improved even for directories of 1 file. >> regexp-opt takes around 5 milliseconds, so to avoid slowing down >> omitting in small dired buffers we cache the return value. >> >> Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. >> >> * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. >> (dired-omit-regexp): Use regexp-opt. >> (dired-omit-size-limit): Increase, since omitting is now faster. > > I'm okay with these changes, but: > > . the change in the default value of dired-omit-size-limit should be > called out in NEWS > . please document this variable in the dired-x.texi manual, where we > document all the other variables relevant to dired-omit mode. > . the doc string of dired-omit-size-limit is embarrassingly > unhelpful, so bonus points for fixing that as well > > Thanks. Certainly, updated patch attached. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Use-regexp-opt-in-dired-omit-regexp.patch >From ca0ff9d40b85b281e25b998528c1e1a71b9e70c5 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sat, 16 Mar 2024 17:11:24 +0000 Subject: [PATCH] Use regexp-opt in dired-omit-regexp In my benchmarking, for large dired buffers, using regexp-opt provides around a 3x speedup in omitting. regexp-opt takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. Also, document dired-omit-size-limit better. * doc/misc/dired-x.texi (Omitting Variables): Document dired-omit-size-limit. * etc/NEWS: Announce increase of dired-omit-size-limit. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use regexp-opt. (bug#69775) (dired-omit-size-limit): Increase and improve docs. --- doc/misc/dired-x.texi | 8 ++++++++ etc/NEWS | 6 ++++++ lisp/dired-x.el | 26 ++++++++++++++++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi index 4cad016a0f6..66045c5f759 100644 --- a/doc/misc/dired-x.texi +++ b/doc/misc/dired-x.texi @@ -346,6 +346,14 @@ Omitting Variables match the file name relative to the buffer's top-level directory. @end defvar +@defvar dired-omit-size-limit +If non-@code{nil}, omitting will be skipped if the directory listing +exceeds this size in bytes. Since omitting can be slow for very large +directories, this avoids having to wait before seeing the directory. +This variable is ignored when @code{dired-omit-mode} is called +interactively, such as by @code{C-x M-o}, so you can still enable +omitting in the directory after the initial display. + @cindex omitting additional files @defvar dired-omit-marker-char Temporary marker used by Dired to implement omitting. Should never be used diff --git a/etc/NEWS b/etc/NEWS index b4a1c887f2e..fdface7aa0c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -668,6 +668,12 @@ marked or clicked on files according to the OS conventions. For example, on systems supporting XDG, this runs 'xdg-open' on the files. +*** The default value of 'dired-omit-size-limit' has increased. +After performance improvements to omitting in large directories, the new +default value is 300k, up from 100k. This means 'dired-omit-mode' will +omit files in directories whose directory listing is up to 300 kilobytes +in size. + +++ *** 'dired-listing-switches' handles connection-local values if exist. This allows to customize different switches for different remote machines. diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 62fdd916e69..d7d15028489 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -77,12 +77,17 @@ dired-vm-read-only-folders (other :tag "non-writable only" if-file-read-only)) :group 'dired-x) -(defcustom dired-omit-size-limit 100000 - "Maximum size for the \"omitting\" feature. +(defcustom dired-omit-size-limit 300000 + "Maximum buffer size for `dired-omit-mode'. + +Omitting will be skipped if the directory listing exceeds this size in +bytes. This variable is ignored when `dired-omit-mode' is called +interactively. + If nil, there is no maximum size." :type '(choice (const :tag "no maximum" nil) integer) :group 'dired-x - :version "29.1") + :version "30.1") (defcustom dired-omit-case-fold 'filesystem "Determine whether \"omitting\" patterns are case-sensitive. @@ -506,14 +511,23 @@ dired-omit-expunge (re-search-forward dired-re-mark nil t)))) count))) +(defvar dired-omit--extension-regexp-cache + nil + "A cache of `regexp-opt' applied to `dired-omit-extensions'. + +This is a cons whose car is a list of strings and whose cdr is a +regexp produced by `regexp-opt'.") + (defun dired-omit-regexp () + (unless (equal dired-omit-extensions (car dired-omit--extension-regexp-cache)) + (setq dired-omit--extension-regexp-cache + (cons dired-omit-extensions (regexp-opt dired-omit-extensions)))) (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "") (if (and dired-omit-files dired-omit-extensions) "\\|" "") (if dired-omit-extensions (concat ".";; a non-extension part should exist - "\\(" - (mapconcat 'regexp-quote dired-omit-extensions "\\|") - "\\)$") + (cdr dired-omit--extension-regexp-cache) + "$") ""))) ;; Returns t if any work was done, nil otherwise. -- 2.44.0 --=-=-=-- From unknown Sun Jun 22 04:21:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Mar 2024 10:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69775 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: sbaugh@catern.com Cc: sbaugh@janestreet.com, 69775@debbugs.gnu.org Received: via spool by 69775-submit@debbugs.gnu.org id=B69775.171101756116162 (code B ref 69775); Thu, 21 Mar 2024 10:40:01 +0000 Received: (at 69775) by debbugs.gnu.org; 21 Mar 2024 10:39:21 +0000 Received: from localhost ([127.0.0.1]:35230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rnFpR-0004Cc-5G for submit@debbugs.gnu.org; Thu, 21 Mar 2024 06:39:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rnFpM-0004CN-Uf for 69775@debbugs.gnu.org; Thu, 21 Mar 2024 06:39:20 -0400 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 1rnFod-00053h-6a; Thu, 21 Mar 2024 06:38:31 -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=ZHrAmy1yE40sXHKoVHKfD36VXuHxaoYXDcPeeqJ7Is4=; b=eyb0QxC1V87H +rvfOnb0WdxWSC1agnWwc7NIulRaAhwKBtWjjfFdcgVel1Jf5zCCRnM/URChIvOic9y9ivK5LeFoc MMAk+M8CEJ0AsZFyB+7qHWc81askO38Z3bw+/6ezc6ZKlTsX6tjaSP6QETw/fdlXGJzaXRWAC8pA6 BGLuhMvJNLjLdrYiUzW5jl8b+fVDOo97ef+i/BgY/UTNbFD4B8QD/u5cIMkOMYdxXZ9V8BCAI9Qxw nZ0rNb8kYEvV4czmdKeA6B1/Mmawj2sg98h1mqJr3ObwU/g/U0I7S0MJcU2jtA5MDANLkECWBMgrh /PIIjpOi/yFVW038kkVz/A==; Date: Thu, 21 Mar 2024 12:38:28 +0200 Message-Id: <864jcz3m57.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <8734sqjdyz.fsf@catern.com> (sbaugh@catern.com) References: <86o7bh9iz3.fsf@gnu.org> <8734sqjdyz.fsf@catern.com> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: sbaugh@catern.com > Date: Sat, 16 Mar 2024 17:15:52 +0000 (UTC) > Cc: Spencer Baugh , 69775@debbugs.gnu.org > > $ ./src/emacs -Q --batch -l ../emacs-29/bench-omit.elc > files 1, ntimes 100: new 0.008839979999999999 old 0.018162129 new-uncached 0.031399762 > files 10, ntimes 100: new 0.012037615 old 0.040232355000000004 new-uncached 0.037990543 > files 100, ntimes 100: new 0.07368538100000001 old 0.314905271 new-uncached 0.10006527300000001 > files 1000, ntimes 100: new 0.669103498 old 3.076339984 new-uncached 0.693134644 > files 10000, ntimes 100: new 6.336211434 old 30.926320486 new-uncached 6.442762152999999 > > So the performance improvement is quite substantial for large > directories. > > new-uncached is the performance if dired-omit-extensions changes on each > call of dired-omit-regexp. For a directory of 1 file, the overhead of > recomputing regexp-opt every time makes the performance perhaps 2x-3x > worse, but around 10 files the performance improvement from regexp-opt > exceeds the overhead, and above that the uncached version still > outperforms the old version substantially. SGTM, thanks. > Certainly, updated patch attached. > > +@defvar dired-omit-size-limit > +If non-@code{nil}, omitting will be skipped if the directory listing > +exceeds this size in bytes. I'd rephrase If non-@code{nil}, @code{dired-omit-mode} will be effectively disabled in directories whose listing has size (in bytes) larger than the value of this option. > +*** The default value of 'dired-omit-size-limit' has increased. ^^^ "was" is better there. > +(defcustom dired-omit-size-limit 300000 > + "Maximum buffer size for `dired-omit-mode'. > + > +Omitting will be skipped if the directory listing exceeds this size in ^^^^^^^ "disabled" From unknown Sun Jun 22 04:21:31 2025 X-Loop: help-debbugs@gnu.org Subject: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Mar 2024 13:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69775 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: sbaugh@janestreet.com, 69775@debbugs.gnu.org Received: via spool by 69775-submit@debbugs.gnu.org id=B69775.171120059922135 (code B ref 69775); Sat, 23 Mar 2024 13:30:02 +0000 Received: (at 69775) by debbugs.gnu.org; 23 Mar 2024 13:29:59 +0000 Received: from localhost ([127.0.0.1]:55482 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ro1Re-0005kv-C1 for submit@debbugs.gnu.org; Sat, 23 Mar 2024 09:29:59 -0400 Received: from s.wfbtzhsw.outbound-mail.sendgrid.net ([159.183.224.105]:12152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ro1Ra-0005kQ-1g for 69775@debbugs.gnu.org; Sat, 23 Mar 2024 09:29:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=m2Jx+hSymSiTiLpRXofnPBlKPW4c9i15BBC2cGfx3WU=; b=PV5P4kDXnLY59RW+pstQ8QJJhVv9Ag/p2L9gGOo2XYt4unazWw4mrZuUKLEsDogZtOyc syFPsPP0dLaWlMwdzTIEIt3HAqnth29RLhsRT1YzPcnXC1ix7gfXJJ8RGny/cYPn4qFP2i Rvqpc0Idz28qghr9EUymrJ3VBlRQLLc9gjsrAA7cw0s3j0Ntks2eE6NUWnfn9Fe90Pw6oU +CLlvMI+fm4j4K1G5F46+OipA/m2GX+hCj5es5s/gpoBpgaXSv5NTKII48E4lefy3g+YPh B878fZQWeXDu4IqBFe4090a8tCtuNRsxUN6B9/76864OG2iqLYo2h85P+2Sf0/RA== Received: by recvd-6fc499775c-sfjtq with SMTP id recvd-6fc499775c-sfjtq-1-65FED922-F 2024-03-23 13:29:06.343065723 +0000 UTC m=+405002.857703640 Received: from earth.catern.com (unknown) by geopod-ismtpd-21 (SG) with ESMTP id guRUgrWlT1WeDTeKT107dA Sat, 23 Mar 2024 13:29:06.162 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=127.0.0.1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gnu.org Received: from localhost (localhost [127.0.0.1]) by earth.catern.com (Postfix) with ESMTPSA id B36BE6006B; Sat, 23 Mar 2024 09:29:05 -0400 (EDT) From: sbaugh@catern.com In-Reply-To: <864jcz3m57.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 21 Mar 2024 12:38:28 +0200") References: <86o7bh9iz3.fsf@gnu.org> <8734sqjdyz.fsf@catern.com> <864jcz3m57.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Sat, 23 Mar 2024 13:29:06 +0000 (UTC) Message-ID: <87sf0h6pr2.fsf@catern.com> MIME-Version: 1.0 X-SG-EID: u001.v6RTqHFpv1T6krEot6UFAVAJmQ+4h1t8/TfqqE2B07P9mDCopJ1hNJown0Giu3fh1hTzAF6l60VLcZPW3/fWwFYzccUrjBAcFsjYvHUAObCQTReQ9YYoKhAtKsCf+fkQVFWIGdGnhK1FuAhmGkkTaHzKWmOlUhYoF5JLgsk/7Xhw9xkuBGxjQPSkP4u1zWCK8KMRfs6AbF0kKCiG3JabDQ== X-Entity-ID: u001.oW4JupFKOzCccZAQN2OOFQ== Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Eli Zaretskii writes: >> From: sbaugh@catern.com >> Date: Sat, 16 Mar 2024 17:15:52 +0000 (UTC) >> Cc: Spencer Baugh , 69775@debbugs.gnu.org >> >> $ ./src/emacs -Q --batch -l ../emacs-29/bench-omit.elc >> files 1, ntimes 100: new 0.008839979999999999 old 0.018162129 new-uncached 0.031399762 >> files 10, ntimes 100: new 0.012037615 old 0.040232355000000004 new-uncached 0.037990543 >> files 100, ntimes 100: new 0.07368538100000001 old 0.314905271 new-uncached 0.10006527300000001 >> files 1000, ntimes 100: new 0.669103498 old 3.076339984 new-uncached 0.693134644 >> files 10000, ntimes 100: new 6.336211434 old 30.926320486 new-uncached 6.442762152999999 >> >> So the performance improvement is quite substantial for large >> directories. >> >> new-uncached is the performance if dired-omit-extensions changes on each >> call of dired-omit-regexp. For a directory of 1 file, the overhead of >> recomputing regexp-opt every time makes the performance perhaps 2x-3x >> worse, but around 10 files the performance improvement from regexp-opt >> exceeds the overhead, and above that the uncached version still >> outperforms the old version substantially. > > SGTM, thanks. > >> Certainly, updated patch attached. >> >> +@defvar dired-omit-size-limit >> +If non-@code{nil}, omitting will be skipped if the directory listing >> +exceeds this size in bytes. > > I'd rephrase > > If non-@code{nil}, @code{dired-omit-mode} will be effectively > disabled in directories whose listing has size (in bytes) larger > than the value of this option. > >> +*** The default value of 'dired-omit-size-limit' has increased. > ^^^ > "was" is better there. > >> +(defcustom dired-omit-size-limit 300000 >> + "Maximum buffer size for `dired-omit-mode'. >> + >> +Omitting will be skipped if the directory listing exceeds this size in > ^^^^^^^ > "disabled" Adjusted all these, here's the new patch. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Use-regexp-opt-in-dired-omit-regexp.patch >From 7ae71f994814f3eb7bad3387608e8c0cbe0d2d68 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sat, 16 Mar 2024 17:11:24 +0000 Subject: [PATCH] Use regexp-opt in dired-omit-regexp In my benchmarking, for large dired buffers, using regexp-opt provides around a 3x speedup in omitting. regexp-opt takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. Also, document dired-omit-size-limit better. * doc/misc/dired-x.texi (Omitting Variables): Document dired-omit-size-limit. * etc/NEWS: Announce increase of dired-omit-size-limit. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use regexp-opt. (bug#69775) (dired-omit-size-limit): Increase and improve docs. --- doc/misc/dired-x.texi | 9 +++++++++ etc/NEWS | 6 ++++++ lisp/dired-x.el | 26 ++++++++++++++++++++------ 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi index 4cad016a0f6..726b6653d0d 100644 --- a/doc/misc/dired-x.texi +++ b/doc/misc/dired-x.texi @@ -346,6 +346,15 @@ Omitting Variables match the file name relative to the buffer's top-level directory. @end defvar +@defvar dired-omit-size-limit +If non-@code{nil}, @code{dired-omit-mode} will be effectively disabled +in directories whose listing has size (in bytes) larger than the value +of this option. Since omitting can be slow for very large directories, +this avoids having to wait before seeing the directory. This variable +is ignored when @code{dired-omit-mode} is called interactively, such as +by @code{C-x M-o}, so you can still enable omitting in the directory +after the initial display. + @cindex omitting additional files @defvar dired-omit-marker-char Temporary marker used by Dired to implement omitting. Should never be used diff --git a/etc/NEWS b/etc/NEWS index 50f0ee4a1aa..9324d9f1dcf 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -692,6 +692,12 @@ marked or clicked on files according to the OS conventions. For example, on systems supporting XDG, this runs 'xdg-open' on the files. +*** The default value of 'dired-omit-size-limit' was increased. +After performance improvements to omitting in large directories, the new +default value is 300k, up from 100k. This means 'dired-omit-mode' will +omit files in directories whose directory listing is up to 300 kilobytes +in size. + +++ *** 'dired-listing-switches' handles connection-local values if exist. This allows to customize different switches for different remote machines. diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 62fdd916e69..753d3054d2f 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -77,12 +77,17 @@ dired-vm-read-only-folders (other :tag "non-writable only" if-file-read-only)) :group 'dired-x) -(defcustom dired-omit-size-limit 100000 - "Maximum size for the \"omitting\" feature. +(defcustom dired-omit-size-limit 300000 + "Maximum buffer size for `dired-omit-mode'. + +Omitting will be disabled if the directory listing exceeds this size in +bytes. This variable is ignored when `dired-omit-mode' is called +interactively. + If nil, there is no maximum size." :type '(choice (const :tag "no maximum" nil) integer) :group 'dired-x - :version "29.1") + :version "30.1") (defcustom dired-omit-case-fold 'filesystem "Determine whether \"omitting\" patterns are case-sensitive. @@ -506,14 +511,23 @@ dired-omit-expunge (re-search-forward dired-re-mark nil t)))) count))) +(defvar dired-omit--extension-regexp-cache + nil + "A cache of `regexp-opt' applied to `dired-omit-extensions'. + +This is a cons whose car is a list of strings and whose cdr is a +regexp produced by `regexp-opt'.") + (defun dired-omit-regexp () + (unless (equal dired-omit-extensions (car dired-omit--extension-regexp-cache)) + (setq dired-omit--extension-regexp-cache + (cons dired-omit-extensions (regexp-opt dired-omit-extensions)))) (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "") (if (and dired-omit-files dired-omit-extensions) "\\|" "") (if dired-omit-extensions (concat ".";; a non-extension part should exist - "\\(" - (mapconcat 'regexp-quote dired-omit-extensions "\\|") - "\\)$") + (cdr dired-omit--extension-regexp-cache) + "$") ""))) ;; Returns t if any work was done, nil otherwise. -- 2.41.0 --=-=-=-- From unknown Sun Jun 22 04:21:31 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Spencer Baugh Subject: bug#69775: closed (Re: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp) Message-ID: References: <86wmpsyitn.fsf@gnu.org> X-Gnu-PR-Message: they-closed 69775 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 69775@debbugs.gnu.org Date: Sat, 23 Mar 2024 17:33:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1711215182-11597-1" This is a multi-part message in MIME format... ------------=_1711215182-11597-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #69775: [PATCH] Use regexp-opt in dired-omit-regexp which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 69775@debbugs.gnu.org. --=20 69775: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D69775 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1711215182-11597-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 69775-done) by debbugs.gnu.org; 23 Mar 2024 17:32:40 +0000 Received: from localhost ([127.0.0.1]:42686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ro5EW-00030A-0P for submit@debbugs.gnu.org; Sat, 23 Mar 2024 13:32:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ro5ET-0002zs-0q for 69775-done@debbugs.gnu.org; Sat, 23 Mar 2024 13:32:38 -0400 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 1ro4ts-0003Ct-1l; Sat, 23 Mar 2024 13:11:20 -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=pZxJqP5rcEOI0B5ofBu17sU3oq3UG54a4ueRJBngyzE=; b=RyO/5DbkVzVY 94hbLcaUZsn3YinZCiIzV2CpdEEdbMfObNPV3MJg8pFUnu0fDHgulTW8NRRntA2AHkkBwbbbfjF6f 9WB+mK3QiVPMTgX+py1l7i8LaEp2/ruAy4fzbNmSgm76c/urBO+ag2QowpxA0Y1JZ4Wev+MtQRnoE YC6OVjKKAUrD6n4KGdF7KoEHiulMc6c13nfqg5eMbRYzg8tpJ/KL20JNYhD8plraMxoBfU25SZXSl q/fUbPOppf7wVUrAZrtEFnjC9RE2kz8bMb1ThZLW3BkeaI22KmbFTHKtynasyTlSOt9Rejk47KdTE p1J+gFqYB4ifo+n04icLRw==; Date: Sat, 23 Mar 2024 19:11:16 +0200 Message-Id: <86wmpsyitn.fsf@gnu.org> From: Eli Zaretskii To: sbaugh@catern.com In-Reply-To: <87sf0h6pr2.fsf@catern.com> (sbaugh@catern.com) Subject: Re: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp References: <86o7bh9iz3.fsf@gnu.org> <8734sqjdyz.fsf@catern.com> <864jcz3m57.fsf@gnu.org> <87sf0h6pr2.fsf@catern.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 69775-done Cc: sbaugh@janestreet.com, 69775-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: sbaugh@catern.com > Date: Sat, 23 Mar 2024 13:29:06 +0000 (UTC) > Cc: sbaugh@janestreet.com, 69775@debbugs.gnu.org > > Adjusted all these, here's the new patch. Thanks, installed on master, and closing the bug. ------------=_1711215182-11597-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 13 Mar 2024 15:02:05 +0000 Received: from localhost ([127.0.0.1]:47156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkQ7I-0003qJ-NA for submit@debbugs.gnu.org; Wed, 13 Mar 2024 11:02:05 -0400 Received: from lists.gnu.org ([209.51.188.17]:54176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkQ7F-0003pn-UR for submit@debbugs.gnu.org; Wed, 13 Mar 2024 11:02:03 -0400 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 1rkQ6U-0007u3-Dp for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:01:14 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rkQ6R-0003xm-KQ for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 11:01:14 -0400 From: Spencer Baugh To: bug-gnu-emacs@gnu.org Subject: [PATCH] Use regexp-opt in dired-omit-regexp Date: Wed, 13 Mar 2024 11:01:05 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1710342065; bh=0dKb2rRziZA8F7lSAnUzu8Far3qakV9aYzgOJicYr4k=; h=From:To:Subject:Date; b=y9YnsPHLTQesumYxUGjBtco9HqAaJHvlF18uYk628ZJbxjWY1h8q6c/AZ+nzg8eUf sCKNLu+HAIu8DZRaHBzJzCQ+0hvaE1vCljHZzC+VVWo/jCs3u3l4fsVkTCTlPIL37U znf35o7BhVPBm5mb5In8e8odSkmgiJPmHB7NHSO3DlprrA9f13IHY/4at6c9Hb2h0t kCOxggssMWV6o1iuDSY4gQBb3p/rMacwnNC/N/zUvss0Izm/qhUvA1YJKglraYqc9L yYK4HIxWR+YkevWx2us9fTI6vJJzYl69M0Ll4ald9ABjUJd/XYoAooTr/zN95pB974 hI3DyKXxsxDJw== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Tags: patch In my benchmarking, for large dired buffers, using regexp-opt provides around a 3x speedup in omitting. regexp-opt takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use regexp-opt. (dired-omit-size-limit): Increase, since omitting is now faster. In GNU Emacs 29.2.50 (build 4, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-02-28 built on igm-qws-u22796a Repository revision: 46e23709d37943a20faa735c97af520196a443e9 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.9 (Green Obsidian) Configured using: 'configure 'CFLAGS=-O0 -g3' --with-gif=ifavailable --with-x-toolkit=lucid' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Use-regexp-opt-in-dired-omit-regexp.patch >From f8e3318cab3b3975040efc37225c79c272c4dabe Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 13 Mar 2024 10:57:44 -0400 Subject: [PATCH] Use regexp-opt in dired-omit-regexp In my benchmarking, for large dired buffers, using regexp-opt provides around a 3x speedup in omitting. regexp-opt takes around 5 milliseconds, so to avoid slowing down omitting in small dired buffers we cache the return value. Since omitting is now 3x faster, increase dired-omit-size-limit by 3x. * lisp/dired-x.el (dired-omit--extension-regexp-cache): Add. (dired-omit-regexp): Use regexp-opt. (dired-omit-size-limit): Increase, since omitting is now faster. --- lisp/dired-x.el | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lisp/dired-x.el b/lisp/dired-x.el index 5a494569989..aa4320a393e 100644 --- a/lisp/dired-x.el +++ b/lisp/dired-x.el @@ -77,12 +77,12 @@ dired-vm-read-only-folders (other :tag "non-writable only" if-file-read-only)) :group 'dired-x) -(defcustom dired-omit-size-limit 100000 +(defcustom dired-omit-size-limit 300000 "Maximum size for the \"omitting\" feature. If nil, there is no maximum size." :type '(choice (const :tag "no maximum" nil) integer) :group 'dired-x - :version "29.1") + :version "30.1") (defcustom dired-omit-case-fold 'filesystem "Determine whether \"omitting\" patterns are case-sensitive. @@ -504,14 +504,23 @@ dired-omit-expunge (re-search-forward dired-re-mark nil t)))) count))) +(defvar dired-omit--extension-regexp-cache + nil + "A cache of `regexp-opt' applied to `dired-omit-extensions'. + +This is a cons whose car is a list of strings and whose cdr is a +regexp produced by `regexp-opt'.") + (defun dired-omit-regexp () + (unless (equal dired-omit-extensions (car dired-omit--extension-regexp-cache)) + (setq dired-omit--extension-regexp-cache + (cons dired-omit-extensions (regexp-opt dired-omit-extensions)))) (concat (if dired-omit-files (concat "\\(" dired-omit-files "\\)") "") (if (and dired-omit-files dired-omit-extensions) "\\|" "") (if dired-omit-extensions (concat ".";; a non-extension part should exist - "\\(" - (mapconcat 'regexp-quote dired-omit-extensions "\\|") - "\\)$") + (cdr dired-omit--extension-regexp-cache) + "$") ""))) ;; Returns t if any work was done, nil otherwise. -- 2.39.3 --=-=-=-- ------------=_1711215182-11597-1--