Skip to content

Commit e8fe4ef

Browse files
Merge pull request #160: trace2:gvfs:experiment Add experimental regions and data events to help diagnose checkout and reset perf problems
Add experimental regions and data events to help diagnose performance problems in checkout and reset. We may or may not choose to carry these changes forward in the future.
2 parents e703eda + 8d2815d commit e8fe4ef

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
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
}

cache-tree.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,31 @@ static void discard_unused_subtrees(struct cache_tree *it)
221221
}
222222
}
223223

224-
int cache_tree_fully_valid(struct cache_tree *it)
224+
static int cache_tree_fully_valid_1(struct cache_tree *it)
225225
{
226226
int i;
227227
if (!it)
228228
return 0;
229229
if (it->entry_count < 0 || !has_object_file(&it->oid))
230230
return 0;
231231
for (i = 0; i < it->subtree_nr; i++) {
232-
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
232+
if (!cache_tree_fully_valid_1(it->down[i]->cache_tree))
233233
return 0;
234234
}
235235
return 1;
236236
}
237237

238+
int cache_tree_fully_valid(struct cache_tree *it)
239+
{
240+
int result;
241+
242+
trace2_region_enter("cache_tree", "fully_valid", NULL);
243+
result = cache_tree_fully_valid_1(it);
244+
trace2_region_leave("cache_tree", "fully_valid", NULL);
245+
246+
return result;
247+
}
248+
238249
static int update_one(struct cache_tree *it,
239250
struct cache_entry **cache,
240251
int entries,

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: 8 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,10 +1475,14 @@ 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

1483+
trace2_region_enter("exp", "unpack_trees", NULL);
1484+
nr_unpack_entry_at_start = get_nr_unpack_entry();
1485+
14811486
trace_performance_enter();
14821487
memset(&el, 0, sizeof(el));
14831488
if (!core_apply_sparse_checkout || !o->update)
@@ -1658,6 +1663,9 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
16581663
done:
16591664
trace_performance_leave("unpack_trees");
16601665
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));
1668+
trace2_region_leave("exp", "unpack_trees", NULL);
16611669
return ret;
16621670

16631671
return_failed:

virtualfilesystem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ void apply_virtualfilesystem(struct index_state *istate)
259259
if (!git_config_get_virtualfilesystem())
260260
return;
261261

262+
trace2_region_enter("vfs", "apply", the_repository);
263+
262264
if (!virtual_filesystem_data.len)
263265
get_virtual_filesystem_data(&virtual_filesystem_data);
264266

@@ -329,6 +331,8 @@ void apply_virtualfilesystem(struct index_state *istate)
329331
trace2_data_intmax("vfs", the_repository, "apply/nr_bulk_skip", nr_bulk_skip);
330332
trace2_data_intmax("vfs", the_repository, "apply/nr_explicit_skip", nr_explicit_skip);
331333
}
334+
335+
trace2_region_leave("vfs", "apply", the_repository);
332336
}
333337

334338
/*

0 commit comments

Comments
 (0)