Skip to content

Commit 15268d1

Browse files
jeffhostetlergitster
authored andcommitted
read-cache: log the number of scanned files to trace2
Report the number of files in the working directory that were read and their hashes verified in `refresh_index()`. FSMonitor improves the performance of commands like `git status` by avoiding scanning the disk for changed files. Let's measure this. Signed-off-by: Jeff Hostetler <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a98e0f2 commit 15268d1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

read-cache.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
13651365
struct cache_entry *ce,
13661366
unsigned int options, int *err,
13671367
int *changed_ret,
1368-
int *t2_did_lstat)
1368+
int *t2_did_lstat,
1369+
int *t2_did_scan)
13691370
{
13701371
struct stat st;
13711372
struct cache_entry *updated;
@@ -1445,6 +1446,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
14451446
}
14461447
}
14471448

1449+
if (t2_did_scan)
1450+
*t2_did_scan = 1;
14481451
if (ie_modified(istate, ce, &st, options)) {
14491452
if (err)
14501453
*err = EINVAL;
@@ -1523,6 +1526,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
15231526
const char *unmerged_fmt;
15241527
struct progress *progress = NULL;
15251528
int t2_sum_lstat = 0;
1529+
int t2_sum_scan = 0;
15261530

15271531
if (flags & REFRESH_PROGRESS && isatty(2))
15281532
progress = start_delayed_progress(_("Refresh index"),
@@ -1547,6 +1551,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
15471551
int changed = 0;
15481552
int filtered = 0;
15491553
int t2_did_lstat = 0;
1554+
int t2_did_scan = 0;
15501555

15511556
ce = istate->cache[i];
15521557
if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
@@ -1574,8 +1579,9 @@ int refresh_index(struct index_state *istate, unsigned int flags,
15741579

15751580
new_entry = refresh_cache_ent(istate, ce, options,
15761581
&cache_errno, &changed,
1577-
&t2_did_lstat);
1582+
&t2_did_lstat, &t2_did_scan);
15781583
t2_sum_lstat += t2_did_lstat;
1584+
t2_sum_scan += t2_did_scan;
15791585
if (new_entry == ce)
15801586
continue;
15811587
if (progress)
@@ -1612,6 +1618,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
16121618
replace_index_entry(istate, i, new_entry);
16131619
}
16141620
trace2_data_intmax("index", NULL, "refresh/sum_lstat", t2_sum_lstat);
1621+
trace2_data_intmax("index", NULL, "refresh/sum_scan", t2_sum_scan);
16151622
trace2_region_leave("index", "refresh", NULL);
16161623
if (progress) {
16171624
display_progress(progress, istate->cache_nr);
@@ -1625,7 +1632,7 @@ struct cache_entry *refresh_cache_entry(struct index_state *istate,
16251632
struct cache_entry *ce,
16261633
unsigned int options)
16271634
{
1628-
return refresh_cache_ent(istate, ce, options, NULL, NULL, NULL);
1635+
return refresh_cache_ent(istate, ce, options, NULL, NULL, NULL, NULL);
16291636
}
16301637

16311638

0 commit comments

Comments
 (0)