git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] fetch-pack: speed up loading of refs via commit graph

From
Patrick Steinhardt <ps@pks.im>
Date
Aug 5, 2021, 11:53 UTC
Message-ID
<YQvRTpJ0NGakTy9W@ncase>
In-Reply-To
<YQt/g0iZxAVgw66o@ncase>
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:
> > On Wed, Aug 04, 2021 at 03:56:11PM +0200, Patrick Steinhardt wrote:
[snip]
Show 26 quoted lines
> > 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,
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 7 of 12 in “fetch-pack: speed up loading of refs via commit graph”
  1. fetch-pack: speed up loading of refs via commit graphPatrick Steinhardt, Aug 4, 2021
  2. Derrick StoleeAug 4, 2021
  3. Junio C HamanoAug 4, 2021
  4. Jeff KingAug 4, 2021
  5. Junio C HamanoAug 4, 2021
  6. Patrick SteinhardtAug 5, 2021
  7. Patrick SteinhardtAug 5, 2021
  8. Junio C HamanoAug 5, 2021
  9. Jeff KingAug 5, 2021
  10. Jeff KingAug 5, 2021
  11. Ævar Arnfjörð BjarmasonAug 5, 2021
  12. Jeff KingAug 5, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.