From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8405 invoked by alias); 25 Jun 2016 18:01:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38762 Received: (qmail 251 invoked from network); 25 Jun 2016 18:01:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,SPF_HELO_PASS autolearn=no autolearn_force=no version=3.4.1 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Christian Neukirchen Subject: Re: Memory usage of history? Date: Sat, 25 Jun 2016 19:43:48 +0200 Message-ID: <87vb0xi2p7.fsf@gmail.com> References: <20160624134706.GA22704@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: host109-2.natpool.mwn.de In-Reply-To: (Bart Schaefer's message of "Fri, 24 Jun 2016 18:47:47 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Bart Schaefer writes: > On Fri, Jun 24, 2016 at 6:47 AM, Dominik Vogt wrote: >> >> (A colleague >> says his zshs use 200 MB memory each with a history size of a >> million lines). > > To expand on Eric's answer, zsh reads the entire $HISTFILE and retains > the last $HISTSIZE entries. So a large $HISTFILE also slows down > startup, even if it doesn't consume lots of memory. > > I can't imagine anyone having a million useful lines of history. A > few tens of thousands at most. I use the following functions to create an additional, write-only, daily history, and a helper to search it: # Keep an archive of all commands typed. # Initialize using: # cat /data/dump/juno/2015<->/home/chris/.zsh_history | sort -u | grep '^:' | # gawk -F: '{print $0 >> "chris@juno-" strftime("%Y-%m-%d", $2)}' # 04sep2015 +chris+ mkdir -p ~/.zarchive zshaddhistory() { local words=( ${(z)1} ) local w1=$words[1] (( $+aliases[$w1] )) && w1=$aliases[$w1] if [[ -n $1 && $1 != $'\n' && $w1 != " "* ]]; then printf ': %s:0;%s' ${(%):-%D{%s}} "$1" >> \ ~/.zarchive/${(%):-%n@%m-%D{%Y-%m-%d}} fi } # za WORDS... - search .zarchive for WORDS za() { grep -a -r -e "${(j:.*:)@}" ~/.zarchive | sed 's/[ \t]*$//' | sort -r | sort -t';' -k2 -u | sort | sed $'s,^[^:]*/,,; s,::[^;]*;,\u00A0\u00A0,' } alias za=' za' -- Christian Neukirchen http://chneukirchen.org