Commit

7129d77f1c0c465aca2c1ca5eef4e42b6adf7427

fetch-pack: trace packfile URI downloads

When a protocol v2 fetch includes packfile URIs, the client downloads
each advertised pack in a separate http-fetch process. Existing Trace2
regions cover negotiation, but not the time spent downloading these
packs or the number of advertised URIs.

Add a Trace2 region around the packfile URI download loop and record the
number of URIs. This makes the cost of downloading external packs
visible without emitting an event for each pack.

Extend the existing packfile URI test to verify the region and count.

Signed-off-by: Ted Nyman <tnyman@openai.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ted Nyman <tnyman@openai.com> · 2026-07-26 08:33 UTC · committed by Junio C Hamano

Browse files
2 files changed, +18 −1
modified fetch-pack.c
@@ -1886,6 +1886,13 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1886 1886 }
1887 1887 }
1888 1888
1889 + if (packfile_uris.nr) {
1890 + trace2_region_enter("fetch-pack", "packfile-uris",
1891 + the_repository);
1892 + trace2_data_intmax("fetch-pack", the_repository,
1893 + "packfile-uris/count", packfile_uris.nr);
1894 + }
1895 +
1889 1896 for (i = 0; i < packfile_uris.nr; i++) {
1890 1897 int j;
1891 1898 struct child_process cmd = CHILD_PROCESS_INIT;
@@ -1936,6 +1943,11 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1936 1943 repo_get_object_directory(the_repository),
1937 1944 packname));
1938 1945 }
1946 +
1947 + if (packfile_uris.nr)
1948 + trace2_region_leave("fetch-pack", "packfile-uris",
1949 + the_repository);
1950 +
1939 1951 string_list_clear(&packfile_uris, 0);
1940 1952 strvec_clear(&index_pack_args);
1941 1953
modified t/t5702-protocol-v2.sh
@@ -1223,7 +1223,7 @@ configure_exclusion () {
1223 1223
1224 1224 test_expect_success 'part of packfile response provided as URI' '
1225 1225 P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
1226 - rm -rf "$P" http_child log &&
1226 + rm -rf "$P" http_child log trace2 &&
1227 1227
1228 1228 git init "$P" &&
1229 1229 git -C "$P" config "uploadpack.allowsidebandall" "true" &&
@@ -1238,10 +1238,15 @@ test_expect_success 'part of packfile response provided as URI' '
1238 1238 configure_exclusion "$P" other-blob >h2 &&
1239 1239
1240 1240 GIT_TRACE=1 GIT_TRACE_PACKET="$(pwd)/log" GIT_TEST_SIDEBAND_ALL=1 \
1241 + GIT_TRACE2_EVENT="$(pwd)/trace2" \
1241 1242 git -c protocol.version=2 \
1242 1243 -c fetch.uriprotocols=http,https \
1243 1244 clone "$HTTPD_URL/smart/http_parent" http_child &&
1244 1245
1246 + test_grep \"event\":\"region_enter\".*\"label\":\"packfile-uris\" trace2 &&
1247 + test_grep \"key\":\"packfile-uris/count\",\"value\":\"2\" trace2 &&
1248 + test_grep \"event\":\"region_leave\".*\"label\":\"packfile-uris\" trace2 &&
1249 +
1245 1250 # Ensure that my-blob and other-blob are in separate packfiles.
1246 1251 for idx in http_child/.git/objects/pack/*.idx
1247 1252 do