Re: [PATCH] dump: make dump take Xapian write lock
[notmuch-archives.git] / 6a / d77ba8e2c0a22a0a59d640ee9ef52a6f42e2fe
1 Return-Path: <djcb@djcbsoftware.nl>\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 38DFB431FBC\r
6         for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 08:16:47 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id BuO12gVvwLxb for <notmuch@notmuchmail.org>;\r
11         Tue, 24 Nov 2009 08:16:47 -0800 (PST)\r
12 Received: from gw02.mail.saunalahti.fi (gw02.mail.saunalahti.fi\r
13         [195.197.172.116])\r
14         by olra.theworths.org (Postfix) with ESMTP id 1AE19431FBF\r
15         for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 08:16:46 -0800 (PST)\r
16 Received: from djcbsoftware.nl (a88-112-254-208.elisa-laajakaista.fi\r
17         [88.112.254.208])\r
18         (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
19         (No client certificate requested)\r
20         by gw02.mail.saunalahti.fi (Postfix) with ESMTP id 6B24D1398E8;\r
21         Tue, 24 Nov 2009 18:16:39 +0200 (EET)\r
22 Received: from cthulhu.mindcrime.djcbsoftware.nl (localhost [127.0.0.1])\r
23         by djcbsoftware.nl (Postfix) with ESMTP id 747F339C53A;\r
24         Tue, 24 Nov 2009 16:16:58 +0200 (EET)\r
25 Date: Tue, 24 Nov 2009 16:16:58 +0200\r
26 Message-ID: <874ook80th.wl%djcb@djcbsoftware.nl>\r
27 From: Dirk-Jan C. Binnema <djcb.bulk@gmail.com>\r
28 To: Carl Worth <cworth@cworth.org>\r
29 In-Reply-To: <87k4xg634z.fsf@yoom.home.cworth.org>\r
30 References: <87aayggsjp.wl%djcb@djcbsoftware.nl>\r
31         <87iqd43wot.fsf@yoom.home.cworth.org>   <87skc6n3yp.wl%djcb@djcbsoftware.nl>\r
32         <877htifa0e.fsf@yoom.home.cworth.org>   <87pr79yaz1.wl%djcb@djcbsoftware.nl>\r
33         <87k4xg634z.fsf@yoom.home.cworth.org>\r
34 Mail-Reply-To: djcb@djcbsoftware.nl\r
35 User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/23.1 Mule/6.0\r
36         (HANACHIRUSATO)\r
37 Organization: DJCBSoftware\r
38 MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka")\r
39 Content-Type: text/plain; charset=UTF-8\r
40 Content-Transfer-Encoding: quoted-printable\r
41 Cc: "notmuch@notmuchmail.org" <notmuch@notmuchmail.org>\r
42 Subject: Re: [notmuch] interesting project!\r
43 X-BeenThere: notmuch@notmuchmail.org\r
44 X-Mailman-Version: 2.1.12\r
45 Precedence: list\r
46 Reply-To: djcb@djcbsoftware.nl\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: Tue, 24 Nov 2009 16:16:47 -0000\r
57 \r
58 Hi Carl,\r
59 \r
60 >>>>> "Carl" =3D=3D Carl Worth <cworth@cworth.org> writes:\r
61 \r
62     Carl> I agree that trying to support OOM doesn't make sense without\r
63     Carl> testing. But that's why I want to test notmuch with memory-fault\r
64     Carl> injection. We've been doing this with the cairo library with good\r
65     Carl> success for a while.\r
66 \r
67     Carl> As for "unlikely that malloc ever returns NULL", that's simply a\r
68     Carl> system-configuration away (just turn off overcommit). And I can i=\r
69 magine\r
70     Carl> notmuch being used in lots of places, (netbooks, web servers, etc=\r
71 .), so\r
72     Carl> I do want to make it as robust as possible.\r
73 \r
74 That is a very laudable goal! But it's also quite hard to achieve, consider=\r
75 ing\r
76 that both GMime and Xapian may have some different ideas about that. And at\r
77 least in the current code, I see fprintfs in 'malloc-returns-NULL'-cases --\r
78 but fprintf itself will probably allocate memory too. Also, at least now, t=\r
79 he\r
80 bad=C2=A0alloc exceptions for C++ are not caught. Of course, that can be ch=\r
81 anged,\r
82 but it's just to show that these things are hard to get right.\r
83 \r
84     Carl> Thanks for mentioning the hash table. The hash table is one of th=\r
85 e few\r
86     Carl> things that I *am* using from glib right now in notmuch. It's got=\r
87  a\r
88     Carl> couple of bizarre things about it:\r
89 \r
90     Carl>       1. The simpler-appearing g_hash_table_new function is useless\r
91     Carl>          for common cases like hashing strings. It will just leak\r
92     Carl>          memory. So g_hash_table_new_full is the only one worth using.\r
93 \r
94 Hmmm, I never noticed that behavior. Tf you are using dynamically allocated\r
95 strings, GHashTable won't free them for you -- but I can really see how it\r
96 could (given that it takes generic pointers), so you have to free those\r
97 yourself. But any memleaks beyond that?\r
98 \r
99     Carl>       2. There are two lookup functions, g_hash_table_lookup, and\r
100     Carl>          g_hash_table_lookup_extended.\r
101 \r
102     Carl>          So, it might make sense if a hash-table interface supported\r
103     Carl>          these two modes well. What's bizarre about GHashTable though,\r
104     Carl>          is that in the "just a set" case, we only use NULL as the\r
105     Carl>          value when inserting. And distinguish "previously inserted\r
106     Carl>          with NULL" from "never inserted" is the one thing that\r
107     Carl>          g_hash_table_lookup can't do. So I've only found that I could\r
108     Carl>          ever use g_hash_table_lookup_extended, (and pass a pair of\r
109     Carl>          NULLs for the return arguments I don't need).\r
110 \r
111 Hmmn, well in I found that returning NULL for 'not set' works in many cases,\r
112 and it makes it quite easy for that. If you need to distinguish between NULL\r
113 and 'not set', you can use either the _extended version as you mention, or =\r
114 use\r
115 some special NOT_SET static ptr you can compare with (and handle it\r
116 appropriately in the destructor).\r
117 \r
118     Carl> I definitely like the idea of having tiny, focused libraries that=\r
119  do\r
120     Carl> one thing and do it well, (and maybe even some things so tiny that\r
121     Carl> they are actually designed to be copied into the application---li=\r
122 ke\r
123     Carl> with gnulib and with Eric's new hash table).\r
124 \r
125 Ok; glib fills the role pretty well for me, and I don't really pay for the\r
126 parts that I don't use. But tastes differ, no problem ;-)\r
127 \r
128     Carl> Thanks for understanding. :-)\r
129     Carl> And I enjoy the conversation,\r
130 \r
131 Same here :)=20\r
132 \r
133 Best wishes,\r
134 Dirk.\r
135 \r
136 --=20\r
137 Dirk-Jan C. Binnema                  Helsinki, Finland\r
138 e:djcb@djcbsoftware.nl           w:www.djcbsoftware.nl\r
139 pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C\r