Skip to content

Commit 25e4b80

Browse files
steadmongitster
authored andcommitted
push: add trace2 instrumentation
Add trace2 regions in transport.c and builtin/push.c to better track time spent in various phases of pushing: * Listing refs * Checking submodules * Pushing submodules * Pushing refs Signed-off-by: Josh Steadmon <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fc3118 commit 25e4b80

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

builtin/push.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,10 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
357357

358358
if (verbosity > 0)
359359
fprintf(stderr, _("Pushing to %s\n"), transport->url);
360+
trace2_region_enter("push", "transport_push", the_repository);
360361
err = transport_push(the_repository, transport,
361362
rs, flags, &reject_reasons);
363+
trace2_region_leave("push", "transport_push", the_repository);
362364
if (err != 0) {
363365
fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
364366
error(_("failed to push some refs to '%s'"), transport->url);

transport.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,10 @@ int transport_push(struct repository *r,
11451145

11461146
refspec_ref_prefixes(rs, &ref_prefixes);
11471147

1148+
trace2_region_enter("transport_push", "get_refs_list", the_repository);
11481149
remote_refs = transport->vtable->get_refs_list(transport, 1,
11491150
&ref_prefixes);
1151+
trace2_region_leave("transport_push", "get_refs_list", the_repository);
11501152

11511153
argv_array_clear(&ref_prefixes);
11521154

@@ -1182,6 +1184,7 @@ int transport_push(struct repository *r,
11821184
struct ref *ref = remote_refs;
11831185
struct oid_array commits = OID_ARRAY_INIT;
11841186

1187+
trace2_region_enter("transport_push", "push_submodules", the_repository);
11851188
for (; ref; ref = ref->next)
11861189
if (!is_null_oid(&ref->new_oid))
11871190
oid_array_append(&commits,
@@ -1194,9 +1197,11 @@ int transport_push(struct repository *r,
11941197
transport->push_options,
11951198
pretend)) {
11961199
oid_array_clear(&commits);
1200+
trace2_region_leave("transport_push", "push_submodules", the_repository);
11971201
die(_("failed to push all needed submodules"));
11981202
}
11991203
oid_array_clear(&commits);
1204+
trace2_region_leave("transport_push", "push_submodules", the_repository);
12001205
}
12011206

12021207
if (((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) ||
@@ -1207,6 +1212,7 @@ int transport_push(struct repository *r,
12071212
struct string_list needs_pushing = STRING_LIST_INIT_DUP;
12081213
struct oid_array commits = OID_ARRAY_INIT;
12091214

1215+
trace2_region_enter("transport_push", "check_submodules", the_repository);
12101216
for (; ref; ref = ref->next)
12111217
if (!is_null_oid(&ref->new_oid))
12121218
oid_array_append(&commits,
@@ -1217,15 +1223,19 @@ int transport_push(struct repository *r,
12171223
transport->remote->name,
12181224
&needs_pushing)) {
12191225
oid_array_clear(&commits);
1226+
trace2_region_leave("transport_push", "check_submodules", the_repository);
12201227
die_with_unpushed_submodules(&needs_pushing);
12211228
}
12221229
string_list_clear(&needs_pushing, 0);
12231230
oid_array_clear(&commits);
1231+
trace2_region_leave("transport_push", "check_submodules", the_repository);
12241232
}
12251233

1226-
if (!(flags & TRANSPORT_RECURSE_SUBMODULES_ONLY))
1234+
if (!(flags & TRANSPORT_RECURSE_SUBMODULES_ONLY)) {
1235+
trace2_region_enter("transport_push", "push_refs", the_repository);
12271236
push_ret = transport->vtable->push_refs(transport, remote_refs, flags);
1228-
else
1237+
trace2_region_leave("transport_push", "push_refs", the_repository);
1238+
} else
12291239
push_ret = 0;
12301240
err = push_had_errors(remote_refs);
12311241
ret = push_ret | err;

0 commit comments

Comments
 (0)