From: Josh Steadmon Date: Thu, 22 Aug 2024 21:57:46 +0000 (-0700) Subject: fetch: add top-level trace2 regions X-Git-Tag: v2.47.0-rc0~76^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a45ab549879d0f8e2524f820796daf2f6a1f7d00;p=thirdparty%2Fgit.git fetch: add top-level trace2 regions 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 Signed-off-by: Junio C Hamano --- diff --git a/builtin/fetch.c b/builtin/fetch.c index c297569a47..d0dcbd5e2c 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -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) { diff --git a/bundle-uri.c b/bundle-uri.c index 1e0ee156ba..dc0c96955b 100644 --- a/bundle-uri.c +++ b/bundle-uri.c @@ -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; }