Skip to content

Commit

Permalink
fetch-pack.c: enable fscache for stats under .git/objects
Browse files Browse the repository at this point in the history
When I do git fetch, git call file stats under .git/objects for each
refs. This takes time when there are many refs.

By enabling fscache, git takes file stats by directory traversing and that
improved the speed of fetch-pack for repository having large number of
refs.

In my windows workstation, this improves the time of `git fetch` for
chromium repository like below. I took stats 3 times.

* With this patch
TotalSeconds: 9.9825165
TotalSeconds: 9.1862075
TotalSeconds: 10.1956256
Avg: 9.78811653333333

* Without this patch
TotalSeconds: 15.8406702
TotalSeconds: 15.6248053
TotalSeconds: 15.2085938
Avg: 15.5580231

Signed-off-by: Takuto Ikuta <tikuta@chromium.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
Takuto Ikuta authored and dscho committed Sep 24, 2024
1 parent 5ea907f commit 4579d69
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
save_commit_buffer = 0;

trace2_region_enter("fetch-pack", "parse_remote_refs_and_find_cutoff", NULL);
enable_fscache(1);
for (ref = *refs; ref; ref = ref->next) {
struct commit *commit;

Expand All @@ -783,6 +784,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
if (!cutoff || cutoff < commit->date)
cutoff = commit->date;
}
enable_fscache(0);
trace2_region_leave("fetch-pack", "parse_remote_refs_and_find_cutoff", NULL);

/*
Expand Down

0 comments on commit 4579d69

Please sign in to comment.