Skip to content

Commit 789f7e2

Browse files
pcloudsgitster
authored andcommitted
unpack-trees.c: add performance tracing
We're going to optimize unpack_trees() a bit in the following patches. Let's add some tracing to measure how long it takes before and after. This is the baseline ("git checkout -" on gcc.git, 80k files on worktree) 0.018239226 s: read cache .git/index 0.052541655 s: preload index 0.001537598 s: refresh index 0.168167768 s: unpack trees 0.002897186 s: update worktree after a merge 0.131661745 s: repair cache-tree 0.075389117 s: write index, changed mask = 2a 0.111702023 s: unpack trees 0.000023245 s: update worktree after a merge 0.111793866 s: diff-index 0.587933288 s: git command: /home/pclouds/w/git/git checkout - Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ffc6fa0 commit 789f7e2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

cache-tree.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ static int update_one(struct cache_tree *it,
426426

427427
int cache_tree_update(struct index_state *istate, int flags)
428428
{
429+
uint64_t start = getnanotime();
429430
struct cache_tree *it = istate->cache_tree;
430431
struct cache_entry **cache = istate->cache;
431432
int entries = istate->cache_nr;
@@ -437,6 +438,7 @@ int cache_tree_update(struct index_state *istate, int flags)
437438
if (i < 0)
438439
return i;
439440
istate->cache_changed |= CACHE_TREE_CHANGED;
441+
trace_performance_since(start, "repair cache-tree");
440442
return 0;
441443
}
442444

unpack-trees.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ static int check_updates(struct unpack_trees_options *o)
352352
struct progress *progress = NULL;
353353
struct index_state *index = &o->result;
354354
struct checkout state = CHECKOUT_INIT;
355+
uint64_t start = getnanotime();
355356
int i;
356357

357358
state.force = 1;
@@ -423,6 +424,7 @@ static int check_updates(struct unpack_trees_options *o)
423424
errs |= finish_delayed_checkout(&state);
424425
if (o->update)
425426
git_attr_set_direction(GIT_ATTR_CHECKIN, NULL);
427+
trace_performance_since(start, "update worktree after a merge");
426428
return errs != 0;
427429
}
428430

@@ -1275,6 +1277,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
12751277
int i, ret;
12761278
static struct cache_entry *dfc;
12771279
struct exclude_list el;
1280+
uint64_t start = getnanotime();
12781281

12791282
if (len > MAX_UNPACK_TREES)
12801283
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
@@ -1423,6 +1426,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
14231426
goto done;
14241427
}
14251428
}
1429+
trace_performance_since(start, "unpack trees");
14261430

14271431
ret = check_updates(o) ? (-2) : 0;
14281432
if (o->dst_index) {

0 commit comments

Comments
 (0)