]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: add top-level trace2 regions
authorJosh Steadmon <steadmon@google.com>
Thu, 22 Aug 2024 21:57:46 +0000 (14:57 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 22:02:31 +0000 (15:02 -0700)
At $DAYJOB we experienced some slow fetch operations and needed some
additional data to help diagnose the issue.

Add top-level trace2 regions for the various modes of operation of
`git-fetch`. None of these regions are in recursive code, so any
enclosed trace messages should only see their nesting level increase by
one.

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
bundle-uri.c

index c297569a473f133cf7ba8e23f112fd1b0de3fa92..d0dcbd5e2c1068974946233bd28b160c62b3d819 100644 (file)
@@ -2408,6 +2408,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                struct oidset_iter iter;
                const struct object_id *oid;
 
+               trace2_region_enter("fetch", "negotiate-only", the_repository);
                if (!remote)
                        die(_("must supply remote when using --negotiate-only"));
                gtransport = prepare_transport(remote, 1);
@@ -2416,6 +2417,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                } else {
                        warning(_("protocol does not support --negotiate-only, exiting"));
                        result = 1;
+                       trace2_region_leave("fetch", "negotiate-only", the_repository);
                        goto cleanup;
                }
                if (server_options.nr)
@@ -2426,11 +2428,17 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                while ((oid = oidset_iter_next(&iter)))
                        printf("%s\n", oid_to_hex(oid));
                oidset_clear(&acked_commits);
+               trace2_region_leave("fetch", "negotiate-only", the_repository);
        } else if (remote) {
-               if (filter_options.choice || repo_has_promisor_remote(the_repository))
+               if (filter_options.choice || repo_has_promisor_remote(the_repository)) {
+                       trace2_region_enter("fetch", "setup-partial", the_repository);
                        fetch_one_setup_partial(remote);
+                       trace2_region_leave("fetch", "setup-partial", the_repository);
+               }
+               trace2_region_enter("fetch", "fetch-one", the_repository);
                result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs,
                                   &config);
+               trace2_region_leave("fetch", "fetch-one", the_repository);
        } else {
                int max_children = max_jobs;
 
@@ -2450,7 +2458,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                        max_children = config.parallel;
 
                /* TODO should this also die if we have a previous partial-clone? */
+               trace2_region_enter("fetch", "fetch-multiple", the_repository);
                result = fetch_multiple(&list, max_children, &config);
+               trace2_region_leave("fetch", "fetch-multiple", the_repository);
        }
 
        /*
@@ -2472,6 +2482,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                        max_children = config.parallel;
 
                add_options_to_argv(&options, &config);
+               trace2_region_enter_printf("fetch", "recurse-submodule", the_repository, "%s", submodule_prefix);
                result = fetch_submodules(the_repository,
                                          &options,
                                          submodule_prefix,
@@ -2479,6 +2490,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                                          recurse_submodules_default,
                                          verbosity < 0,
                                          max_children);
+               trace2_region_leave_printf("fetch", "recurse-submodule", the_repository, "%s", submodule_prefix);
                strvec_clear(&options);
        }
 
@@ -2502,9 +2514,11 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
                if (progress)
                        commit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;
 
+               trace2_region_enter("fetch", "write-commit-graph", the_repository);
                write_commit_graph_reachable(the_repository->objects->odb,
                                             commit_graph_flags,
                                             NULL);
+               trace2_region_leave("fetch", "write-commit-graph", the_repository);
        }
 
        if (enable_auto_gc) {
index 1e0ee156ba317cdb8ad2ce3b89020b906a46d6d9..dc0c96955b829997fd251e0feff0b088ad461c6b 100644 (file)
@@ -13,6 +13,7 @@
 #include "config.h"
 #include "fetch-pack.h"
 #include "remote.h"
+#include "trace2.h"
 
 static struct {
        enum bundle_list_heuristic heuristic;
@@ -799,6 +800,8 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
                .id = xstrdup(""),
        };
 
+       trace2_region_enter("fetch", "fetch-bundle-uri", the_repository);
+
        init_bundle_list(&list);
 
        /*
@@ -824,6 +827,7 @@ cleanup:
        for_all_bundles_in_list(&list, unlink_bundle, NULL);
        clear_bundle_list(&list);
        clear_remote_bundle_info(&bundle, NULL);
+       trace2_region_leave("fetch", "fetch-bundle-uri", the_repository);
        return result;
 }