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 CD3A6429E26 for ; Sun, 11 Dec 2011 16:12:34 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.29 X-Spam-Level: X-Spam-Status: No, score=-2.29 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3, T_MIME_NO_TEXT=0.01] 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 yJgivdcXVG1s for ; Sun, 11 Dec 2011 16:12:34 -0800 (PST) Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id B6DE1429E25 for ; Sun, 11 Dec 2011 16:12:33 -0800 (PST) Received: from zancas.localnet (fctnnbsc36w-156034079193.pppoe-dynamic.High-Speed.nb.bellaliant.net [156.34.79.193]) (authenticated bits=0) by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id pBC0CTmA028366 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Sun, 11 Dec 2011 20:12:32 -0400 Received: from bremner by zancas.localnet with local (Exim 4.77) (envelope-from ) id 1RZtVN-00012z-9y; Sun, 11 Dec 2011 20:12:29 -0400 From: David Bremner To: Notmuch Mail Subject: Re: experimental logging branch In-Reply-To: <87obvfu6t5.fsf@zancas.localnet> References: <87obvfu6t5.fsf@zancas.localnet> User-Agent: Notmuch/0.10.2+80~g144897e (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Sun, 11 Dec 2011 20:12:13 -0400 Message-ID: <87liqik5r6.fsf@zancas.localnet> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" 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, 12 Dec 2011 00:12:34 -0000 --=-=-= Content-Transfer-Encoding: quoted-printable On Sat, 10 Dec 2011 23:27:02 -0400, David Bremner wrote: > This uses the jlog library (http://labs.omniti.com/labs/jlog) > to atomically log messages in pub-sub model. Some more explanations.=20 Part 1: pub-what? =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D What is pub-sub? Conceptually you can think of it as a set of queues where each "published" message is magically replicated and put in the queue of each "subscriber". Of course in practice one only needs one queue, and to keep track of how far each subscriber has read. So, we have a queue, and one head pointer per subscriber. We can discard anything in the queue that all of the subscribers have read past. In jlog this data structure is on disk, which is why it is called "durable". This means there are no sockets to communicate between the publisher (notmuch) and the subscribers (e.g. a proposed tag synching tool, described more below). The interact via a directory (currently under .notmuch). Because the datastructure on disk is not completely trivial (not that fancy either, but more than a stream of bytes) both writers and readers need to use the jlog library to interact with the queue. "notmuch log" is one such reader. I'm not that invested in jlog, but I looked around and didn't find any other similar solutions that had some atomicity guarantees without some kind of broker (read yet another daemon running on the machine).=20=20 > On this branch you can enable logging of tagging operations by=20 >=20 > notmuch config set log.subscribers 'name1;name2;name3' The command "notmuch log" lets one read the queue from the shell. "notmuch log name1" dumps any messages (only the string content; there are timestamps but these are currently ignored) queued for "name1" to stdout. So one can interact with this queue without learning about the jlog api (or more precisely, without copy-pasting the example programs From=20the wiki like I did). Part 2: Ok, but what is it good for? =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D OK, so there is this tool, but why should we bother? I think tag synchronization is one of the big missing pieces for notmuch (probably because Carl only reads mail on one computer ;) ). There are various hacks, but they are all based on dump/restore. nmbug only manages to have (mostly) acceptable performance because the query of "tags starting with notmuch::" (done in a hacky way) restricts the output to manageable levels. I think what we need is a way to to update incrementally, and obvious way to do this for tags is to keep track of additions and deletions, and maintain a "shadow" of the database on disk in some form more amenable to synchronization. This could be a directory/file tree like the initial versions of nmbug, or some slightly fancier thing like the bare git repo used by current versions of nmbug. With the jlog patches to notmuch, one or more scripts could run (in cron, or perhaps using something like inotify) to treat the log of tagging operations as essentially a patch to update the "shadow tag database". In my case I would probably want two subscribers, one for my whole tag database, and one to update the set published in nmbug.=20=20 A more wild idea would be to use the queue to help resolve contention for write access to the Xapian database. Clients would write into a queue, and notmuch would read operations to perform out of the queue. To be honest, I'm not sure this is really better than just having clients use locking and blocking/retrying.=20=20 Part 3: Couldn't we do this with hooks? =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Conceptually, yes. But there are a few things to figure out: 1) hooks are a CLI feature, not a library feature. Do we want the library to support something like hooks? 2) The cost of an exec per elementary tagging operation is quite high; maybe some kind of batching could help with this. 3) Atomicity/locking would need to be dealt with by each script. For example git update-index, used by nmbug (and git add) will fail if some other operation is in progress. But having a hook block sounds a bit nightmarish. None of this stuff is my area of expertise; maybe some of you have clearer ideas about how this could/should be handled. d --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iJwEAQECAAYFAk7lRt0ACgkQTiiN/0Um85lGeAP/ZQ2xnfSN4vjJmSElhkIfUvdp WsVW42q/pOPdN3qi4nwYU/1V938BvHToDl+ZQbD2OI2/3wVh/4SEYGrQIJMHz7Ty pw9gYEKv4OV0BqYoVjza0i+BwW4hjiYNvKatyTqkeXmYDxCyKULF6egF9lNS+F1p 16naS+96+vqwaSX326E= =eY1q -----END PGP SIGNATURE----- --=-=-=--