Skip to content

Commit 3b9ec27

Browse files
committed
Merge branch 'js/trace2-fetch-push'
Dev support. * js/trace2-fetch-push: transport: push codepath can take arbitrary repository push: add trace2 instrumentation fetch: add trace2 instrumentation
2 parents c7d2ced + 360c7ba commit 3b9ec27

File tree

4 files changed

+41
-10
lines changed

4 files changed

+41
-10
lines changed

builtin/fetch.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,11 @@ static int check_exist_and_connected(struct ref *ref_map)
10851085
static int fetch_refs(struct transport *transport, struct ref *ref_map)
10861086
{
10871087
int ret = check_exist_and_connected(ref_map);
1088-
if (ret)
1088+
if (ret) {
1089+
trace2_region_enter("fetch", "fetch_refs", the_repository);
10891090
ret = transport_fetch_refs(transport, ref_map);
1091+
trace2_region_leave("fetch", "fetch_refs", the_repository);
1092+
}
10901093
if (!ret)
10911094
/*
10921095
* Keep the new pack's ".keep" file around to allow the caller
@@ -1102,11 +1105,14 @@ static int consume_refs(struct transport *transport, struct ref *ref_map)
11021105
{
11031106
int connectivity_checked = transport->smart_options
11041107
? transport->smart_options->connectivity_checked : 0;
1105-
int ret = store_updated_refs(transport->url,
1106-
transport->remote->name,
1107-
connectivity_checked,
1108-
ref_map);
1108+
int ret;
1109+
trace2_region_enter("fetch", "consume_refs", the_repository);
1110+
ret = store_updated_refs(transport->url,
1111+
transport->remote->name,
1112+
connectivity_checked,
1113+
ref_map);
11091114
transport_unlock_pack(transport);
1115+
trace2_region_leave("fetch", "consume_refs", the_repository);
11101116
return ret;
11111117
}
11121118

@@ -1351,9 +1357,11 @@ static int do_fetch(struct transport *transport,
13511357
argv_array_push(&ref_prefixes, "refs/tags/");
13521358
}
13531359

1354-
if (must_list_refs)
1360+
if (must_list_refs) {
1361+
trace2_region_enter("fetch", "remote_refs", the_repository);
13551362
remote_refs = transport_get_remote_refs(transport, &ref_prefixes);
1356-
else
1363+
trace2_region_leave("fetch", "remote_refs", the_repository);
1364+
} else
13571365
remote_refs = NULL;
13581366

13591367
argv_array_clear(&ref_prefixes);

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);

fetch-pack.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ static int find_common(struct fetch_negotiator *negotiator,
382382
state_len = 0;
383383
}
384384

385+
trace2_region_enter("fetch-pack", "negotiation_v0_v1", the_repository);
385386
flushes = 0;
386387
retval = -1;
387388
if (args->no_dependents)
@@ -466,6 +467,7 @@ static int find_common(struct fetch_negotiator *negotiator,
466467
}
467468
}
468469
done:
470+
trace2_region_leave("fetch-pack", "negotiation_v0_v1", the_repository);
469471
if (!got_ready || !no_done) {
470472
packet_buf_write(&req_buf, "done\n");
471473
send_request(args, fd[1], &req_buf);
@@ -1378,7 +1380,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
13781380
enum fetch_state state = FETCH_CHECK_LOCAL;
13791381
struct oidset common = OIDSET_INIT;
13801382
struct packet_reader reader;
1381-
int in_vain = 0;
1383+
int in_vain = 0, negotiation_started = 0;
13821384
int haves_to_send = INITIAL_FLUSH;
13831385
struct fetch_negotiator negotiator;
13841386
fetch_negotiator_init(r, &negotiator);
@@ -1421,6 +1423,12 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
14211423
}
14221424
break;
14231425
case FETCH_SEND_REQUEST:
1426+
if (!negotiation_started) {
1427+
negotiation_started = 1;
1428+
trace2_region_enter("fetch-pack",
1429+
"negotiation_v2",
1430+
the_repository);
1431+
}
14241432
if (send_fetch_request(&negotiator, fd[1], args, ref,
14251433
&common,
14261434
&haves_to_send, &in_vain,
@@ -1444,6 +1452,9 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
14441452
}
14451453
break;
14461454
case FETCH_GET_PACK:
1455+
trace2_region_leave("fetch-pack",
1456+
"negotiation_v2",
1457+
the_repository);
14471458
/* Check for shallow-info section */
14481459
if (process_section_header(&reader, "shallow-info", 1))
14491460
receive_shallow_info(args, &reader, shallows, si);

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", r);
11481149
remote_refs = transport->vtable->get_refs_list(transport, 1,
11491150
&ref_prefixes);
1151+
trace2_region_leave("transport_push", "get_refs_list", r);
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", r);
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", r);
11971201
die(_("failed to push all needed submodules"));
11981202
}
11991203
oid_array_clear(&commits);
1204+
trace2_region_leave("transport_push", "push_submodules", r);
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", r);
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", r);
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", r);
12241232
}
12251233

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

0 commit comments

Comments
 (0)