Skip to content

Commit 1059afc

Browse files
jeffhostetlerdscho
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 b2aa9e0 commit 1059afc

4 files changed

Lines changed: 25 additions & 0 deletions

File tree

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"
@@ -987,8 +988,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
987988
strbuf_release(&msg);
988989
if (!opts->quiet &&
989990
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
991+
unsigned long nr_unpack_entry_at_start;
992+
990993
trace2_region_enter("exp", "report_tracking", the_repository);
994+
nr_unpack_entry_at_start = get_nr_unpack_entry();
991995
report_tracking(new_branch_info);
996+
trace2_data_intmax("exp", NULL, "report_tracking/nr_unpack_entries",
997+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
992998
trace2_region_leave("exp", "report_tracking", the_repository);
993999
}
9941000
}

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,13 @@ static void *read_object(struct repository *r,
16661666
return content;
16671667
}
16681668

1669+
static unsigned long g_nr_unpack_entry;
1670+
1671+
unsigned long get_nr_unpack_entry(void)
1672+
{
1673+
return g_nr_unpack_entry;
1674+
}
1675+
16691676
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16701677
enum object_type *final_type, unsigned long *final_size)
16711678
{
@@ -1679,6 +1686,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16791686
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16801687
int base_from_cache = 0;
16811688

1689+
g_nr_unpack_entry++;
1690+
16821691
write_pack_access_log(p, obj_offset);
16831692

16841693
/* 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)