Skip to content

Commit 53c3667

Browse files
derrickstoleegitster
authored andcommitted
commit-graph: reduce initial oid allocation
While writing a commit-graph file, we store the full list of commits in a flat list. We use this list for sorting and ensuring we are closed under reachability. The initial allocation assumed that (at most) one in four objects is a commit. This is a dramatic over-count for many repos, especially large ones. Since we grow the repo dynamically, reduce this count by a factor of eight. We still set it to a minimum of 1024 before allocating. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0bfb48e commit 53c3667

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

commit-graph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ void write_commit_graph(const char *obj_dir,
720720
struct progress *progress = NULL;
721721

722722
oids.nr = 0;
723-
oids.alloc = approximate_object_count() / 4;
723+
oids.alloc = approximate_object_count() / 32;
724724
oids.progress = NULL;
725725
oids.progress_done = 0;
726726

0 commit comments

Comments
 (0)