Subject: Re: bug#69775: [PATCH] Use regexp-opt in dired-omit-regexp

From: Eli Zaretskii <[email-masked]>
Date: Thu, 21 Mar 2024 12:38:28 +0200

> From: [email-masked]
> Date: Sat, 16 Mar 2024 17:15:52 +0000 (UTC)
> Cc: Spencer Baugh <[email-masked]>, [email-masked]
> 
> $ ./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"