Skip to content

Commit a45ab54

Browse files
steadmongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cbe1407 commit a45ab54

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

builtin/fetch.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2408,6 +2408,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24082408
struct oidset_iter iter;
24092409
const struct object_id *oid;
24102410

2411+
trace2_region_enter("fetch", "negotiate-only", the_repository);
24112412
if (!remote)
24122413
die(_("must supply remote when using --negotiate-only"));
24132414
gtransport = prepare_transport(remote, 1);
@@ -2416,6 +2417,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24162417
} else {
24172418
warning(_("protocol does not support --negotiate-only, exiting"));
24182419
result = 1;
2420+
trace2_region_leave("fetch", "negotiate-only", the_repository);
24192421
goto cleanup;
24202422
}
24212423
if (server_options.nr)
@@ -2426,11 +2428,17 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24262428
while ((oid = oidset_iter_next(&iter)))
24272429
printf("%s\n", oid_to_hex(oid));
24282430
oidset_clear(&acked_commits);
2431+
trace2_region_leave("fetch", "negotiate-only", the_repository);
24292432
} else if (remote) {
2430-
if (filter_options.choice || repo_has_promisor_remote(the_repository))
2433+
if (filter_options.choice || repo_has_promisor_remote(the_repository)) {
2434+
trace2_region_enter("fetch", "setup-partial", the_repository);
24312435
fetch_one_setup_partial(remote);
2436+
trace2_region_leave("fetch", "setup-partial", the_repository);
2437+
}
2438+
trace2_region_enter("fetch", "fetch-one", the_repository);
24322439
result = fetch_one(remote, argc, argv, prune_tags_ok, stdin_refspecs,
24332440
&config);
2441+
trace2_region_leave("fetch", "fetch-one", the_repository);
24342442
} else {
24352443
int max_children = max_jobs;
24362444

@@ -2450,7 +2458,9 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24502458
max_children = config.parallel;
24512459

24522460
/* TODO should this also die if we have a previous partial-clone? */
2461+
trace2_region_enter("fetch", "fetch-multiple", the_repository);
24532462
result = fetch_multiple(&list, max_children, &config);
2463+
trace2_region_leave("fetch", "fetch-multiple", the_repository);
24542464
}
24552465

24562466
/*
@@ -2472,13 +2482,15 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
24722482
max_children = config.parallel;
24732483

24742484
add_options_to_argv(&options, &config);
2485+
trace2_region_enter_printf("fetch", "recurse-submodule", the_repository, "%s", submodule_prefix);
24752486
result = fetch_submodules(the_repository,
24762487
&options,
24772488
submodule_prefix,
24782489
config.recurse_submodules,
24792490
recurse_submodules_default,
24802491
verbosity < 0,
24812492
max_children);
2493+
trace2_region_leave_printf("fetch", "recurse-submodule", the_repository, "%s", submodule_prefix);
24822494
strvec_clear(&options);
24832495
}
24842496

@@ -2502,9 +2514,11 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
25022514
if (progress)
25032515
commit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;
25042516

2517+
trace2_region_enter("fetch", "write-commit-graph", the_repository);
25052518
write_commit_graph_reachable(the_repository->objects->odb,
25062519
commit_graph_flags,
25072520
NULL);
2521+
trace2_region_leave("fetch", "write-commit-graph", the_repository);
25082522
}
25092523

25102524
if (enable_auto_gc) {

bundle-uri.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "config.h"
1414
#include "fetch-pack.h"
1515
#include "remote.h"
16+
#include "trace2.h"
1617

1718
static struct {
1819
enum bundle_list_heuristic heuristic;
@@ -799,6 +800,8 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
799800
.id = xstrdup(""),
800801
};
801802

803+
trace2_region_enter("fetch", "fetch-bundle-uri", the_repository);
804+
802805
init_bundle_list(&list);
803806

804807
/*
@@ -824,6 +827,7 @@ int fetch_bundle_uri(struct repository *r, const char *uri,
824827
for_all_bundles_in_list(&list, unlink_bundle, NULL);
825828
clear_bundle_list(&list);
826829
clear_remote_bundle_info(&bundle, NULL);
830+
trace2_region_leave("fetch", "fetch-bundle-uri", the_repository);
827831
return result;
828832
}
829833

0 commit comments

Comments
 (0)