1 Return-Path: <tomi.ollila@nixu.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 37DD5429E25
\r
6 for <notmuch@notmuchmail.org>; Wed, 30 Nov 2011 03:53:31 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id Q0uPr0JxJKSH for <notmuch@notmuchmail.org>;
\r
16 Wed, 30 Nov 2011 03:53:29 -0800 (PST)
\r
17 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id D7E82431FB6
\r
21 for <notmuch@notmuchmail.org>; Wed, 30 Nov 2011 03:53:28 -0800 (PST)
\r
22 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
23 by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id
\r
24 pAUBrOE2024733; Wed, 30 Nov 2011 13:53:25 +0200
\r
25 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
26 To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>, notmuch@notmuchmail.org
\r
27 Subject: Re: [PATCH 1/3] test: add functions to count how much times notmuch
\r
29 In-Reply-To: <87aa7evdy8.fsf@gmail.com>
\r
30 References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
31 <1322450895-32523-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
32 <1322450895-32523-2-git-send-email-dmitry.kurochkin@gmail.com>
\r
33 <yf6aa7gj7w5.fsf@taco2.nixu.fi> <87hb1ovsz4.fsf@gmail.com>
\r
34 <yf6mxbfxezr.fsf@taco2.nixu.fi> <87aa7evdy8.fsf@gmail.com>
\r
35 User-Agent: Notmuch/0.10+15~gb5803e9 (http://notmuchmail.org) Emacs/23.3.1
\r
37 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
38 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
39 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
40 Date: Wed, 30 Nov 2011 13:53:24 +0200
\r
41 Message-ID: <yf662i1n7wr.fsf@taco2.nixu.fi>
\r
43 Content-Type: text/plain; charset=us-ascii
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Wed, 30 Nov 2011 11:53:31 -0000
\r
58 On Wed, 30 Nov 2011 01:03:27 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
\r
61 > On Tue, 29 Nov 2011 14:58:00 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
\r
67 > > The (posix) shell command language defines 'Arithmetic Expansion' in
\r
69 > > http://pubs.opengroup.org/onlinepubs/007908799/xcu/chap2.html#tag_001_006_004
\r
71 > > I.e. using format $(( expression )) makes shell doing the arithetic itself
\r
72 > > instead of forking a process (or two!) to do so.
\r
75 > I though expr was a builtin. Now I agree that it is better to replace
\r
76 > it with $(()), even though I still prefer the expr syntax.
\r
78 Actually, I thought also that expr was a builtin. That makes the resolution
\r
79 'forks subshell to execute builtin expr' below wrong. If it were a builtin
\r
80 then bash would also fork only once (to get details right). I re-tested
\r
81 with zsh using 'builtin pwd' and '/bin/pwd' instead of 'expr' -- only one fork
\r
82 in each case. So, those who examined my tests with deep interest also note
\r
86 > > Normally in this case it is not so big deal (and still it isn't, but...)
\r
87 > > In this particular case the shell wrapper counting notmuch launches and
\r
88 > > exec'ing it the wrapper could do this without fork(2)ing a single time
\r
89 > > (i.e. keep the process count unchanged compared to execing notmuch
\r
92 > > Anyway, many opinions; as far as it works I'm fine with it :)
\r
94 > > Now that you feel relaxed, check the results of some further
\r
95 > > experimentation ;) :
\r
97 > > excerpt from man strace:
\r
99 > > -ff If the -o filename option is in effect, each processes
\r
100 > > trace is written to filename.pid where pid is the
\r
101 > > numeric process id of each process.
\r
103 > > Executing rm -f forked.*; strace -ff -o forked bash -c 'echo $(( 5 + 5 ))'
\r
105 > > will output '10' and create just one 'forked.<pid>' file
\r
107 > > Executing rm -f forked.*; strace -ff -o forked bash -c 'echo $(expr 5 + 5)'
\r
109 > > output 10 as expected, but there is now *3* forked.<pid> files !
\r
111 > > bash does not optmize; it forks subshell to execute $(...) and then
\r
112 > > there just works as usual (forks subshell to execute builtin expr))
\r
114 > > Executing rm -f forked.*; strace -ff -o forked bash -c 'echo $(exec expr 5 + 5)'
\r
116 > > (the added 'exec' takes off one fork -- just 2 forked.<pid> files appear).
\r
118 > > I did the same tests using dash, ksh & zsh on linux system, and every one
\r
119 > > of these managed to optimize one fork out in the above 3 fork case.
\r
122 > Thanks for details.
\r