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 <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Josh Steadmon
2024-08-22 14:57:46 -07:00
committed by Junio C Hamano
parent cbe140754b
commit a45ab54987
2 changed files with 19 additions and 1 deletions

View File

@ -2408,6 +2408,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
struct oidset_iter iter; struct oidset_iter iter;
const struct object_id *oid; const struct object_id *oid;
trace2_region_enter("fetch", "negotiate-only", the_repository);
if (!remote) if (!remote)
die(_("must supply remote when using --negotiate-only")); die(_("must supply remote when using --negotiate-only"));
gtransport = prepare_transport(remote, 1); gtransport = prepare_transport(remote, 1);
@ -2416,6 +2417,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
} else { } else {
warning(_("protocol does not support --negotiate-only, exiting")); warning(_("protocol does not support --negotiate-only, exiting"));
result = 1; result = 1;
trace2_region_leave("fetch", "negotiate-only", the_repository);
goto cleanup; goto cleanup;
} }
if (server_options.nr) 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))) while ((oid = oidset_iter_next(&iter)))
printf("%s\n", oid_to_hex(oid)); printf("%s\n", oid_to_hex(oid));
oidset_clear(&acked_commits); oidset_clear(&acked_commits);
trace2_region_leave("fetch", "negotiate-only", the_repository);
} else if (remote) { } 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); 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, result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs,
&config); &config);
trace2_region_leave("fetch", "fetch-one", the_repository);
} else { } else {
int max_children = max_jobs; int max_children = max_jobs;
@ -2450,7 +2458,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
max_children = config.parallel; max_children = config.parallel;
/* TODO should this also die if we have a previous partial-clone? */ /* 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); 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; max_children = config.parallel;
add_options_to_argv(&options, &config); add_options_to_argv(&options, &config);
trace2_region_enter_printf("fetch", "recurse-submodule", the_repository, "%s", submodule_prefix);
result = fetch_submodules(the_repository, result = fetch_submodules(the_repository,
&options, &options,
submodule_prefix, submodule_prefix,
@ -2479,6 +2490,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
recurse_submodules_default, recurse_submodules_default,
verbosity < 0, verbosity < 0,
max_children); max_children);
trace2_region_leave_printf("fetch", "recurse-submodule", the_repository, "%s", submodule_prefix);
strvec_clear(&options); strvec_clear(&options);
} }
@ -2502,9 +2514,11 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
if (progress) if (progress)
commit_graph_flags |= COMMIT_GRAPH_WRITE_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, write_commit_graph_reachable(the_repository->objects->odb,
commit_graph_flags, commit_graph_flags,
NULL); NULL);
trace2_region_leave("fetch", "write-commit-graph", the_repository);
} }
if (enable_auto_gc) { if (enable_auto_gc) {

View File

@ -13,6 +13,7 @@
#include "config.h" #include "config.h"
#include "fetch-pack.h" #include "fetch-pack.h"
#include "remote.h" #include "remote.h"
#include "trace2.h"
static struct { static struct {
enum bundle_list_heuristic heuristic; enum bundle_list_heuristic heuristic;
@ -799,6 +800,8 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
.id = xstrdup(""), .id = xstrdup(""),
}; };
trace2_region_enter("fetch", "fetch-bundle-uri", the_repository);
init_bundle_list(&list); init_bundle_list(&list);
/* /*
@ -824,6 +827,7 @@ cleanup:
for_all_bundles_in_list(&list, unlink_bundle, NULL); for_all_bundles_in_list(&list, unlink_bundle, NULL);
clear_bundle_list(&list); clear_bundle_list(&list);
clear_remote_bundle_info(&bundle, NULL); clear_remote_bundle_info(&bundle, NULL);
trace2_region_leave("fetch", "fetch-bundle-uri", the_repository);
return result; return result;
} }