Skip to content

Commit 8c4b750

Browse files
jeffhostetlergitster
authored andcommitted
preload-index: log the number of lstat calls to trace2
Report the total number of calls made to lstat() inside preload_index(). FSMonitor improves the performance of commands like `git status` by avoiding scanning the disk for changed files. This can be seen in `preload_index()`. 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 4f2009d commit 8c4b750

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

preload-index.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct thread_data {
3131
struct pathspec pathspec;
3232
struct progress_data *progress;
3333
int offset, nr;
34+
int t2_nr_lstat;
3435
};
3536

3637
static void *preload_thread(void *_data)
@@ -73,6 +74,7 @@ static void *preload_thread(void *_data)
7374
continue;
7475
if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce)))
7576
continue;
77+
p->t2_nr_lstat++;
7678
if (lstat(ce->name, &st))
7779
continue;
7880
if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY|CE_MATCH_IGNORE_FSMONITOR))
@@ -98,6 +100,7 @@ void preload_index(struct index_state *index,
98100
int threads, i, work, offset;
99101
struct thread_data data[MAX_PARALLEL];
100102
struct progress_data pd;
103+
int t2_sum_lstat = 0;
101104

102105
if (!HAVE_THREADS || !core_preload_index)
103106
return;
@@ -107,6 +110,9 @@ void preload_index(struct index_state *index,
107110
threads = 2;
108111
if (threads < 2)
109112
return;
113+
114+
trace2_region_enter("index", "preload", NULL);
115+
110116
trace_performance_enter();
111117
if (threads > MAX_PARALLEL)
112118
threads = MAX_PARALLEL;
@@ -141,10 +147,14 @@ void preload_index(struct index_state *index,
141147
struct thread_data *p = data+i;
142148
if (pthread_join(p->pthread, NULL))
143149
die("unable to join threaded lstat");
150+
t2_sum_lstat += p->t2_nr_lstat;
144151
}
145152
stop_progress(&pd.progress);
146153

147154
trace_performance_leave("preload index");
155+
156+
trace2_data_intmax("index", NULL, "preload/sum_lstat", t2_sum_lstat);
157+
trace2_region_leave("index", "preload", NULL);
148158
}
149159

150160
int repo_read_index_preload(struct repository *repo,

0 commit comments

Comments
 (0)