From: Tomi Valkeinen Date: Mon, 18 Nov 2013 14:40:52 +0000 (+0200) Subject: notmuch-lib questions and observations X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8cde5ffaaf2b78b5c99e4abd328ab097432f1bc5;p=notmuch-archives.git notmuch-lib questions and observations --- diff --git a/e5/a363a3e1ec4f53c952ede2d8b340fb80c23afc b/e5/a363a3e1ec4f53c952ede2d8b340fb80c23afc new file mode 100644 index 000000000..ff9ec6032 --- /dev/null +++ b/e5/a363a3e1ec4f53c952ede2d8b340fb80c23afc @@ -0,0 +1,196 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id D4CA1431FD4 + for ; Mon, 18 Nov 2013 06:46:23 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.699 +X-Spam-Level: +X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Z9HnpNDogKgD for ; + Mon, 18 Nov 2013 06:46:14 -0800 (PST) +Received: from mail-la0-f47.google.com (mail-la0-f47.google.com + [209.85.215.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 1EBD0431FBF + for ; Mon, 18 Nov 2013 06:46:12 -0800 (PST) +Received: by mail-la0-f47.google.com with SMTP id ep20so4936732lab.34 + for ; Mon, 18 Nov 2013 06:46:11 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=sender:message-id:date:from:user-agent:mime-version:to:subject + :content-type; bh=SeiOMcvjodu43hbCVwySpueCMqz0Vn5dL31JmgCKKOU=; + b=NdtaWyZlGOUCgVp965EzFq072DVOHClNqKmsQ59z7kBoO3pzna6zaVOcgtI0eEYLmO + v0VWFA9dJNv1YVhtMzI1q1pbRhLoFT5PavBAIBuvQB4k9VYO5wAkNlXkG+IKTi6Hh/Bw + AFI+qsCYyb6vQQYKydZIDTZkhMrmF+K1tCuGp4xnVuXmmMkxHpQ5ilgPAewQ+UoH/+93 + 2UCqV/kw3oPPa4Jy62p7DiMtcAPYbxWKV/s5jwqZOhzZz++y/w50UH9Q6ccUf1nxYRy1 + 3GgIBVDEy4jw58YwXpM7665Yul0MyAtrk3zyHOv08EOfzO0o0EKclL3eUJplTcAqLPMx + Hmkw== +X-Received: by 10.112.136.163 with SMTP id qb3mr13852875lbb.14.1384785655593; + Mon, 18 Nov 2013 06:40:55 -0800 (PST) +Received: from [192.168.1.3] (a91-156-160-115.elisa-laajakaista.fi. + [91.156.160.115]) + by mx.google.com with ESMTPSA id vx8sm12543355lbb.8.2013.11.18.06.40.53 + for + (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); + Mon, 18 Nov 2013 06:40:54 -0800 (PST) +Sender: Tomi Valkeinen +Message-ID: <528A26F4.3040006@iki.fi> +Date: Mon, 18 Nov 2013 16:40:52 +0200 +From: Tomi Valkeinen +User-Agent: Mozilla/5.0 (X11; Linux x86_64; + rv:24.0) Gecko/20100101 Thunderbird/24.1.0 +MIME-Version: 1.0 +To: notmuch@notmuchmail.org +Subject: notmuch-lib questions and observations +X-Enigmail-Version: 1.6 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="wmE6ev4CTJF6STxfvwCGAG75IKbnj5iTC" +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 18 Nov 2013 14:46:24 -0000 + +This is an OpenPGP/MIME signed message (RFC 4880 and 3156) +--wmE6ev4CTJF6STxfvwCGAG75IKbnj5iTC +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable + +Hi, + +I found out about notmuch quite recently, and now I've been tinkering +with it, prototyping a GUI client. I have some questions and observations= +: + +1. + +The API seems to be a bit broken. I think many of the functions should +return notmuch_status_t. I encountered this issue with get_header() and +get_date(), which I happened to call after the DB had been changed +twice, leading to Xapian::DatabaseModifiedError. + +Neither function handle the exception, causing a crash, which is +obviously a bug, but even if they did handle the exception they don't +return any sensible error information. Even worse, consider +count_messages(), for which return value of 0 is valid. + +So, as far as I see, many of the funcs should be changed to something lik= +e: + +notmuch_status_t +notmuch_query_count_messages (notmuch_query_t *query, unsigned *count); + + +2. + +This is more about Xapian, I guess. The behavior that a db reader will +start failing if the db has been changed twice is rather bad. If I'm not +mistaken, having a rather long read-only query could be blocked (or, +well, re-tried) forever, if there just happens to be a few db writes +during the read. + +I think a better approach would be to allow only one change to the db if +there are open db readers. If a second db writer tries to open the db, +it would get a failure (instead of the readers). + +Anyone know if this has been discussed, or if my suggestion is plain sill= +y? + +3. + +How is a client using notmuch supposed to find out there are new +messages, and which messages are new? + +My current thought is to make 'notmuch new' run a script that tags the +messages, and make it add a 'new-gui' or such tag to all new messages. +The client would then periodically make a query for that tag, and at the +same time remove the tag for any returned messages. + +4. + +Has there been discussion on returning integer IDs instead of strings +from various functions like notmuch_message_get_message_id() and +notmuch_tags_get()? + +I have two things behind this question: + +- Marshaling strings from native code to managed code requires +allocating memory and copying the string, whereas returning an int is +more or less a no-op [1][2]. E.g. at the moment if I fetch tag 'inbox' +for 10k messages, I'm creating a new 'inbox' string 10k times. I'd +rather fetch an int 10k times, and the 'inbox' string once. + +- My prototype fetches the message ids for all the messages returned by +the query, so that it can later load the message if the user wants to +read it. Fetching and storing only an int per message versus a long-ish +string per message would most likely be good for performance with large +queries. + +5. + +This one is just a vague thought that came to my mind. At the moment +notmuch hides Xapian totally behind notmuch's interface, which probably +makes things simpler (and gives a nice C API), but also (afaik) prevents +using Xapian features that are not at the moment supported in the +notmuch API. + +I wonder how would an approach work where notmuch would be a bit more +like a helper library, allowing full use of Xapian's features but making +it simple to manage notmuch database. So, for example, when making a +query, you'd create a Xapian query with notmuch, and then use Xapian to +run the query. + +I don't have anything clear in mind, and obviously Xapian being C++ +might make the whole idea unimplementable. + + Tomi + + +[1] That's on C#. I wouldn't be surprised if it's also the same with +other higher level languages. + +[2] That's not entirely true, as strings can be passed as is, if the +managed code is given the ownership of the string, and the managed code +will free the string eventually. + + +--wmE6ev4CTJF6STxfvwCGAG75IKbnj5iTC +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.14 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ + +iQIcBAEBAgAGBQJSiib0AAoJEPo9qoy8lh71z68P/3iZg15rtu/7Vwj1VZnZ4OA3 +sDkbptjc0MNa21YxlCQcDzrhW+Da96wtIC+Vfj0ZMrCSAkuU7qaI7DvhpZk1iQCJ +u79/M2klKgEq6YpMZr1HOtUmoAh4FXl5qtZDO3iGtkglGma3bkT7j8c9K24EwMEc +6ZILkvplD/nrGHqnx9cXVVCDrAdwVYXUqnO3BFpDiHip+O7iLRYxBXXdJHoblkmd +mTcU9Z4J2awH+zL+o/h1Khny7U5JdWbyAMJvmASHlyqa/BCXfYORE2htRQBw0USk +qxlGOjWQqEIA7Qrs+KXmq+tbW4Dxdlo11DXPBdHe05E+mSyBkblO7C2lMN+Y9kg0 +WhmOKqt3AYnjFUpqb9M3Fw5jK76FWp9JYPj6TvsYYgwEDvpsDXqnQIWgRCW8xphT +AmKpeL2CpF2pLR5pV6zymWcwyJW8ysYijf8aO/CbLgdlgPYltLnQzxO3jeUplWwF +f8gv22IRUwolJOqQ3J1pQ5F+sBTc6ZwNN81wjSEEizrfOT7O0mTl30Wu7OJRYnUX +bEfzXlKjopo0bO3CUjsq/wv8GDAsjRv0eYTVUuhGc3zKwo1ZjDoHpqgDY/PNSQnX +f+Yshd1+1ModXqup20QSWeVIW86BiNb1MDgDGXsM2wkUyxb7+5FZ+YDO1JBkrllI +ZEGw3PCaDzgZ6tcmgpOM +=702r +-----END PGP SIGNATURE----- + +--wmE6ev4CTJF6STxfvwCGAG75IKbnj5iTC--