Skip to content

Commit

Permalink
trace2:gvfs:experiment: add unpack_entry() counter to unpack_trees() …
Browse files Browse the repository at this point in the history
…and report_tracking()

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  • Loading branch information
jeffhostetler authored and dscho committed Aug 16, 2023
1 parent 2cb55c2 commit fa4bfcf
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "merge-recursive.h"
#include "object-name.h"
#include "object-store-ll.h"
#include "packfile.h"
#include "parse-options.h"
#include "path.h"
#include "preload-index.h"
Expand Down Expand Up @@ -1019,8 +1020,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
strbuf_release(&msg);
if (!opts->quiet &&
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
unsigned long nr_unpack_entry_at_start;

trace2_region_enter("exp", "report_tracking", the_repository);
nr_unpack_entry_at_start = get_nr_unpack_entry();
report_tracking(new_branch_info);
trace2_data_intmax("exp", NULL, "report_tracking/nr_unpack_entries",
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
trace2_region_leave("exp", "report_tracking", the_repository);
}
}
Expand Down
9 changes: 9 additions & 0 deletions packfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,13 @@ struct unpack_entry_stack_ent {
unsigned long size;
};

static unsigned long g_nr_unpack_entry;

unsigned long get_nr_unpack_entry(void)
{
return g_nr_unpack_entry;
}

void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
enum object_type *final_type, unsigned long *final_size)
{
Expand All @@ -1679,6 +1686,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
int base_from_cache = 0;

g_nr_unpack_entry++;

write_pack_access_log(p, obj_offset);

/* PHASE 1: drill down to the innermost base object */
Expand Down
5 changes: 5 additions & 0 deletions packfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,9 @@ int is_promisor_object(const struct object_id *oid);
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
size_t idx_size, struct packed_git *p);

/*
* Return the number of objects fetched from a packfile.
*/
unsigned long get_nr_unpack_entry(void);

#endif
5 changes: 5 additions & 0 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "tree-walk.h"
#include "cache-tree.h"
#include "unpack-trees.h"
#include "packfile.h"
#include "progress.h"
#include "refs.h"
#include "attr.h"
Expand Down Expand Up @@ -1890,6 +1891,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
struct pattern_list pl;
int free_pattern_list = 0;
struct dir_struct dir = DIR_INIT;
unsigned long nr_unpack_entry_at_start;

if (o->reset == UNPACK_RESET_INVALID)
BUG("o->reset had a value of 1; should be UNPACK_TREES_*_UNTRACKED");
Expand All @@ -1904,6 +1906,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
BUG("o->df_conflict_entry is an output only field");

trace2_region_enter("exp", "unpack_trees", NULL);
nr_unpack_entry_at_start = get_nr_unpack_entry();

trace_performance_enter();
trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
Expand Down Expand Up @@ -2109,6 +2112,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
}
trace2_region_leave("unpack_trees", "unpack_trees", the_repository);
trace_performance_leave("unpack_trees");
trace2_data_intmax("unpack_trees", NULL, "unpack_trees/nr_unpack_entries",
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
trace2_region_leave("exp", "unpack_trees", NULL);
return ret;

Expand Down

0 comments on commit fa4bfcf

Please sign in to comment.