Skip to content

Commit 9652bc6

Browse files
jeffhostetlerderrickstolee
authored andcommitted
trace2:gvfs:experiment: add unpack_entry() counter to unpack_trees() and report_tracking()
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
1 parent b246a42 commit 9652bc6

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

builtin/checkout.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "lockfile.h"
1515
#include "merge-recursive.h"
1616
#include "object-store.h"
17+
#include "packfile.h"
1718
#include "parse-options.h"
1819
#include "refs.h"
1920
#include "remote.h"
@@ -979,8 +980,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
979980
strbuf_release(&msg);
980981
if (!opts->quiet &&
981982
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
983+
unsigned long nr_unpack_entry_at_start;
984+
982985
trace2_region_enter("exp", "report_tracking", the_repository);
986+
nr_unpack_entry_at_start = get_nr_unpack_entry();
983987
report_tracking(new_branch_info);
988+
trace2_data_intmax("exp", NULL, "report_tracking/nr_unpack_entries",
989+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
984990
trace2_region_leave("exp", "report_tracking", the_repository);
985991
}
986992
}

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,13 @@ static void *read_object(struct repository *r,
16781678
return content;
16791679
}
16801680

1681+
static unsigned long g_nr_unpack_entry;
1682+
1683+
unsigned long get_nr_unpack_entry(void)
1684+
{
1685+
return g_nr_unpack_entry;
1686+
}
1687+
16811688
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16821689
enum object_type *final_type, unsigned long *final_size)
16831690
{
@@ -1691,6 +1698,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16911698
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16921699
int base_from_cache = 0;
16931700

1701+
g_nr_unpack_entry++;
1702+
16941703
write_pack_access_log(p, obj_offset);
16951704

16961705
/* PHASE 1: drill down to the innermost base object */

packfile.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,9 @@ int is_promisor_object(const struct object_id *oid);
195195
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
196196
size_t idx_size, struct packed_git *p);
197197

198+
/*
199+
* Return the number of objects fetched from a packfile.
200+
*/
201+
unsigned long get_nr_unpack_entry(void);
202+
198203
#endif

unpack-trees.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "tree-walk.h"
1010
#include "cache-tree.h"
1111
#include "unpack-trees.h"
12+
#include "packfile.h"
1213
#include "progress.h"
1314
#include "refs.h"
1415
#include "attr.h"
@@ -1877,6 +1878,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
18771878
struct pattern_list pl;
18781879
int free_pattern_list = 0;
18791880
struct dir_struct dir = DIR_INIT;
1881+
unsigned long nr_unpack_entry_at_start;
18801882

18811883
if (o->reset == UNPACK_RESET_INVALID)
18821884
BUG("o->reset had a value of 1; should be UNPACK_TREES_*_UNTRACKED");
@@ -1887,6 +1889,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
18871889
BUG("o->dir is for internal use only");
18881890

18891891
trace2_region_enter("exp", "unpack_trees", NULL);
1892+
nr_unpack_entry_at_start = get_nr_unpack_entry();
18901893

18911894
trace_performance_enter();
18921895
trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
@@ -2086,6 +2089,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
20862089
}
20872090
trace2_region_leave("unpack_trees", "unpack_trees", the_repository);
20882091
trace_performance_leave("unpack_trees");
2092+
trace2_data_intmax("unpack_trees", NULL, "unpack_trees/nr_unpack_entries",
2093+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
20892094
trace2_region_leave("exp", "unpack_trees", NULL);
20902095
return ret;
20912096

0 commit comments

Comments
 (0)