Skip to content

Commit 8d2815d

Browse files
committed
trace2:gvfs:experiment: add unpack_entry() counter to unpack_trees() and report_tracking()
Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 1c2e3dc commit 8d2815d

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
@@ -25,6 +25,7 @@
2525
#include "submodule-config.h"
2626
#include "submodule.h"
2727
#include "advice.h"
28+
#include "packfile.h"
2829

2930
static int checkout_optimize_new_branch;
3031

@@ -921,8 +922,13 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
921922
strbuf_release(&msg);
922923
if (!opts->quiet &&
923924
(new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD")))) {
925+
unsigned long nr_unpack_entry_at_start;
926+
924927
trace2_region_enter("exp", "report_tracking", the_repository);
928+
nr_unpack_entry_at_start = get_nr_unpack_entry();
925929
report_tracking(new_branch_info);
930+
trace2_data_intmax("exp", NULL, "report_tracking/nr_unpack_entries",
931+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
926932
trace2_region_leave("exp", "report_tracking", the_repository);
927933
}
928934
}

packfile.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,13 @@ static void *read_object(struct repository *r,
16461646
return content;
16471647
}
16481648

1649+
static unsigned long g_nr_unpack_entry;
1650+
1651+
unsigned long get_nr_unpack_entry(void)
1652+
{
1653+
return g_nr_unpack_entry;
1654+
}
1655+
16491656
void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16501657
enum object_type *final_type, unsigned long *final_size)
16511658
{
@@ -1659,6 +1666,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset,
16591666
int delta_stack_nr = 0, delta_stack_alloc = UNPACK_ENTRY_STACK_PREALLOC;
16601667
int base_from_cache = 0;
16611668

1669+
g_nr_unpack_entry++;
1670+
16621671
write_pack_access_log(p, obj_offset);
16631672

16641673
/* 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
@@ -193,4 +193,9 @@ int is_promisor_object(const struct object_id *oid);
193193
int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
194194
size_t idx_size, struct packed_git *p);
195195

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

unpack-trees.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "fetch-object.h"
2020
#include "gvfs.h"
2121
#include "virtualfilesystem.h"
22+
#include "packfile.h"
2223

2324
/*
2425
* Error messages expected by scripts out of plumbing commands such as
@@ -1474,11 +1475,13 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
14741475
int i, ret;
14751476
static struct cache_entry *dfc;
14761477
struct exclude_list el;
1478+
unsigned long nr_unpack_entry_at_start;
14771479

14781480
if (len > MAX_UNPACK_TREES)
14791481
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
14801482

14811483
trace2_region_enter("exp", "unpack_trees", NULL);
1484+
nr_unpack_entry_at_start = get_nr_unpack_entry();
14821485

14831486
trace_performance_enter();
14841487
memset(&el, 0, sizeof(el));
@@ -1660,6 +1663,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
16601663
done:
16611664
trace_performance_leave("unpack_trees");
16621665
clear_exclude_list(&el);
1666+
trace2_data_intmax("exp", NULL, "unpack_trees/nr_unpack_entries",
1667+
(intmax_t)(get_nr_unpack_entry() - nr_unpack_entry_at_start));
16631668
trace2_region_leave("exp", "unpack_trees", NULL);
16641669
return ret;
16651670

0 commit comments

Comments
 (0)