Message ID | f1eb194b9fdf5e385610fa3c0ddee22b89cf4f0e.1588633810.git.me@ttaylorr.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | pack-bitmap: use bitmaps for traversals with '--filter=tree:0' | expand |
Taylor Blau <me@ttaylorr.com> writes: > But now that we support tree filters, there's opportunity for savings. A > tree:depth=0 filter means we can avoid accessing trees entirely, since > we know we won't them (or any of the subtrees or blobs they point to). "we know we won't _have_ them"? > @@ -506,7 +506,8 @@ static int should_include(struct commit *commit, void *_data) > static struct bitmap *find_objects(struct bitmap_index *bitmap_git, > struct rev_info *revs, > struct object_list *roots, > - struct bitmap *seen) > + struct bitmap *seen, > + struct list_objects_filter_options *filter) > { > struct bitmap *base = NULL; > int needs_walk = 0; > @@ -599,8 +600,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git, > show_data.bitmap_git = bitmap_git; > show_data.base = base; > > - traverse_commit_list(revs, show_commit, show_object, > - &show_data); > + traverse_commit_list_filtered(filter, revs, > + show_commit, show_object, > + &show_data, NULL); And then finally the change in step 1/4 pays off. > } > > return base; > @@ -999,7 +1001,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, > > if (haves) { > revs->ignore_missing_links = 1; > - haves_bitmap = find_objects(bitmap_git, revs, haves, NULL); > + haves_bitmap = find_objects(bitmap_git, revs, haves, NULL, > + filter); > reset_revision_walk(); > revs->ignore_missing_links = 0; > > @@ -1007,7 +1010,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, > BUG("failed to perform bitmap walk"); > } > > - wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap); > + wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap, > + filter); > > if (!wants_bitmap) > BUG("failed to perform bitmap walk"); > diff --git a/t/perf/p5310-pack-bitmaps.sh b/t/perf/p5310-pack-bitmaps.sh > index 75ccf9f4e3..b3e725f031 100755 > --- a/t/perf/p5310-pack-bitmaps.sh > +++ b/t/perf/p5310-pack-bitmaps.sh > @@ -91,4 +91,9 @@ test_perf 'pack to file (partial bitmap)' ' > git pack-objects --use-bitmap-index --all pack2b </dev/null >/dev/null > ' > > +test_perf 'rev-list with tree filter (partial bitmap)' ' > + git rev-list --use-bitmap-index --count --objects --all \ > + --filter=tree:0 >/dev/null > +' > + > test_done
On Mon, May 04, 2020 at 10:40:43PM -0700, Junio C Hamano wrote: > Taylor Blau <me@ttaylorr.com> writes: > > > But now that we support tree filters, there's opportunity for savings. A > > tree:depth=0 filter means we can avoid accessing trees entirely, since > > we know we won't them (or any of the subtrees or blobs they point to). > > "we know we won't _have_ them"? Yep, fixed. Thanks for pointing it out. > > @@ -506,7 +506,8 @@ static int should_include(struct commit *commit, void *_data) > > static struct bitmap *find_objects(struct bitmap_index *bitmap_git, > > struct rev_info *revs, > > struct object_list *roots, > > - struct bitmap *seen) > > + struct bitmap *seen, > > + struct list_objects_filter_options *filter) > > { > > struct bitmap *base = NULL; > > int needs_walk = 0; > > @@ -599,8 +600,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git, > > show_data.bitmap_git = bitmap_git; > > show_data.base = base; > > > > - traverse_commit_list(revs, show_commit, show_object, > > - &show_data); > > + traverse_commit_list_filtered(filter, revs, > > + show_commit, show_object, > > + &show_data, NULL); > > And then finally the change in step 1/4 pays off. Woohoo! > > } > > > > return base; > > @@ -999,7 +1001,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, > > > > if (haves) { > > revs->ignore_missing_links = 1; > > - haves_bitmap = find_objects(bitmap_git, revs, haves, NULL); > > + haves_bitmap = find_objects(bitmap_git, revs, haves, NULL, > > + filter); > > reset_revision_walk(); > > revs->ignore_missing_links = 0; > > > > @@ -1007,7 +1010,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, > > BUG("failed to perform bitmap walk"); > > } > > > > - wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap); > > + wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap, > > + filter); > > > > if (!wants_bitmap) > > BUG("failed to perform bitmap walk"); > > diff --git a/t/perf/p5310-pack-bitmaps.sh b/t/perf/p5310-pack-bitmaps.sh > > index 75ccf9f4e3..b3e725f031 100755 > > --- a/t/perf/p5310-pack-bitmaps.sh > > +++ b/t/perf/p5310-pack-bitmaps.sh > > @@ -91,4 +91,9 @@ test_perf 'pack to file (partial bitmap)' ' > > git pack-objects --use-bitmap-index --all pack2b </dev/null >/dev/null > > ' > > > > +test_perf 'rev-list with tree filter (partial bitmap)' ' > > + git rev-list --use-bitmap-index --count --objects --all \ > > + --filter=tree:0 >/dev/null > > +' > > + > > test_done Thanks, Taylor
diff --git a/pack-bitmap.c b/pack-bitmap.c index 195ee8cad0..4077e731e8 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -506,7 +506,8 @@ static int should_include(struct commit *commit, void *_data) static struct bitmap *find_objects(struct bitmap_index *bitmap_git, struct rev_info *revs, struct object_list *roots, - struct bitmap *seen) + struct bitmap *seen, + struct list_objects_filter_options *filter) { struct bitmap *base = NULL; int needs_walk = 0; @@ -599,8 +600,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git, show_data.bitmap_git = bitmap_git; show_data.base = base; - traverse_commit_list(revs, show_commit, show_object, - &show_data); + traverse_commit_list_filtered(filter, revs, + show_commit, show_object, + &show_data, NULL); } return base; @@ -999,7 +1001,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, if (haves) { revs->ignore_missing_links = 1; - haves_bitmap = find_objects(bitmap_git, revs, haves, NULL); + haves_bitmap = find_objects(bitmap_git, revs, haves, NULL, + filter); reset_revision_walk(); revs->ignore_missing_links = 0; @@ -1007,7 +1010,8 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs, BUG("failed to perform bitmap walk"); } - wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap); + wants_bitmap = find_objects(bitmap_git, revs, wants, haves_bitmap, + filter); if (!wants_bitmap) BUG("failed to perform bitmap walk"); diff --git a/t/perf/p5310-pack-bitmaps.sh b/t/perf/p5310-pack-bitmaps.sh index 75ccf9f4e3..b3e725f031 100755 --- a/t/perf/p5310-pack-bitmaps.sh +++ b/t/perf/p5310-pack-bitmaps.sh @@ -91,4 +91,9 @@ test_perf 'pack to file (partial bitmap)' ' git pack-objects --use-bitmap-index --all pack2b </dev/null >/dev/null ' +test_perf 'rev-list with tree filter (partial bitmap)' ' + git rev-list --use-bitmap-index --count --objects --all \ + --filter=tree:0 >/dev/null +' + test_done