summaryrefslogtreecommitdiff
path: root/pack-bitmap-write.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-12-08 22:04:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-08 22:48:16 (GMT)
commit6dc5ef759f25fbded11d235362c59f59498809e6 (patch)
treebc613bec149e086e16c4c952885fab1d9edc0913 /pack-bitmap-write.c
parent010e5eacfb004218087da054a61772da8fc40463 (diff)
downloadgit-6dc5ef759f25fbded11d235362c59f59498809e6.zip
git-6dc5ef759f25fbded11d235362c59f59498809e6.tar.gz
git-6dc5ef759f25fbded11d235362c59f59498809e6.tar.bz2
pack-bitmap-write: fill bitmap with commit history
The current implementation of bitmap_writer_build() creates a reachability bitmap for every walked commit. After computing a bitmap for a commit, those bits are pushed to an in-progress bitmap for its children. fill_bitmap_commit() assumes the bits corresponding to objects reachable from the parents of a commit are already set. This means that when visiting a new commit, we only have to walk the objects reachable between it and any of its parents. A future change to bitmap_writer_build() will relax this condition so not all parents have their bits set. Prepare for that by having 'fill_bitmap_commit()' walk parents until reaching commits whose bits are already set. Then, walk the trees for these commits as well. This has no functional change with the current implementation of bitmap_writer_build(). Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-bitmap-write.c')
-rw-r--r--pack-bitmap-write.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 1eb9615..9576392 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -12,6 +12,7 @@
#include "sha1-lookup.h"
#include "pack-objects.h"
#include "commit-reach.h"
+#include "prio-queue.h"
struct bitmapped_commit {
struct commit *commit;
@@ -279,17 +280,30 @@ static void fill_bitmap_tree(struct bitmap *bitmap,
}
static void fill_bitmap_commit(struct bb_commit *ent,
- struct commit *commit)
+ struct commit *commit,
+ struct prio_queue *queue)
{
if (!ent->bitmap)
ent->bitmap = bitmap_new();
- /*
- * mark ourselves, but do not bother with parents; their values
- * will already have been propagated to us
- */
bitmap_set(ent->bitmap, find_object_pos(&commit->object.oid));
- fill_bitmap_tree(ent->bitmap, get_commit_tree(commit));
+ prio_queue_put(queue, commit);
+
+ while (queue->nr) {
+ struct commit_list *p;
+ struct commit *c = prio_queue_get(queue);
+
+ bitmap_set(ent->bitmap, find_object_pos(&c->object.oid));
+ fill_bitmap_tree(ent->bitmap, get_commit_tree(c));
+
+ for (p = c->parents; p; p = p->next) {
+ int pos = find_object_pos(&p->item->object.oid);
+ if (!bitmap_get(ent->bitmap, pos)) {
+ bitmap_set(ent->bitmap, pos);
+ prio_queue_put(queue, p->item);
+ }
+ }
+ }
}
static void store_selected(struct bb_commit *ent, struct commit *commit)
@@ -319,6 +333,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
struct bitmap_builder bb;
size_t i;
int nr_stored = 0; /* for progress */
+ struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
writer.bitmaps = kh_init_oid_map();
writer.to_pack = to_pack;
@@ -335,7 +350,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
struct commit *child;
int reused = 0;
- fill_bitmap_commit(ent, commit);
+ fill_bitmap_commit(ent, commit, &queue);
if (ent->selected) {
store_selected(ent, commit);
@@ -360,6 +375,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
bitmap_free(ent->bitmap);
ent->bitmap = NULL;
}
+ clear_prio_queue(&queue);
bitmap_builder_clear(&bb);
trace2_region_leave("pack-bitmap-write", "building_bitmaps_total",