git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 00/20] Untracked cache to speed up "git status"

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
May 7, 2014, 14:51 UTC
Message-ID
<1399474320-6840-1-git-send-email-pclouds@gmail.com>

First of all, thanks for pointing to many more big repos. I'll look at them tomorrow. End-of-day report (or ranting :D) time.

The series now looks good enough for public eyes. I haven't run the test suite with untracked cache on by default so confidence level is not so high. Although I suspect racy timestamp issue will practically disable the cache anyway.

The idea is as before, exploit directory mtime to cache untracked files. MSDN tells me NTFS on Windows exposes the "good" dir mtime behavior, which means this series could speed up Git on Windows (I think Karsten fscache only deals with slow lstat, untracked files..).

It would be nice if Windows people could try and confirm this. This could be a good point for untracked cache vs watchman (no windows support, last time I checked). Usage is very simple, "git update-index --untracked-cache" and you're ready. Do --no-untracked-cache to revert back.

The peformance numbers on webkit look good. If we focus on read_directory time only. Normally it takes 890ms. The first run with untracked cache goes up to 922ms (filling up the cache, not counting index write time). The next run goes down to 184ms (best case). The gain is about 80%. lstat costs on directories only about 20ms out of that 184ms, so I still need to see if I can lower that number further down.

"git status" performance gain is less impressive of course. Only about 38% with refresh time now becomes the top offender. With core.preloadindex on, the gain increases to 50%. There's still room for improvement to maybe make it to 65% by reducing read time, I think.

But again we may not stay in the best case forever. The more dirs are damaged, the slower it gets. At the end of the spectrum, all dirs are damanged, we gain nothing but overhead. This is actually when watchman shines, although projects that do that may need some improvements.

Another bad point for untracked cache is, the extension data is so specifiec to core git algorithm that it probably cannot be reused by other implementations. Again, watchman shines here.

Last note, this series conflicts with split-index due to the write_cache API change, so not a candidate for 'pu' yet. The series could also be fetched from

https://github.com/pclouds/git/commits/untracked-cache
except the last few timing/experimental patches.
Nguyễn Thái Ngọc Duy (20):
  dir.c: coding style fix
  dir.h: move struct exclude declaration to top level
  prep_exclude: remove the artificial PATH_MAX limit
  dir.c: optionally compute sha-1 of a .gitignore file
  untracked cache: record .gitignore information and dir hierarchy
  untracked cache: initial untracked cache validation
  untracked cache: invalidate dirs recursively if .gitignore changes
  untracked cache: record/validate dir mtime and reuse cached output
  untracked cache: mark what dirs should be recursed/saved
  untracked cache: don't open non-existent .gitignore
  untracked cache: save to an index extension
  untracked cache: load from UNTR index extension
  untracked cache: invalidate at index addition or removal
  untracked cache: print untracked statistics with $GIT_TRACE_UNTRACKED
  read-cache.c: split racy stat test to a separate function
  untracked cache: avoid racy timestamps
  status: support untracked cache
  update-index: manually enable or disable untracked cache
  update-index: test the system before enabling untracked cache
  t7063: tests for untracked cache
 .gitignore                                 |   1 +
 Makefile                                   |   1 +
 builtin/commit.c                           |   8 +
 builtin/update-index.c                     | 161 ++++++
 cache.h                                    |   5 +
 dir.c                                      | 853 +++++++++++++++++++++++++++--
 dir.h                                      | 120 +++-
 read-cache.c                               |  51 +-
 t/t7063-status-untracked-cache.sh (new +x) | 352 ++++++++++++
 test-dump-untracked-cache.c (new)          |  61 +++
 unpack-trees.c                             |   7 +-
 wt-status.c                                |   6 +
 12 files changed, 1537 insertions(+), 89 deletions(-)
 create mode 100755 t/t7063-status-untracked-cache.sh
 create mode 100644 test-dump-untracked-cache.c
-- 
1.9.1.346.ga2b5940
Next: Nguyễn Thái Ngọc Duy
Message 1 of 21 in “Untracked cache to speed up "git status"”
  1. 00/20 Untracked cache to speed up "git status"Nguyễn Thái Ngọc Duy, May 7, 2014
  2. 01/20 dir.c: coding style fixNguyễn Thái Ngọc Duy, May 7, 2014
  3. 02/20 dir.h: move struct exclude declaration to top levelNguyễn Thái Ngọc Duy, May 7, 2014
  4. 03/20 prep_exclude: remove the artificial PATH_MAX limitNguyễn Thái Ngọc Duy, May 7, 2014
  5. 04/20 dir.c: optionally compute sha-1 of a .gitignore fileNguyễn Thái Ngọc Duy, May 7, 2014
  6. 05/20 untracked cache: record .gitignore information and dir hierarchyNguyễn Thái Ngọc Duy, May 7, 2014
  7. 06/20 untracked cache: initial untracked cache validationNguyễn Thái Ngọc Duy, May 7, 2014
  8. 07/20 untracked cache: invalidate dirs recursively if .gitignore changesNguyễn Thái Ngọc Duy, May 7, 2014
  9. 08/20 untracked cache: record/validate dir mtime and reuse cached outputNguyễn Thái Ngọc Duy, May 7, 2014
  10. 09/20 untracked cache: mark what dirs should be recursed/savedNguyễn Thái Ngọc Duy, May 7, 2014
  11. 10/20 untracked cache: don't open non-existent .gitignoreNguyễn Thái Ngọc Duy, May 7, 2014
  12. 11/20 untracked cache: save to an index extensionNguyễn Thái Ngọc Duy, May 7, 2014
  13. 12/20 untracked cache: load from UNTR index extensionNguyễn Thái Ngọc Duy, May 7, 2014
  14. 13/20 untracked cache: invalidate at index addition or removalNguyễn Thái Ngọc Duy, May 7, 2014
  15. 14/20 untracked cache: print untracked statistics with $GIT_TRACE_UNTRACKEDNguyễn Thái Ngọc Duy, May 7, 2014
  16. 15/20 read-cache.c: split racy stat test to a separate functionNguyễn Thái Ngọc Duy, May 7, 2014
  17. 16/20 untracked cache: avoid racy timestampsNguyễn Thái Ngọc Duy, May 7, 2014
  18. 17/20 status: support untracked cacheNguyễn Thái Ngọc Duy, May 7, 2014
  19. 18/20 update-index: manually enable or disable untracked cacheNguyễn Thái Ngọc Duy, May 7, 2014
  20. 19/20 update-index: test the system before enabling untracked cacheNguyễn Thái Ngọc Duy, May 7, 2014
  21. 20/20 t7063: tests for untracked cacheNguyễn Thái Ngọc Duy, May 7, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.