GNU bug report logs -
#77089
[PATCH] Simplify Eshell history de-duplication
Previous Next
To reply to this bug, email your comments to 77089 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
johnw <at> gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#77089
; Package
emacs
.
(Mon, 17 Mar 2025 22:35:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Morgan Smith <Morgan.J.Smith <at> outlook.com>
:
New bug report received and forwarded. Copy sent to
johnw <at> gnu.org, bug-gnu-emacs <at> gnu.org
.
(Mon, 17 Mar 2025 22:35:05 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Tags: patch
Hello!
I was noticing a perceptible delay in starting eshell of 0.838 seconds.
Turns out it was because I had `eshell-hist-ignoredups' set to 'erase
and I had a 5000 line shell-history file.
This patch speeds it up for me to 0.011 seconds.
[0001-Simplify-Eshell-history-de-duplication.patch (text/patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77089
; Package
emacs
.
(Tue, 18 Mar 2025 01:36:03 GMT)
Full text and
rfc822 format available.
Message #8 received at 77089 <at> debbugs.gnu.org (full text, mbox):
>>>>> "MS" == Morgan Smith <Morgan.J.Smith <at> outlook.com> writes:
MS> I was noticing a perceptible delay in starting eshell of 0.838 seconds.
MS> Turns out it was because I had `eshell-hist-ignoredups' set to 'erase and
MS> I had a 5000 line shell-history file.
MS> This patch speeds it up for me to 0.011 seconds.
This is great, I didn’t realize this about ‘delete-duplicate-lines':
Identical lines need not be adjacent, unless the argument
ADJACENT is non-nil (interactively, with a C-u C-u prefix).
This is a more efficient mode of operation, and may be useful
on large regions that have already been sorted.
So it should accomplish just what the original intended to do, but relying on
a likely better optimized function.
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77089
; Package
emacs
.
(Tue, 18 Mar 2025 12:49:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 77089 <at> debbugs.gnu.org (full text, mbox):
> Cc: John Wiegley <johnw <at> gnu.org>
> From: Morgan Smith <Morgan.J.Smith <at> outlook.com>
> Date: Mon, 17 Mar 2025 18:33:50 -0400
>
> I was noticing a perceptible delay in starting eshell of 0.838 seconds.
> Turns out it was because I had `eshell-hist-ignoredups' set to 'erase
> and I had a 5000 line shell-history file.
>
> This patch speeds it up for me to 0.011 seconds.
Thanks, I'm adding Jim to the discussion.
> >From 68160b6c84c2f8946caca5a6be274434f4e3d053 Mon Sep 17 00:00:00 2001
> From: Morgan Smith <Morgan.J.Smith <at> outlook.com>
> Date: Mon, 17 Mar 2025 18:19:21 -0400
> Subject: [PATCH] Simplify Eshell history de-duplication
>
> This also increases performance significantly for large history
> files when `eshell-hist-ignoredups' is set to 'erase.
>
> * lisp/eshell/em-hist.el (eshell-read-history): Run
> `delete-duplicate-lines' on the shell history text instead of
> checking for duplicates at every insertion.
> ---
> lisp/eshell/em-hist.el | 17 ++++++-----------
> 1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
> index 3f779f95acd..78ceed4bd6a 100644
> --- a/lisp/eshell/em-hist.el
> +++ b/lisp/eshell/em-hist.el
> @@ -458,22 +458,17 @@ eshell-read-history
> (ignore-dups eshell-hist-ignoredups))
> (with-temp-buffer
> (insert-file-contents file)
> + (when ignore-dups
> + (delete-duplicate-lines (point-min) (point-max) t
> + (not (eq ignore-dups 'erase))))
> ;; Watch for those date stamps in history files!
> (goto-char (point-max))
> (while (and (< count size)
> (re-search-backward "^[ \t]*\\([^#\n].*\\)[ \t]*$"
> nil t))
> - (let ((history (match-string 1)))
> - (when (or (ring-empty-p ring)
> - (null ignore-dups)
> - (and (not (string-equal
> - (ring-ref ring (1- (ring-length ring)))
> - history))
> - (not (and (eq ignore-dups 'erase)
> - (ring-member ring history)))))
> - (ring-insert-at-beginning
> - ring (subst-char-in-string ?\177 ?\n history))
> - (setq count (1+ count))))))
> + (ring-insert-at-beginning
> + ring (subst-char-in-string ?\177 ?\n (match-string 1)))
> + (setq count (1+ count))))
> (setq eshell-history-ring ring
> eshell-history-index nil
> eshell-hist--new-items 0))))))
> --
> 2.48.1
>
This bug report was last modified 22 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.