From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 440E4429E28 for ; Thu, 26 May 2011 14:47:49 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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 w7DehrVHubty for ; Thu, 26 May 2011 14:47:48 -0700 (PDT) Received: from mail-ww0-f41.google.com (mail-ww0-f41.google.com [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E223E431FB6 for ; Thu, 26 May 2011 14:47:47 -0700 (PDT) Received: by wwi18 with SMTP id 18so4809100wwi.2 for ; Thu, 26 May 2011 14:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:cc:subject:from:to:in-reply-to:references:date :message-id:user-agent:content-transfer-encoding:mime-version :content-type; bh=Pyr3gAlEQ8tLu+6WfCLXTf6XAsWSdocNr9/tbJlIo08=; b=Zu05y+x6JoTFAn/bvQR2FI0jVGrv3LIqGBzX1IVX8j0jtAHGG20bMNKK5QJd4LfkH4 VkPzWGWnUVL1p6GkkI2S4ypzZyIOO4cI08q12/8a78HRqYKt+dfW+bhdnIqzDZROqf2u WmhI6xr+CdFP/ZQ32awY6465+ZABtpAeg6VEc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=cc:subject:from:to:in-reply-to:references:date:message-id :user-agent:content-transfer-encoding:mime-version:content-type; b=JSJ/ruVrztAqV4hyscY/nnwNqktD+dyvNh0pAyIDX6PYr63XE7d+gRLH3adoHNufT6 V7/xvHbuHjBal4qVqijLJGcaKj0xfA14qit4CtdRImn7JyZ0QH6Pgsq5CB17e7K9qsUz hjClP9hMftyfVlAM7h2gMoqvEvUzIhRXSIwaU= Received: by 10.227.54.6 with SMTP id o6mr1330767wbg.61.1306446466515; Thu, 26 May 2011 14:47:46 -0700 (PDT) Received: from localhost (cpc1-sgyl2-0-0-cust47.sgyl.cable.virginmedia.com [80.192.18.48]) by mx.google.com with ESMTPS id fm14sm761526wbb.58.2011.05.26.14.47.43 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 May 2011 14:47:45 -0700 (PDT) Subject: Re: one-time-iterators From: Patrick Totzke To: Austin Clements In-reply-to: References: <1306397849-sup-3304@brick> <877h9d9y5m.fsf@yoom.home.cworth.org> Date: Thu, 26 May 2011 22:47:42 +0100 Message-Id: <1306446359-sup-9475@brick> User-Agent: Sup/git Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-1306446462-339054-32122-5398-1-="; protocol="application/pgp-signature" Cc: notmuch@notmuchmail.org 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: Thu, 26 May 2011 21:47:49 -0000 --=-1306446462-339054-32122-5398-1-= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable hehe, did it again (dropping the list from cc). I need to stop using sup :P thanks Austin. Excerpts from Carl Worth's message of Thu May 26 18:20:21 +0100 2011: > On Thu, 26 May 2011 09:31:19 +0100, Patrick Totzke wrote: > > Wow. This reads really complicated. All I want to say is: > > if I change tags in my search-results view, I get Xapian errors :) > = > Yes, that's frustrating. I wish that we had a more reliable interface a= t > the notmuch library level. But I'm not entirely sure what would be the > best way to do this. Actually, I expected something like this. For this reason each sup instan= ce = locks its index. At the moment I'm going for custom wrapper classes around notmuch.Thread and notmuch.Messages that cache the result of the calls relevant for me. But the real issue seems to be the iterator: It takes an awful lot of time just to copy the thread ids of all threads = from = large a query result. I tried the following in ipython: q=3DDatabase().create_query('*') time tids =3D [t.get_thread_id() for t in q.search_threads()] which results in CPU times: user 7.64 s, sys: 2.06 s, total: 9.70 s Wall time: 9.84 s It would really help if the Query object could return an iterator of thread-ids that makes this copying unnecessary. Is it possible to implement this? Or would this require the same amount of copying to happe= n at a lower level? I have not looked into the code for the bindings or the C code so far, but I guess the Query.search_threads() translates to some = "SELECT id,morestuff from threads" where for me a "SELECT is from threads" would totally suffice. Copying = (in the C code) only the ids so some list that yields an iterator should = be faster. > > The question: How do you solve this in the emacs code? > > do you store all tids of a query? = > = > The emacs code does not use the notmuch library interface like your > python bindings do. Instead, it uses the notmuch command-line tool, (an= d > buffers up the text output by it). = Ahh ok. Thanks for the explanation. Excerpts from Austin Clements's message of Thu May 26 21:18:53 +0100 2011= : > I proposed a solution to this problem a while ago > (id:"AANLkTi=3DKOx8aTJipkiArFVjEHE6zt_JypoASMiiAWBZ6@mail.gmail.com"), > though I haven't tried implementing it yet. Sorry, I wasn't on the list back then. > Though, Patrick, that solution doesn't address your problem.=C2=A0 On t= he > other hand, it's not clear to me what concurrent access semantics > you're actually expecting.=C2=A0 I suspect you don't want the remaining= > iteration to reflect the changes, since your changes could equally > well have affected earlier iteration results.=C2=A0 That's right. = > But if you want a > consistent view of your query results, something's going to have to > materialize that iterator, and it might as well be you (or Xapian > would need more sophisticated concurrency control than it has).=C2=A0 B= ut > this shouldn't be expensive because all you need to materialize are > the document ids; you shouldn't need to eagerly fetch the per-thread > information. = I thought so, but it seems that Query.search_threads() already caches more than the id of each item. Which is as expected because it is designed to return thread objects, not their ids. As you can see above, this _is_ too expensive for me. > Have you tried simply calling list() on your thread > iterator to see how expensive it is? My bet is that it's quite cheap, > both memory-wise and CPU-wise. Funny thing: q=3DDatabase().create_query('*') time tlist =3D list(q.search_threads()) raises a NotmuchError(STATUS.NOT_INITIALIZED) exception. For some reason the list constructor must read mere than once from the iterator. So this is not an option, but even if it worked, it would show the same behaviour as my above test.. would it be very hard to implement a Query.search_thread_ids() ? This name is a bit off because it had to be done on a lower level. Cheers, /p --=-1306446462-339054-32122-5398-1-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk3eyn4ACgkQlDQDZ9fWxaqVKACeJYzPrEY/E60dnP0b9hBGJhvo +VMAoK7XflpIiPibDDHdnRySul/LuQfP =Ez9a -----END PGP SIGNATURE----- --=-1306446462-339054-32122-5398-1-=--