Merge branch 'tn/fetch-pack-trace-packfile-uri' into next

The process of downloading packfile URIs in protocol v2 has been
instrumented with a Trace2 region.  This visibility allows tracking
the cumulative time spent downloading external packs and the number
of advertised URIs without emitting a separate event per pack.

* tn/fetch-pack-trace-packfile-uri:
  fetch-pack: trace packfile URI downloads
next
Junio C Hamano 2026-09-08 12:15:03 -07:00
commit dd3c024f52
2 changed files with 18 additions and 1 deletions

View File

@ -1853,6 +1853,13 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
}
}

if (packfile_uris.nr) {
trace2_region_enter("fetch-pack", "packfile-uris",
the_repository);
trace2_data_intmax("fetch-pack", the_repository,
"packfile-uris/count", packfile_uris.nr);
}

for (i = 0; i < packfile_uris.nr; i++) {
bool created_keep;
int j;
@ -1906,6 +1913,11 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
repo_get_object_directory(the_repository),
packhash));
}

if (packfile_uris.nr)
trace2_region_leave("fetch-pack", "packfile-uris",
the_repository);

string_list_clear(&packfile_uris, 0);
strvec_clear(&index_pack_args);


View File

@ -1223,7 +1223,7 @@ configure_exclusion () {

test_expect_success 'part of packfile response provided as URI' '
P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
rm -rf "$P" http_child log &&
rm -rf "$P" http_child log trace2 &&

git init "$P" &&
git -C "$P" config "uploadpack.allowsidebandall" "true" &&
@ -1238,10 +1238,15 @@ test_expect_success 'part of packfile response provided as URI' '
configure_exclusion "$P" other-blob >h2 &&

GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \
GIT_TRACE2_EVENT="$(pwd)/trace2" \
git -c protocol.version=2 \
-c fetch.uriprotocols=http,https \
clone "$HTTPD_URL/smart/http_parent" http_child &&

test_grep \"event\":\"region_enter\".*\"label\":\"packfile-uris\" trace2 &&
test_grep \"key\":\"packfile-uris/count\",\"value\":\"2\" trace2 &&
test_grep \"event\":\"region_leave\".*\"label\":\"packfile-uris\" trace2 &&

# Ensure that my-blob and other-blob are in separate packfiles.
for idx in http_child/.git/objects/pack/*.idx
do