On Thu, 10 Dec 2009 15:00:42 +0800, Kan-Ru Chen <kanru@kanru.info> wrote: > The termlist is already sorted, so this is the patch trying to minimize > the modification of database as suggested in the comment and Carl's > TODO file. Fantastic, Kan-Ru! > My poor profiling shows not much, but some improvement. Now you're just understating for sake of the pun. A 5-6x performance improvement looks great. And I see that as well in my testing: Before: $ time notmuch tag +foo tag:sent real 3m18.067s $ time notmuch tag -foo tag:sent real 3m12.940s After: $ time notmuch tag +foo tag:sent real 0m31.497s $ time notmuch tag -foo tag:sent real 0m28.722s I didn't flush the OS caches between runs, but a subsequent run of the "before" code still performed similarly slow: $ time notmuch tag +foo tag:sent real 3m7.172s And if I *had* used cold caches for every run the benefit of the patch would have looked even better. Anyway, we should get this upstream to the Xapian folks straight away. I expect they'll want to see a patch to the chert backend as well as the flint backend, (but fortunately the relevant code looks very similar if not identical). Thanks again, -Carl