Skip to content

Commit 89aaab1

Browse files
Haizzzttaylorr
authored andcommitted
index: add trace2 region for clear skip worktree
When using sparse checkout, clear_skip_worktree_from_present_files() must enumerate index entries to find ones with the SKIP_WORKTREE bit to determine whether those index entries exist on disk (in which case their SKIP_WORKTREE bit should be removed). In a large repository, this may take considerable time depending on the size of the index. Add a trace2 region to surface this information, keeping a count of how many paths have been checked. Separately, keep counts after a full index is materialized. Signed-off-by: Anh Le <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 5af5e54 commit 89aaab1

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

sparse-index.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,24 +493,40 @@ void clear_skip_worktree_from_present_files(struct index_state *istate)
493493
int dir_found = 1;
494494

495495
int i;
496+
int path_count[2] = {0, 0};
497+
int restarted = 0;
496498

497499
if (!core_apply_sparse_checkout ||
498500
sparse_expect_files_outside_of_patterns)
499501
return;
500502

503+
trace2_region_enter("index", "clear_skip_worktree_from_present_files",
504+
istate->repo);
501505
restart:
502506
for (i = 0; i < istate->cache_nr; i++) {
503507
struct cache_entry *ce = istate->cache[i];
504508

505-
if (ce_skip_worktree(ce) &&
506-
path_found(ce->name, &last_dirname, &dir_len, &dir_found)) {
507-
if (S_ISSPARSEDIR(ce->ce_mode)) {
508-
ensure_full_index(istate);
509-
goto restart;
509+
if (ce_skip_worktree(ce)) {
510+
path_count[restarted]++;
511+
if (path_found(ce->name, &last_dirname, &dir_len, &dir_found)) {
512+
if (S_ISSPARSEDIR(ce->ce_mode)) {
513+
ensure_full_index(istate);
514+
restarted = 1;
515+
goto restart;
516+
}
517+
ce->ce_flags &= ~CE_SKIP_WORKTREE;
510518
}
511-
ce->ce_flags &= ~CE_SKIP_WORKTREE;
512519
}
513520
}
521+
522+
if (path_count[0])
523+
trace2_data_intmax("index", istate->repo,
524+
"sparse_path_count", path_count[0]);
525+
if (restarted)
526+
trace2_data_intmax("index", istate->repo,
527+
"sparse_path_count_full", path_count[1]);
528+
trace2_region_leave("index", "clear_skip_worktree_from_present_files",
529+
istate->repo);
514530
}
515531

516532
/*

0 commit comments

Comments
 (0)