From: Eugene Dzhurinsky <jdevelop@gmail.com>
To: zsh-users@zsh.org
Subject: Re: delay in exitting from zsh shell
Date: Thu, 10 Nov 2011 09:19:46 +0200 [thread overview]
Message-ID: <20111110071946.GA2380@devbox> (raw)
In-Reply-To: <111109195118.ZM6411@torch.brasslantern.com>
[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]
On Wed, Nov 09, 2011 at 07:51:18PM -0800, Bart Schaefer wrote:
> This tends to imply that what's taking those 3-5 seconds is searching
> your history file for duplicate entries in order to enforce the
> hist_save_no_dups option. Also, inc_append_history may allow the file
> to grow to up to 10500 lines for a SAVEHIST of 10000, and those extra
> lines will be trimmed at shell exit.
>
> In more detail, when you use inc_append_history and/or share_history
> along with hist_save_no_dups, zsh re-reads and de-duplicates the entire
> file from disk after it has obtained a lock for it, rather than just
> dumping out the history that is already in memory, because it can't
> know if some other shell has appended something new to the file before
> the lock was obtained. The speed of the disk is inconsequential to the
> CPU expended doing the deduplication.
Okay, I wrote stupid and simple program to de-duplicate lines in history file:
import qualified Data.ByteString.Char8 as C8
import Data.List
import System
import Control.Monad
fixHist = nub . C8.lines
main = do
(fname:_) <- getArgs
hl <- liftM fixHist $ C8.readFile fname
C8.writeFile fname $ C8.unlines hl
function nub is O(n^2) time-complex, and still it takes less than second in
order to read file, optimize it and write it down.
> ./hst .histfile.tst 0.89s user 0.01s system 99% cpu 0.901 total
and I believe that using linked hashtables will improve performance as well.
Am I missing something there if would say that history saving and
de-duplication is suboptimal?
--
Eugene N Dzhurinsky
[-- Attachment #2: Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2011-11-10 7:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-09 22:20 Eugene Dzhurinsky
2011-11-10 1:14 ` Rommel Martinez
2011-11-10 6:56 ` Eugene Dzhurinsky
2011-11-10 3:51 ` Bart Schaefer
2011-11-10 7:19 ` Eugene Dzhurinsky [this message]
2011-11-10 10:10 ` Bart Schaefer
2011-11-10 10:15 ` Eugene Dzhurinsky
2011-11-10 10:46 ` Bart Schaefer
2011-11-10 10:58 ` Eugene Dzhurinsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111110071946.GA2380@devbox \
--to=jdevelop@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).