Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: One more heap optimization trick for zsh < 5.2
- X-seq: zsh-users 21582
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: One more heap optimization trick for zsh < 5.2
- Date: Wed, 18 May 2016 17:16:23 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=RJHFpU/SMQRyN3Y1+U9UcPOoPQARg7l2rIXTi/Rx8Ko=; b=Mum0ocHyWuw14lE6TBW99xLkqnKVp8fcFC1W8XeolI/GSjTp3HewE73fGkj3WkuK5k tIIAwy9zTmBbPpE9KrO60WXaph5dQMh3FOmlfxNNQ8ReB1NSGYJ6YSjrm/twqwSwCGiJ kDKLZZqeO49NYfVoy+ThgWnk0uZrP3Hzb35i7mwtJvBlD3v97/y+r8B7tzzJrafSt3fA vMvTlOgqcKWLeUWHAqcynOUs6zHQEe271F6GqyqaTgQmYjQxO6mqGHVOhyJwZ/zEKIjy xdvaaFe+MqVqWggiQsbiF/nDkBVMPXdRB3uXpY6NjRQ+b07oyLTZlyWIuDpddqVzlqwM 8Yog==
- In-reply-to: <CAH+w=7Z3YUUpNQ+rNAT_FRhecqDVA4Z-oTzbT6KJeeA8SccELQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVDRk2hx9i0T62fnD=v__1RbB9sPr5ni_mHXLojVa4sotA@mail.gmail.com> <160508093530.ZM9686@torch.brasslantern.com> <CAKc7PVDaLHs3xEVJGFn1F2M0BEEOzZFt8enMis7tTmbVKLx12Q@mail.gmail.com> <CAH+w=7Z3YUUpNQ+rNAT_FRhecqDVA4Z-oTzbT6KJeeA8SccELQ@mail.gmail.com>
On 17 May 2016 at 12:18, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Mon, May 16, 2016 at 8:01 AM, Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
>>
>> I was testing the same input with 89k lines. The cause now
>> accidentally clarified. It's about zplugin's shadowing of autoload
>
> Are you sure it's the wrapper and not the autoloading? It's pretty
> common for the first run of an autoloaded function to be slower than
> subsequent runs.
I tested with zplugin and without it, and slow down occurs in first
case. Also, I wanted to move a normal function outside a file to make
it autoloaded function. It started to be painfully slow when used with
zplugin. Luckily I can optimize for 5.1 and use normal hand-made
"autoload -X" body instead of the wrapper. So zplugin's future is in
general safe.
Tried to construct synthetic test (attached). In general the results
are inconsistent. Their order changes depending even on given run.
Could came up with following alerting times:
# ./aload2.zsh.txt
More special autoload:
( aload_fun; ) 3,68s user 0,18s system 98% cpu 3,909 total
Special autoload:
( aload_fun; ) 3,08s user 0,18s system 99% cpu 3,277 total
Normal autoload:
( aload_fun; ) 3,83s user 0,18s system 99% cpu 4,026 total
# ./aload2.zsh.txt
More special autoload:
( aload_fun; ) 2,90s user 0,19s system 99% cpu 3,115 total
Special autoload:
( aload_fun; ) 3,24s user 0,18s system 99% cpu 3,436 total
Normal autoload:
( aload_fun; ) 3,62s user 0,18s system 99% cpu 3,812 total
# ./aload2.zsh.txt
More special autoload:
( aload_fun; ) 2,86s user 0,18s system 99% cpu 3,050 total
Special autoload:
( aload_fun; ) 3,22s user 0,18s system 99% cpu 3,402 total
Normal autoload:
( aload_fun; ) 3,94s user 0,19s system 99% cpu 4,148 total
Best regards,
Sebastian Gniazdowski
#!/bin/zsh
emulate -LR zsh
--reload-and-run () {
local fpath_prefix="$1" autoload_opts="$2" func="$3"
shift 3
unfunction "$func"
local FPATH="$fpath_prefix":"${FPATH}"
builtin autoload $=autoload_opts "$func"
"$func" "$@"
}
fbody='#!/bin/zsh
str=""
str=${(r:100000::_:)str};
arr=( "${(@s::)str}" )
repeat 100; do
arr2=( "${(@M)arr:#(#a1)_}" )
done
#print -rl "${arr2[@]}"
'
echo "$fbody" > aload_fun
#chmod +x aload_fun
# More special autoload
PLUGIN_DIR=`pwd`
eval "
function aload_fun {
--reload-and-run ${(q)PLUGIN_DIR} '' aload_fun
}
"
echo "More special autoload:"
time ( aload_fun )
unfunction aload_fun
# Special autoload
eval "
function aload_fun {
local FPATH=$FPATH:`pwd`
autoload -X
}
"
echo "Special autoload:"
time ( aload_fun )
unfunction aload_fun
# Normal autoload
FPATH+=:`pwd`
autoload aload_fun
echo "Normal autoload:"
time ( aload_fun )
unfunction aload_fun
Messages sorted by:
Reverse Date,
Date,
Thread,
Author