Skip to content

Commit 144d703

Browse files
derrickstoleegitster
authored andcommitted
multi-pack-index: report progress during 'verify'
When verifying a multi-pack-index, the only action that takes significant time is checking the object offsets. For example, to verify a multi-pack-index containing 6.2 million objects in the Linux kernel repository takes 1.3 seconds on my machine. 99% of that time is spent looking up object offsets in each of the packfiles and comparing them to the multi-pack-index offset. Add a progress indicator for that section of the 'verify' verb. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cc6af73 commit 144d703

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

midx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "object-store.h"
88
#include "sha1-lookup.h"
99
#include "midx.h"
10+
#include "progress.h"
1011

1112
#define MIDX_SIGNATURE 0x4d494458 /* "MIDX" */
1213
#define MIDX_VERSION 1
@@ -940,6 +941,7 @@ static void midx_report(const char *fmt, ...)
940941
int verify_midx_file(const char *object_dir)
941942
{
942943
uint32_t i;
944+
struct progress *progress = NULL;
943945
struct multi_pack_index *m = load_multi_pack_index(object_dir, 1);
944946
verify_midx_error = 0;
945947

@@ -971,6 +973,7 @@ int verify_midx_file(const char *object_dir)
971973
i, oid_to_hex(&oid1), oid_to_hex(&oid2), i + 1);
972974
}
973975

976+
progress = start_progress(_("Verifying object offsets"), m->num_objects);
974977
for (i = 0; i < m->num_objects; i++) {
975978
struct object_id oid;
976979
struct pack_entry e;
@@ -995,7 +998,10 @@ int verify_midx_file(const char *object_dir)
995998
if (m_offset != p_offset)
996999
midx_report(_("incorrect object offset for oid[%d] = %s: %"PRIx64" != %"PRIx64),
9971000
i, oid_to_hex(&oid), m_offset, p_offset);
1001+
1002+
display_progress(progress, i + 1);
9981003
}
1004+
stop_progress(&progress);
9991005

10001006
return verify_midx_error;
10011007
}

0 commit comments

Comments
 (0)