From: Jeff King Date: Wed, 27 May 2026 08:57:40 GMT Subject: Re: [PATCH 1/8] pack-bitmap: pass object position to `fill_bitmap_tree()` Message-ID: <20260527085740.GB981444@coredump.intra.peff.net> In-Reply-To: <13191c19b91bc3f5d671b7016b97f2309f12737d.1779207127.git.me@ttaylorr.com> On Tue, May 19, 2026 at 12:12:36PM -0400, Taylor Blau wrote: > In the following commit, callers of `fill_bitmap_tree()` will be > required to check the bit corresponding to their tree before calling > that function. That change will reduce the overhead of setting up and > tearing down stack frames for trees whose bits are already set. > > To prepare for that change, have callers pass in the tree's bit position > in `fill_bitmap_tree()`, which will make the next commit easier to read. > > In the meantime, this change has a surprising and measurable benefit > during bitmap generation, particularly on very large repositories. It is indeed surprising. There's a possible candidate for the speedup here: > @@ -482,8 +479,12 @@ static int fill_bitmap_tree(struct bitmap_writer *writer, > while (tree_entry(&desc, &entry)) { > switch (object_type(entry.mode)) { > case OBJ_TREE: > + pos = find_object_pos(writer, &entry.oid, &found); > + if (!found) > + return -1; > if (fill_bitmap_tree(writer, bitmap, > - lookup_tree(writer->repo, &entry.oid)) < 0) > + lookup_tree(writer->repo, > + &entry.oid), pos) < 0) > return -1; > break; Whenever "found" is false, we cut out early and skip the hash lookup in lookup_tree() entirely. But that should almost never happen! It implies that a reachable object is not in the pack/midx, and thus the bitmaps is not closed (and we'll refuse to generate it). So it really is the case that we do the same operations in a different order. Weird. But the patch itself looks correct to me, and I get ~6% speedup on a from-scratch bitmap generation of linux.git. I guess it could vary between architectures and compilers (I'm using gcc on x86), but since the reorg is setting us up for further optimizations in the next patch, I suppose there's no need to look a gift horse in the mouth. -Peff