]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-objects: add tracing for various packfile metrics
authorTaylor Blau <me@ttaylorr.com>
Thu, 14 Dec 2023 22:24:36 +0000 (17:24 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Dec 2023 22:38:09 +0000 (14:38 -0800)
As part of the multi-pack reuse effort, we will want to add some tests
that assert that we reused a certain number of objects from a certain
number of packs.

We could do this by grepping through the stderr output of
`pack-objects`, but doing so would be brittle in case the output format
changed.

Instead, let's use the trace2 mechanism to log various pieces of
information about the generated packfile, which we can then use to
compare against desired values.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c

index 7eb035eb7d0df597af635e8a2b7cffa60b07a448..7aae9f104bff7534cbc8451c1bc7ece36f23d99f 100644 (file)
@@ -4595,6 +4595,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                           reuse_packfile_objects,
                           (uintmax_t)reuse_packfiles_used_nr);
 
+       trace2_data_intmax("pack-objects", the_repository, "written", written);
+       trace2_data_intmax("pack-objects", the_repository, "written/delta", written_delta);
+       trace2_data_intmax("pack-objects", the_repository, "reused", reused);
+       trace2_data_intmax("pack-objects", the_repository, "reused/delta", reused_delta);
+       trace2_data_intmax("pack-objects", the_repository, "pack-reused", reuse_packfile_objects);
+       trace2_data_intmax("pack-objects", the_repository, "packs-reused", reuse_packfiles_used_nr);
+
 cleanup:
        clear_packing_data(&to_pack);
        list_objects_filter_release(&filter_options);