Re: A systematic way of handling Xapian lock errors?
[notmuch-archives.git] / 8b / aa33affc8104607de690a1d010dd62edfea6c1
1 Return-Path: <tomi.ollila@iki.fi>\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 4830A431FAF\r
6         for <notmuch@notmuchmail.org>; Tue, 22 Jan 2013 05:43:21 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 Ek585k-Kxx7q for <notmuch@notmuchmail.org>;\r
16         Tue, 22 Jan 2013 05:43:19 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id 6A13D431FAE\r
19         for <notmuch@notmuchmail.org>; Tue, 22 Jan 2013 05:43:19 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 66578100086;\r
22         Tue, 22 Jan 2013 15:43:07 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Jani Nikula <jani@nikula.org>, Mark Walters <markwalters1009@gmail.com>,\r
25         notmuch@notmuchmail.org\r
26 Subject: Re: [PATCH 0/5] notmuch batch count\r
27 In-Reply-To: <87fw1u30zz.fsf@nikula.org>\r
28 References: <cover.1358273133.git.jani@nikula.org> <8738y2ui4y.fsf@qmul.ac.uk>\r
29         <m27gndsotu.fsf@guru.guru-group.fi> <87fw1u30zz.fsf@nikula.org>\r
30 User-Agent: Notmuch/0.15+11~ge1e719d (http://notmuchmail.org) Emacs/24.2.1\r
31         (x86_64-unknown-linux-gnu)\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
33         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
34         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
35 Date: Tue, 22 Jan 2013 15:43:07 +0200\r
36 Message-ID: <m2r4ldjpuc.fsf@guru.guru-group.fi>\r
37 MIME-Version: 1.0\r
38 Content-Type: text/plain\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Tue, 22 Jan 2013 13:43:21 -0000\r
52 \r
53 On Mon, Jan 21 2013, Jani Nikula <jani@nikula.org> wrote:\r
54 \r
55 > On Wed, 16 Jan 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
56 >> One could argue that we'd should send json "documents" to notmuch in\r
57 >> stdin and notmuch would output json(/sexp) "documents". That is just\r
58 >> SMOP. I bet Austin would like this solution, especially the part\r
59 >> that involves writing or integrating json parser >;). \r
60 >> I'd be happy with this 'batch' approach. \r
61 >>\r
62 >> I'll be testing this soon, but refrain from reviewing the code\r
63 >> until 0.15 is out.\r
64 >\r
65 > id:87a9s5cp38.fsf@zancas.localnet ;)\r
66 \r
67 OK :D\r
68 \r
69 I started testing:\r
70 \r
71 First a remote script to prepare:\r
72 \r
73 cat > remote-notmuch-test.sh << EOF\r
74 #!/bin/bash\r
75 printf -v ARGS '%q ' "$@" # bash feature\r
76 ssh -S '~'/.ssh/master-notmuch-remote1 -oControlMaster=no 0.1 notmuch $ARGS\r
77 EOF\r
78 chmod 755 remote-notmuch-test.sh\r
79 \r
80 Note 2 things about the script:\r
81 \r
82     1)  '~' is in quotes so shell doesn't expand it -- ssh uses /etc/passwd\r
83         instead of environment variable to get HOME (security feature).\r
84         This can be easly tested by prefixing the command with HOME=/tmp.\r
85     2)  The remote address '0.1' is ignored when control socket is active\r
86         if control socket is down, connection will fail (0.0 connects to\r
87         localhost (I'm not sure which interface in that case)).\r
88 \r
89 Another "script", for emacs:\r
90 \r
91 cat > remote-notmuch-test.el << EOF\r
92 (load "notmuch")\r
93 (setq notmuch-command "/home/too/remote-notmuch-test.sh")\r
94 \r
95 (setq notmuch-saved-searches '(("inbox" . "tag:inbox")\r
96                                ("unread" . "tag:unread")\r
97                                ("contrib" . "tag:notmuch::contrib")\r
98                                ("pushed" . "tag:notmuch::pushed")\r
99                                ("needs-review" . "tag:notmuch::needs-review")\r
100                                ("moreinfo" . "tag:notmuch::moreinfo")\r
101                                ("stale" . "tag:notmuch::stale")\r
102                                ("wip" . "tag:notmuch::wip")\r
103                                ("bug" . "tag:notmuch::bug")\r
104                                ("obsolete" . "tag:notmuch::obsolete")))\r
105 \r
106 (notmuch)\r
107 EOF\r
108 \r
109 First ssh connection with ControlMaster needs to be started\r
110 from one terminal:\r
111 \r
112 ssh -S '~'/.ssh/master-notmuch-remote1 -M remote.host.tld\r
113 \r
114 Then, from another terminal, emacs:\r
115 \r
116 emacs -l remote-notmuch-test.el\r
117 \r
118 works, takes quite a long time -- opening 'all tags' even longer.\r
119 \r
120 Let's edit wrapper script:\r
121 \r
122 cat > remote-notmuch-test.sh << EOF\r
123 #!/bin/bash\r
124 printf -v ARGS '%q ' "$@" # bash feature\r
125 echo /usr/bin/time ./remote-notmuch-test.sh $ARGS >> notmuch-replay.$PPID.log\r
126 ssh -S '~'/.ssh/master-notmuch-remote1 -oControlMaster=no 0.1 notmuch $ARGS\r
127 EOF\r
128 chmod 755 remote-notmuch-test.sh\r
129 \r
130 Now, after emacs -l remote-notmuch-test.el run and all tags opened,\r
131 exit emacs and run the replay script\r
132 \r
133 env TIME='grepme %Us user %Ss system %P cpu %E total' /usr/bin/time sh ../notmuch-replay.1744.log\r
134 last line outputs:\r
135 grepme 0.38s user 0.40s system 1% cpu 0:48.21 total\r
136 \r
137 and wc notmuch-replay.1744.log\r
138   61  240 3787 notmuch-replay.1744.log\r
139 \r
140 and each of the individual command in script printed either\r
141 \r
142 grepme 0.00s user 0.00s system 1% cpu 0:00.78 total or\r
143 grepme 0.00s user 0.00s system 1% cpu 0:00.79 total.\r
144 \r
145 ( 0.785 * 61 = 47.9 so notmuch was wasted elsewhere :)\r
146 \r
147 ---\r
148 \r
149 Ok, now patching 2 notmuch trees, one in local and one in\r
150 remote machine and building and installing those.\r
151 \r
152 Running emacs -l remote-notmuch-test.el \r
153 was fast (not in one second, but just a few).\r
154 \r
155 Unsuprisingly, the "replay" script cannot be run anymore\r
156 as it requires input from stdin, therefore tuning it as follows\r
157 \r
158 cat > remote-notmuch-test.sh << EOF\r
159 #!/bin/bash\r
160 printf -v ARGS '%q ' "$@" # bash feature\r
161 echo `date`: $ARGS >> notmuch-dates.$PPID.log\r
162 echo /usr/bin/time ./remote-notmuch-test.sh $ARGS >> notmuch-replay.$PPID.log\r
163 ssh -S '~'/.ssh/master-notmuch-remote1 -oControlMaster=no 0.1 notmuch $ARGS\r
164 date >> notmuch-dates.$PPID.log\r
165 EOF\r
166 chmod 755 remote-notmuch-test.sh\r
167 \r
168 now, again: emacs -l remote-notmuch-test.el \r
169 then 'echo output of echo : >> notmuch-dates.2678.log'\r
170 and finally opening 'all tags' \r
171 \r
172 cat notmuch-dates.2678.log\r
173 \r
174 Tue 22 Jan 15:04:34 EET 2013: count\r
175 Tue 22 Jan 15:04:35 EET 2013\r
176 Tue 22 Jan 15:04:35 EET 2013: count --batch\r
177 Tue 22 Jan 15:04:36 EET 2013\r
178 Tue 22 Jan 15:04:36 EET 2013: search-tags\r
179 Tue 22 Jan 15:04:37 EET 2013\r
180 output of echo :\r
181 Tue 22 Jan 15:04:45 EET 2013: count\r
182 Tue 22 Jan 15:04:45 EET 2013\r
183 Tue 22 Jan 15:04:45 EET 2013: count --batch\r
184 Tue 22 Jan 15:04:47 EET 2013\r
185 Tue 22 Jan 15:04:47 EET 2013: search-tags\r
186 Tue 22 Jan 15:04:47 EET 2013\r
187 Tue 22 Jan 15:04:47 EET 2013: count --batch\r
188 Tue 22 Jan 15:04:49 EET 2013\r
189 \r
190 3 seconds for first tags and 4 seconds for second tags (approximately :)\r
191 -- quite an improvement 48 seconds.\r
192 \r
193 Also, changes work fine. Now that I forgot my laptop charger to office\r
194 I'll have to wait until tomorrow to do the core review.\r
195 \r
196 (maybe the 2 'count's could be combined in elisp code ;)\r
197 \r
198 >\r
199 > J.\r
200 \r
201 Tomi\r