Re: [PATCH] fetch-pack: speed up loading of refs via commit graph
From: Patrick Steinhardt <hidden>
Date: 2021-08-05 11:54:02
Subsystem:
the rest · Maintainer:
Linus Torvalds
On Thu, Aug 05, 2021 at 08:04:53AM +0200, Patrick Steinhardt wrote:
On Wed, Aug 04, 2021 at 04:59:40PM -0400, Jeff King wrote:quoted
On Wed, Aug 04, 2021 at 03:56:11PM +0200, Patrick Steinhardt wrote:
[snip]
quoted
I wonder where the remaining 20s is going.Rebasing this commit on top of my git-rev-list(1) series [1] for the connectivity check gives another 25% speedup, going down from 20s to 14s (numbers are a bit different given that I'm on a different machine right now). From here on, it's multiple things which take time: - 20% of the time is spent sorting the refs in `mark_complete_and_common_ref()`. This time around I feel less comfortable to just disable sorting given that it may impact correctness. - 30% of the time is spent looking up object types via `oid_object_info_extended()`, where 75% of these lookups come from `deref_without_lazy_fetch()`. This can be improved a bit by doing the `lookup_unknown_object()` dance, buying a modest speedup of ~8%. But this again has memory tradeoffs given that we must allocate the object such that all types would fit. Other than that I don't see any obvious things in the flame graphs. In case anybody is interested, I've posted flame graphs in our GitLab issue at [2], with the state before this patch, with this patch and in combination with [1]. [1]: http://public-inbox.org/git/cover.1627896460.git.ps@pks.im/ [2]: https://gitlab.com/gitlab-org/gitlab/-/issues/336657#note_642957933
I've put some more time into this. If rebased on top of v4 of [1], then we can also use `parse_commit_in_graph_gently()` to further speed this up from 15.8 seconds to 11.6 seconds with below patch. It's the same memory/speed tradeoff as I'm doing in [1]. I guess I'd still like to treat both series separately for now given that [1] is more involved compared to this patch series here. I'll then do a follow-up when (if?) both series have landed. Patrick
diff --git a/fetch-pack.c b/fetch-pack.c
index 0bf7ed7e47..cc8b2ffa6c 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c@@ -119,6 +119,17 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid, { enum object_type type; struct object_info info = { .typep = &type }; + struct object *object = lookup_unknown_object(the_repository, oid); + + if (object->type == OBJ_COMMIT) + return (struct commit *) object; + + if (object->type == OBJ_NONE && + parse_commit_in_graph_gently(the_repository, object) == 0) { + if (!repo_has_object_file(the_repository, oid)) + return NULL; + return (struct commit *) object; + } while (1) { if (oid_object_info_extended(the_repository, oid, &info,
Attachments
- signature.asc [application/pgp-signature] 833 bytes