From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22944 invoked by alias); 8 Feb 2015 20:28:00 -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: 34476 Received: (qmail 10360 invoked from network); 8 Feb 2015 20:27:58 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=Kc1larcG c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=0HtSIViG9nkA:10 a=TtDgqLzfQylvTZovR5AA:9 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <150208122744.ZM5447@torch.brasslantern.com> Date: Sun, 08 Feb 2015 12:27:44 -0800 In-reply-to: <54D78CA8.7010802@thequod.de> Comments: In reply to Daniel Hahler "Performance of _store_cache and _retrieve_cache" (Feb 8, 5:19pm) References: <54D78CA8.7010802@thequod.de> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "Zsh Hackers' List" Subject: Re: Performance of _store_cache and _retrieve_cache MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Feb 8, 5:19pm, Daniel Hahler wrote: } } _store_cache saves the array like this: } } _zsh_all_pkgs=( '02exercicio' '0x10c-asm' ... ) } } The problem is that `source ./pip_allpkgs.slow` takes about 8 seconds, } and is slower than generating the list anew! The slowdown here appears to be with compiling the source'd file into the internal wordcode format before executing it. Even dumping the whole assignment as a single string and then using "eval" on that, is faster than allowing "source" to parse the words directly. We may want to dig further into why that is the case. The following is a LOT faster than either "source" or "eval", but may require recent changes that fix bugs in the parsing of $(...) : _zsh_all_pkgs=( "${(zQ)$(<<\EO:_zsh_all_pkgs '02exercicio' '0x10c-asm' ... EO:_zsh_all_pkgs )}" ) diff --git a/Completion/Base/Utility/_store_cache b/Completion/Base/Utility/_store_cache index 86e72e9..8feaee6 100644 --- a/Completion/Base/Utility/_store_cache +++ b/Completion/Base/Utility/_store_cache @@ -46,8 +46,15 @@ if zstyle -t ":completion:${curcontext}:" use-cache; then for var; do case ${(Pt)var} in (*readonly*) ;; - (*(association|array)*) print -r "$var=( ${(kv@Pqq)^^var} )";; - (*) print -r "$var=${(Pqq)^^var}";; + (*(association|array)*) + # Dump the array as a here-document to reduce parsing overhead + # when reloading the cache with "source" from _retrieve_cache + print -r "$var=( "'"${(zQ)$(<<\EO:'"$var" + print -r "${(kv@Pqq)^^var}" + print -r "EO:$var" + print -r ')}" )' + ;; + (*) print -r "$var=${(Pqq)^^var}";; esac done >! "$_cache_dir/$_cache_ident" else