Skip to content

Commit c1aa021

Browse files
committed
midx: do not try to look at every object in the index
Similar to previous issues around doing way too much verification at loading time, checking whether the object index chunk is monotonic is better left for git-fsck instead of every single time we want to look at something in the repository. As midx files grow, this starts taking more and more times. As an example, I went looking for this because it's taking about 1.5s to do a single object lookup in a repository that's ended up with a 7G multi-pack-index file.
1 parent f041a94 commit c1aa021

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/libgit2/midx.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ static int midx_parse_oid_lookup(
114114
const unsigned char *data,
115115
struct git_midx_chunk *chunk_oid_lookup)
116116
{
117-
uint32_t i;
118-
unsigned char *oid, *prev_oid, zero_oid[GIT_OID_MAX_SIZE] = {0};
119117
size_t oid_size = git_oid_size(idx->oid_type);
120118

121119
if (chunk_oid_lookup->offset == 0)
@@ -125,13 +123,7 @@ static int midx_parse_oid_lookup(
125123
if (chunk_oid_lookup->length != idx->num_objects * oid_size)
126124
return midx_error("OID Lookup chunk has wrong length");
127125

128-
idx->oid_lookup = oid = (unsigned char *)(data + chunk_oid_lookup->offset);
129-
prev_oid = zero_oid;
130-
for (i = 0; i < idx->num_objects; ++i, oid += oid_size) {
131-
if (git_oid_raw_cmp(prev_oid, oid, oid_size) >= 0)
132-
return midx_error("OID Lookup index is non-monotonic");
133-
prev_oid = oid;
134-
}
126+
idx->oid_lookup = (unsigned char *)(data + chunk_oid_lookup->offset);
135127

136128
return 0;
137129
}

0 commit comments

Comments
 (0)