21

The Diagnosing why Git is so slow article has this interesting item in it:

Enable the filesystem cache

Windows' filesystem layer is inherently different from Linux' (for which Git's filesystem access is optimized). As a workaround, Git for Windows offers a filesystem cache which accelerates operations in many cases, after an initial "warm-up". You can activate the filesystem cache per-repository:

git config core.fscache true

If I enable this option in Git, what actually changes? What does the filesystem cache in Windows 7 look like, and what is being cached? What does the "initial warm-up" entail?

1 Answer 1

14

Here is what git config --help says:

core.fscache
Enable additional caching of file system data for some operations.

Git for Windows uses this to bulk-read and cache lstat data of entire directories (instead of doing lstat file by file).

Instead of doing many file-system requests git will do only one request to get information about all files in directory.

More technical description can be found in commit that introduced fscache:
Win32: add a cache below mingw's lstat and dirent implementations

Checking the work tree status is quite slow on Windows, due to slow lstat emulation (git calls lstat once for each file in the index). Windows operating system APIs seem to be much better at scanning the status of entire directories than checking single files.

Add an lstat implementation that uses a cache for lstat data. Cache misses read the entire parent directory and add it to the cache. Subsequent lstat calls for the same directory are served directly from the cache.

Also implement opendir / readdir / closedir so that they create and use directory listings in the cache.

The cache doesn't track file system changes and doesn't plug into any modifying file APIs, so it has to be explicitly enabled for git functions that don't modify the working copy.

3
  • 1
    Does "The cache doesn't track file system changes and doesn't plug into any modifying file APIs" mean that if you have modified your work tree (e.g. during development) git status doesn't see the change?
    – Antonio
    Commented Jun 9, 2020 at 13:52
  • 1
    @Antonio: no, since the cache only lives during a single git command invocation. So the only changes it could conceivably miss is changes that happen while you're running git status (but those are not guaranteed anyway, due to the inherent race condition). Commented May 31, 2021 at 10:00
  • thanks for the clarification!
    – Antonio
    Commented Jun 1, 2021 at 10:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .