summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Ævar Arnfjörð Bjarmason <avarab@gmail.com>2019-01-19 21:21:12 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-01-22 11:32:56 -0800
commitd7574c95bb74cd189950cc6e9cad762099382162 (patch)
treeca3d1387b3b2c758181df82200f69f62f8a8c45e
parentSecond batch after 2.20 (diff)
downloadtgif-d7574c95bb74cd189950cc6e9cad762099382162.tar.xz
commit-graph write: use pack order when finding commits
Slightly optimize the "commit-graph write" step by using FOR_EACH_OBJECT_PACK_ORDER with for_each_object_in_pack(). See commit [1] and [2] for the facility and a similar optimization for "cat-file". On Linux it is around 5% slower to run: echo 1 >/proc/sys/vm/drop_caches && cat .git/objects/pack/* >/dev/null && git cat-file --batch-all-objects --batch-check --unordered Than the same thing with the "cat" omitted. This is as expected, since we're iterating in pack order and the "cat" is extra work. Before this change the opposite was true of "commit-graph write". We were 6% faster if we first ran "cat" to efficiently populate the FS cache for our sole big pack on linux.git, than if we had populated it via for_each_object_in_pack(). Now we're 3% faster without the "cat" instead. My tests were done on an unloaded Linux 3.10 system with 10 runs for each. Derrick Stolee did his own tests on Windows[3] showing a 2% improvement with a high degree of accuracy. 1. 736eb88fdc ("for_each_packed_object: support iterating in pack-order", 2018-08-10) 2. 0750bb5b51 ("cat-file: support "unordered" output for --batch-all-objects", 2018-08-10) 3. https://public-inbox.org/git/f71fa868-25e8-a9c9-46a6-611b987f1a8f@gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--commit-graph.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/commit-graph.c b/commit-graph.c
index 5c8fb4b134..981faf0465 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -816,7 +816,8 @@ void write_commit_graph(const char *obj_dir,
die(_("error adding pack %s"), packname.buf);
if (open_pack_index(p))
die(_("error opening index for %s"), packname.buf);
- for_each_object_in_pack(p, add_packed_commits, &oids, 0);
+ for_each_object_in_pack(p, add_packed_commits, &oids,
+ FOR_EACH_OBJECT_PACK_ORDER);
close_pack(p);
free(p);
}
@@ -854,7 +855,8 @@ void write_commit_graph(const char *obj_dir,
if (report_progress)
oids.progress = start_delayed_progress(
_("Finding commits for commit graph"), 0);
- for_each_packed_object(add_packed_commits, &oids, 0);
+ for_each_packed_object(add_packed_commits, &oids,
+ FOR_EACH_OBJECT_PACK_ORDER);
stop_progress(&oids.progress);
}