Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Why sourcing a file is not faster than doing a loop with eval, zle -N
- X-seq: zsh-users 22735
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Sebastian Gniazdowski <psprint@xxxxxxxxxxx>
- Subject: Re: Why sourcing a file is not faster than doing a loop with eval, zle -N
- Date: Mon, 19 Jun 2017 13:24:13 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g9o8DKNZ4LAK7UAZfbMNodwpxTGOB4hbz8iCrfOgK1o=; b=taYM6FS3S3hQxhaFf5G2Krm8aCLO8HzPeKgC8MeuESPcJMJYkWJfxVGV6u/c93RDZK eKCRip4wS/F9sZxKZi3celOBHrtoKzzsRNZOQpbf3VJwAsN/47zTqRDqPKq5bnZoWND2 sqm/e4JPJJVG5y7mRLYinlcWPvqWKng+HJw4KgN68UAjllJPHeEaF906fKfwN/EhKscP jGwf37NvV8Xbi5jox+QArX/2rE4EkjrIyLxTWN56hwzVV5J90orP0WCQeSv9yikmDbIq ZqeB+0bA8wpiZ91YKZxpOdxqvVnjmkC+o2tvwB9+Uq1oPR+10NKP+DHM72Gt3NUQ4+eG s3sA==
- In-reply-to: <etPan.594513a8.516100cd.10b2e__10513.1716504276$1497699329$gmane$org@zdharma.org>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mail-followup-to: Sebastian Gniazdowski <psprint@xxxxxxxxxxx>, zsh-users@xxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <etPan.594513a8.516100cd.10b2e__10513.1716504276$1497699329$gmane$org@zdharma.org>
Note:
$ time zsh -c 'repeat 100 . ./fsh_cache'
[...]
./fsh_cache:zle:269: invalid widget `.menu-select'
./fsh_cache:zle:269: invalid widget `.menu-select'
zsh -c 'repeat 100 . ../hacking-private/FSH/fsh_cache' 1.13s user 0.98s system 99% cpu 2.109 total
A lot of "system" time.
$ wc ./fsh_cache
554 2964 58524 ./fsh_cache
$ strace -c zsh -c '. ./fsh_cache'
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000996 0 60022 rt_sigprocmask
60022 calls to rt_sigprocmask sounds a bit much. They seem to be all on
#0 0x00007ffff730d730 in __sigprocmask (how=1, set=0x7fffffffb1c0, oset=0x7fffffffb120) at ../sysdeps/unix/sysv/linux/x86_64/sigprocmask.c:36
#1 0x000000000049b2c0 in signal_unblock (set=...) at signals.c:274
#2 0x00000000004580ac in shingetline () at input.c:148
#3 0x000000000045899b in inputline () at input.c:278
#4 0x000000000045882a in ingetc () at input.c:226
#5 0x000000000046211e in gettok () at lex.c:611
#6 0x000000000046183b in zshlex () at lex.c:275
#7 0x0000000000484825 in parse_event (endtok=37) at parse.c:569
#8 0x0000000000453f6e in loop (toplevel=0, justonce=0) at init.c:146
#9 0x0000000000456db0 in source (s=0x708930 "../hacking-private/FSH/fsh_cache") at init.c:1386
#10 0x0000000000425a0e in bin_dot (name=0x7ffff7ff2550 ".", argv=0x7ffff7ff25b0, ops=0x7fffffffd980, func=0) at builtin.c:5699
#11 0x00000000004105ff in execbuiltin (args=0x7ffff7ff2580, assigns=0x0, bn=0x6dc7c0 <builtins+384>) at builtin.c:485
#12 0x0000000000437fd4 in execcmd_exec (state=0x7fffffffe300, eparams=0x7fffffffdef0, input=0, output=0, how=18, last1=1) at exec.c:3958
#13 0x0000000000431a50 in execpline2 (state=0x7fffffffe300, pcode=131, how=18, input=0, output=0, last1=1) at exec.c:1873
#14 0x0000000000430665 in execpline (state=0x7fffffffe300, slcode=4098, how=18, last1=1) at exec.c:1602
#15 0x000000000042f95a in execlist (state=0x7fffffffe300, dont_change_job=0, exiting=1) at exec.c:1360
#16 0x000000000042efd4 in execode (p=0x7ffff7ff2488, dont_change_job=0, exiting=1, context=0x4c37a2 "cmdarg") at exec.c:1141
#17 0x000000000042ee9c in execstring (s=0x7fffffffe772 ". ../hacking-private/FSH/fsh_cache", dont_change_job=0, exiting=1,
context=0x4c37a2 "cmdarg") at exec.c:1107
#18 0x0000000000456a61 in init_misc (cmd=0x7fffffffe772 ". ../hacking-private/FSH/fsh_cache", zsh_name=0x7fffffffe76a "zsh") at init.c:1292
#19 0x0000000000457e8e in zsh_main (argc=3, argv=0x7fffffffe4f8) at init.c:1678
#20 0x000000000040f7f6 in main (argc=3, argv=0x7fffffffe4f8) at ./main.c:93
Which probably explains why one gets about as many rt_sigprocmask calls as
there are bytes in the file.
$ time zsh -c 'repeat 100 eval "$(<fsh_cache)"'
gives:
1.18s user 0.05s system 99% cpu 1.239 total
With "only" 942 rt_sigprocmask calls according to strace -c.
There's probably scope for optimisation here, though I can't
comment further as I don't know why that signal handling code is
there in the first place.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author