From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4339 invoked by alias); 8 Feb 2015 18:28:03 -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: 34472 Received: (qmail 24216 invoked from network); 8 Feb 2015 18:27:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h= content-transfer-encoding:content-type:content-type:in-reply-to :references:subject:subject:mime-version:user-agent:from:from :date:date:message-id:received:received; s=postfix2; t= 1423420077; bh=Qg4qdQ0jyhaCp4M0A6lcRRqHF5qGkPdWi0xejoUTx78=; b=p rTWzdaynALF/I2mB+tc8/txd+9rIjlyZ4H+J7I30B8AgQcnFfdsnNlcb3kIV24K9 JEgjhSoqLSNDG8NfRU8x2+0lqIHDy/UGT5AgGh+5GGCevnNTpesqhtzH2b/6m/Cx m9DMXDqJ1/d5cSP2GOPdTKi53aHMK+FV+FE1/kn2l8= Message-ID: <54D7AAAD.9000104@thequod.de> Date: Sun, 08 Feb 2015 19:27:57 +0100 From: Daniel Hahler User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Zsh Hackers' List Subject: Re: Performance of _store_cache and _retrieve_cache References: <54D78CA8.7010802@thequod.de> In-Reply-To: <54D78CA8.7010802@thequod.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have profiled this a bit, using: % valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes Src/zsh -f ==1513== Callgrind, a call-graph generating cache profiler ==1513== Copyright (C) 2002-2013, and GNU GPL'd, by Josef Weidendorfer et al. ==1513== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info ==1513== Command: Src/zsh -f ==1513== --1513-- warning: L3 cache found, using its data for the LL simulation. ==1513== For interactive control, run 'callgrind_control -h'. lenny% source ~/.zcompcache/pip_allpkgs.slow lenny% ==1513== ==1513== Events : Ir Dr Dw I1mr D1mr D1mw ILmr DLmr DLmw ==1513== Collected : 16367431118 6050585484 1493446409 47422 484447632 867383 8162 142249 187982 ==1513== ==1513== I refs: 16,367,431,118 ==1513== I1 misses: 47,422 ==1513== LLi misses: 8,162 ==1513== I1 miss rate: 0.0% ==1513== LLi miss rate: 0.0% ==1513== ==1513== D refs: 7,544,031,893 (6,050,585,484 rd + 1,493,446,409 wr) ==1513== D1 misses: 485,315,015 ( 484,447,632 rd + 867,383 wr) ==1513== LLd misses: 330,231 ( 142,249 rd + 187,982 wr) ==1513== D1 miss rate: 6.4% ( 8.0% + 0.0% ) ==1513== LLd miss rate: 0.0% ( 0.0% + 0.0% ) ==1513== ==1513== LL refs: 485,362,437 ( 484,495,054 rd + 867,383 wr) ==1513== LL misses: 338,393 ( 150,411 rd + 187,982 wr) ==1513== LL miss rate: 0.0% ( 0.0% + 0.0% ) valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes Src/zsh -f 491,95s user 0,33s system 92% cpu 8:52,36 total A screenshot of kcachegrind displaying the hot spot is available at: http://i.imgur.com/8ntTLUQ.png I can also provide the callgrind.out.1513 file itself, if this helps. - From Src/parse.c, line 390: for (pp = &ecstrs; (p = *pp); ) { This following condition is never true (but the most expensive): if (!(cmp = p->nfunc - ecnfunc) && !(cmp = strcmp(p->str, s))) > 286166892 call(s) to '__strcmp_ssse3' (libc-2.19.so: strcmp.S) > Jumping 286 166 892 times to parse.c:393 with 286 166 892 executions return p->offs; pp = (cmp < 0 ? &(p->left) : &(p->right)); Thanks, Daniel. On 08.02.2015 17:19, Daniel Hahler wrote: > Hi, > > I've noticed that the completion systems cache mechanism > (_retrieve_cache and _store_cache) is slow with large lists (~50000). > > _store_cache saves the array like this: > > _zsh_all_pkgs=( '02exercicio' '0x10c-asm' ... ) > > and _retrieve_cache then sources it from a file. > > The problem is that `source ./pip_allpkgs.slow` takes about 8 seconds, > and is slower than generating the list anew! > > > When converting the list to be line-separated, the following is much > faster (less than a second): > > _zsh_all_pkgs=(${(f)"$( > This also applies to using the "formatted"/"typed" source file as-is: > Even when using the slow list as is: > > _zsh_all_pkgs=(${$( > > The initial list is generated using: > > _zsh_all_pkgs=( $(curl -s https://pypi.python.org/simple/ \ > | sed -n '/\([^<]\{1,\}\).*/\1/p' \ > | tr '\n' ' ') ) > > > Regards, > Daniel. > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iD8DBQFU16qtfAK/hT/mPgARAgNAAJ9y//ybvVz0MPwu9XzxC/6/js2PSACeLgQp vWt3CCIPbOOeaD0+I0flWWg= =5aY6 -----END PGP SIGNATURE-----