1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-29 05:06:09 +02:00

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 <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Derrick Stolee 2018-10-03 10:12:19 -07:00 committed by Junio C Hamano
parent 0bfb48e672
commit 53c36670e7

View File

@ -720,7 +720,7 @@ void write_commit_graph(const char *obj_dir,
struct progress *progress = NULL;
oids.nr = 0;
oids.alloc = approximate_object_count() / 4;
oids.alloc = approximate_object_count() / 32;
oids.progress = NULL;
oids.progress_done = 0;