Skip to content

Commit

Permalink
Enable the filesystem cache (fscache) in refresh_index().
Browse files Browse the repository at this point in the history
On file systems that support it, this can dramatically speed up operations
like add, commit, describe, rebase, reset, rm that would otherwise have to
lstat() every file to "re-match" the stat information in the index to that
of the file system.

On a synthetic repo with 1M files, "git reset" dropped from 52.02 seconds to
14.42 seconds for a savings of 72%.

Signed-off-by: Ben Peart <Ben.Peart@microsoft.com>
  • Loading branch information
benpeart committed Sep 7, 2018
1 parent 425f414 commit f58e6e1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions read-cache.c
Expand Up @@ -1483,6 +1483,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
enable_fscache(1);
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new_entry;
int cache_errno = 0;
Expand Down Expand Up @@ -1547,6 +1548,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,

replace_index_entry(istate, i, new_entry);
}
enable_fscache(0);
trace_performance_since(start, "refresh index");
return has_errors;
}
Expand Down

0 comments on commit f58e6e1

Please sign in to comment.