Skip to content

Commit 99bb1a0

Browse files
committed
Merge branch 'tb/midx-bitmap-selection-fix'
A bugfix with tracing support in midx codepath * tb/midx-bitmap-selection-fix: pack-bitmap-write.c: instrument number of reused bitmaps midx.c: instrument MIDX and bitmap generation with trace2 regions midx.c: consider annotated tags during bitmap selection midx.c: fix whitespace typo
2 parents db29e6b + e9c3839 commit 99bb1a0

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

midx.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ uint32_t nth_midxed_pack_int_id(struct multi_pack_index *m, uint32_t pos)
278278
(off_t)pos * MIDX_CHUNK_OFFSET_WIDTH);
279279
}
280280

281-
int fill_midx_entry(struct repository * r,
281+
int fill_midx_entry(struct repository *r,
282282
const struct object_id *oid,
283283
struct pack_entry *e,
284284
struct multi_pack_index *m)
@@ -913,6 +913,8 @@ static uint32_t *midx_pack_order(struct write_midx_context *ctx)
913913
uint32_t *pack_order;
914914
uint32_t i;
915915

916+
trace2_region_enter("midx", "midx_pack_order", the_repository);
917+
916918
ALLOC_ARRAY(data, ctx->entries_nr);
917919
for (i = 0; i < ctx->entries_nr; i++) {
918920
struct pack_midx_entry *e = &ctx->entries[i];
@@ -930,6 +932,8 @@ static uint32_t *midx_pack_order(struct write_midx_context *ctx)
930932
pack_order[i] = data[i].nr;
931933
free(data);
932934

935+
trace2_region_leave("midx", "midx_pack_order", the_repository);
936+
933937
return pack_order;
934938
}
935939

@@ -939,6 +943,8 @@ static void write_midx_reverse_index(char *midx_name, unsigned char *midx_hash,
939943
struct strbuf buf = STRBUF_INIT;
940944
const char *tmp_file;
941945

946+
trace2_region_enter("midx", "write_midx_reverse_index", the_repository);
947+
942948
strbuf_addf(&buf, "%s-%s.rev", midx_name, hash_to_hex(midx_hash));
943949

944950
tmp_file = write_rev_file_order(NULL, ctx->pack_order, ctx->entries_nr,
@@ -948,6 +954,8 @@ static void write_midx_reverse_index(char *midx_name, unsigned char *midx_hash,
948954
die(_("cannot store reverse index file"));
949955

950956
strbuf_release(&buf);
957+
958+
trace2_region_leave("midx", "write_midx_reverse_index", the_repository);
951959
}
952960

953961
static void clear_midx_files_ext(const char *object_dir, const char *ext,
@@ -963,6 +971,8 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
963971
{
964972
uint32_t i;
965973

974+
trace2_region_enter("midx", "prepare_midx_packing_data", the_repository);
975+
966976
memset(pdata, 0, sizeof(struct packing_data));
967977
prepare_packing_data(the_repository, pdata);
968978

@@ -973,20 +983,26 @@ static void prepare_midx_packing_data(struct packing_data *pdata,
973983
oe_set_in_pack(pdata, to,
974984
ctx->info[ctx->pack_perm[from->pack_int_id]].p);
975985
}
986+
987+
trace2_region_leave("midx", "prepare_midx_packing_data", the_repository);
976988
}
977989

978990
static int add_ref_to_pending(const char *refname,
979991
const struct object_id *oid,
980992
int flag, void *cb_data)
981993
{
982994
struct rev_info *revs = (struct rev_info*)cb_data;
995+
struct object_id peeled;
983996
struct object *object;
984997

985998
if ((flag & REF_ISSYMREF) && (flag & REF_ISBROKEN)) {
986999
warning("symbolic ref is dangling: %s", refname);
9871000
return 0;
9881001
}
9891002

1003+
if (!peel_iterated_oid(oid, &peeled))
1004+
oid = &peeled;
1005+
9901006
object = parse_object_or_die(oid, refname);
9911007
if (object->type != OBJ_COMMIT)
9921008
return 0;
@@ -1066,6 +1082,9 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
10661082
struct rev_info revs;
10671083
struct bitmap_commit_cb cb = {0};
10681084

1085+
trace2_region_enter("midx", "find_commits_for_midx_bitmap",
1086+
the_repository);
1087+
10691088
cb.ctx = ctx;
10701089

10711090
repo_init_revisions(the_repository, &revs, NULL);
@@ -1099,6 +1118,10 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
10991118
*indexed_commits_nr_p = cb.commits_nr;
11001119

11011120
release_revisions(&revs);
1121+
1122+
trace2_region_leave("midx", "find_commits_for_midx_bitmap",
1123+
the_repository);
1124+
11021125
return cb.commits;
11031126
}
11041127

@@ -1116,6 +1139,8 @@ static int write_midx_bitmap(const char *midx_name,
11161139
char *bitmap_name = xstrfmt("%s-%s.bitmap", midx_name,
11171140
hash_to_hex(midx_hash));
11181141

1142+
trace2_region_enter("midx", "write_midx_bitmap", the_repository);
1143+
11191144
if (flags & MIDX_WRITE_BITMAP_HASH_CACHE)
11201145
options |= BITMAP_OPT_HASH_CACHE;
11211146

@@ -1161,6 +1186,9 @@ static int write_midx_bitmap(const char *midx_name,
11611186
cleanup:
11621187
free(index);
11631188
free(bitmap_name);
1189+
1190+
trace2_region_leave("midx", "write_midx_bitmap", the_repository);
1191+
11641192
return ret;
11651193
}
11661194

@@ -1207,6 +1235,8 @@ static int write_midx_internal(const char *object_dir,
12071235
int result = 0;
12081236
struct chunkfile *cf;
12091237

1238+
trace2_region_enter("midx", "write_midx_internal", the_repository);
1239+
12101240
get_midx_filename(&midx_name, object_dir);
12111241
if (safe_create_leading_directories(midx_name.buf))
12121242
die_errno(_("unable to create leading directories of %s"),
@@ -1548,6 +1578,8 @@ static int write_midx_internal(const char *object_dir,
15481578
free(ctx.pack_order);
15491579
strbuf_release(&midx_name);
15501580

1581+
trace2_region_leave("midx", "write_midx_internal", the_repository);
1582+
15511583
return result;
15521584
}
15531585

pack-bitmap-write.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ static int fill_bitmap_tree(struct bitmap *bitmap,
384384
return 0;
385385
}
386386

387+
static int reused_bitmaps_nr;
388+
387389
static int fill_bitmap_commit(struct bb_commit *ent,
388390
struct commit *commit,
389391
struct prio_queue *queue,
@@ -409,8 +411,10 @@ static int fill_bitmap_commit(struct bb_commit *ent,
409411
* bitmap and add its bits to this one. No need to walk
410412
* parents or the tree for this commit.
411413
*/
412-
if (old && !rebuild_bitmap(mapping, old, ent->bitmap))
414+
if (old && !rebuild_bitmap(mapping, old, ent->bitmap)) {
415+
reused_bitmaps_nr++;
413416
continue;
417+
}
414418
}
415419

416420
/*
@@ -526,6 +530,8 @@ int bitmap_writer_build(struct packing_data *to_pack)
526530

527531
trace2_region_leave("pack-bitmap-write", "building_bitmaps_total",
528532
the_repository);
533+
trace2_data_intmax("pack-bitmap-write", the_repository,
534+
"building_bitmaps_reused", reused_bitmaps_nr);
529535

530536
stop_progress(&writer.progress);
531537

t/t5326-multi-pack-bitmaps.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,28 @@ test_expect_success 'preferred pack change with existing MIDX bitmap' '
410410
)
411411
'
412412

413+
test_expect_success 'tagged commits are selected for bitmapping' '
414+
rm -fr repo &&
415+
git init repo &&
416+
test_when_finished "rm -fr repo" &&
417+
(
418+
cd repo &&
419+
420+
test_commit --annotate base &&
421+
git repack -d &&
422+
423+
# Remove refs/heads/main which points at the commit directly,
424+
# leaving only a reference to the annotated tag.
425+
git branch -M main &&
426+
git checkout base &&
427+
git branch -d main &&
428+
429+
git multi-pack-index write --bitmap &&
430+
431+
git rev-parse HEAD >want &&
432+
test-tool bitmap list-commits >actual &&
433+
grep $(cat want) actual
434+
)
435+
'
436+
413437
test_done

0 commit comments

Comments
 (0)