I split up the patches as requested and also rebased to current master. Relative to the original patch, I stripped out the bound-to-max change since I could no longer convince myself it was a good idea, and changed BITMAP_* to DOCIDSET_* to clarify that the macros were for working with the doc ID set bitmaps and not just any old bitmaps. As usual, this is also available in my git repo http://awakening.csail.mit.edu/git/notmuch.git as the search-perf-3 branch.