fetch: add trace2 instrumentation

Add trace2 regions to fetch-pack.c and builtins/fetch.c to better track
time spent in the various phases of a fetch:

* listing refs
* negotiation for protocol versions v0-v2
* fetching refs
* consuming refs

Signed-off-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Josh Steadmon 2019-10-02 16:49:28 -07:00 committed by Junio C Hamano
parent bc12974a89
commit 5fc31180d8
2 changed files with 27 additions and 8 deletions

View File

@ -1071,8 +1071,11 @@ static int check_exist_and_connected(struct ref *ref_map)
static int fetch_refs(struct transport *transport, struct ref *ref_map) static int fetch_refs(struct transport *transport, struct ref *ref_map)
{ {
int ret = check_exist_and_connected(ref_map); int ret = check_exist_and_connected(ref_map);
if (ret) if (ret) {
trace2_region_enter("fetch", "fetch_refs", the_repository);
ret = transport_fetch_refs(transport, ref_map); ret = transport_fetch_refs(transport, ref_map);
trace2_region_leave("fetch", "fetch_refs", the_repository);
}
if (!ret) if (!ret)
/* /*
* Keep the new pack's ".keep" file around to allow the caller * Keep the new pack's ".keep" file around to allow the caller
@ -1088,11 +1091,14 @@ static int consume_refs(struct transport *transport, struct ref *ref_map)
{ {
int connectivity_checked = transport->smart_options int connectivity_checked = transport->smart_options
? transport->smart_options->connectivity_checked : 0; ? transport->smart_options->connectivity_checked : 0;
int ret = store_updated_refs(transport->url, int ret;
transport->remote->name, trace2_region_enter("fetch", "consume_refs", the_repository);
connectivity_checked, ret = store_updated_refs(transport->url,
ref_map); transport->remote->name,
connectivity_checked,
ref_map);
transport_unlock_pack(transport); transport_unlock_pack(transport);
trace2_region_leave("fetch", "consume_refs", the_repository);
return ret; return ret;
} }
@ -1337,9 +1343,11 @@ static int do_fetch(struct transport *transport,
argv_array_push(&ref_prefixes, "refs/tags/"); argv_array_push(&ref_prefixes, "refs/tags/");
} }
if (must_list_refs) if (must_list_refs) {
trace2_region_enter("fetch", "remote_refs", the_repository);
remote_refs = transport_get_remote_refs(transport, &ref_prefixes); remote_refs = transport_get_remote_refs(transport, &ref_prefixes);
else trace2_region_leave("fetch", "remote_refs", the_repository);
} else
remote_refs = NULL; remote_refs = NULL;
argv_array_clear(&ref_prefixes); argv_array_clear(&ref_prefixes);

View File

@ -382,6 +382,7 @@ static int find_common(struct fetch_negotiator *negotiator,
state_len = 0; state_len = 0;
} }
trace2_region_enter("fetch-pack", "negotiation_v0_v1", the_repository);
flushes = 0; flushes = 0;
retval = -1; retval = -1;
if (args->no_dependents) if (args->no_dependents)
@ -466,6 +467,7 @@ static int find_common(struct fetch_negotiator *negotiator,
} }
} }
done: done:
trace2_region_leave("fetch-pack", "negotiation_v0_v1", the_repository);
if (!got_ready || !no_done) { if (!got_ready || !no_done) {
packet_buf_write(&req_buf, "done\n"); packet_buf_write(&req_buf, "done\n");
send_request(args, fd[1], &req_buf); send_request(args, fd[1], &req_buf);
@ -1378,7 +1380,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
enum fetch_state state = FETCH_CHECK_LOCAL; enum fetch_state state = FETCH_CHECK_LOCAL;
struct oidset common = OIDSET_INIT; struct oidset common = OIDSET_INIT;
struct packet_reader reader; struct packet_reader reader;
int in_vain = 0; int in_vain = 0, negotiation_started = 0;
int haves_to_send = INITIAL_FLUSH; int haves_to_send = INITIAL_FLUSH;
struct fetch_negotiator negotiator; struct fetch_negotiator negotiator;
fetch_negotiator_init(r, &negotiator); fetch_negotiator_init(r, &negotiator);
@ -1421,6 +1423,12 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
} }
break; break;
case FETCH_SEND_REQUEST: case FETCH_SEND_REQUEST:
if (!negotiation_started) {
negotiation_started = 1;
trace2_region_enter("fetch-pack",
"negotiation_v2",
the_repository);
}
if (send_fetch_request(&negotiator, fd[1], args, ref, if (send_fetch_request(&negotiator, fd[1], args, ref,
&common, &common,
&haves_to_send, &in_vain, &haves_to_send, &in_vain,
@ -1444,6 +1452,9 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
} }
break; break;
case FETCH_GET_PACK: case FETCH_GET_PACK:
trace2_region_leave("fetch-pack",
"negotiation_v2",
the_repository);
/* Check for shallow-info section */ /* Check for shallow-info section */
if (process_section_header(&reader, "shallow-info", 1)) if (process_section_header(&reader, "shallow-info", 1))
receive_shallow_info(args, &reader, shallows, si); receive_shallow_info(args, &reader, shallows, si);