commit-graph: reduce initial oid allocation
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 3 Oct 2018 17:12:19 +0000 (10:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 Oct 2018 23:25:05 +0000 (08:25 +0900)
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>
commit-graph.c
index ceca6026b0fabb5bf6bc8b18019d5b5be2e39a59..e773703e1ddd6116abcd910caeb3cd72b862658c 100644 (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;