Skip to content

status: base the "results were cached" remark on the untracked cache - #2345

Open
blanet wants to merge 1 commit into
gitgitgadget:masterfrom
blanet:xx/status-untracked-cache-advice
Open

blanet wants to merge 1 commit into
gitgitgadget:masterfrom
blanet:xx/status-untracked-cache-advice

Conversation

@blanet

@blanet blanet commented Dec 1, 2026

Copy link
Copy Markdown

No description provided.

Since ecbc23e (status: modernize git-status "slow untracked files"
advice, 2022-11-30), the advice that "git status" gives when
enumerating untracked files takes more than 2 seconds adds "but the
results were cached, and subsequent runs may be faster" whenever
core.fsmonitor is enabled. But it is the untracked cache that caches
these results, with or without fsmonitor:

 - Without the untracked cache, which is off by default, every run
   enumerates all untracked files again, however fsmonitor is
   configured, and the promised speedup never comes.

 - With it, subsequent runs only read the directories that changed,
   which they find by checking the stat data of all directories, or,
   with fsmonitor, by asking it.

In the Linux kernel repository, on an Apple M4 Pro, enumerating the
untracked files takes 305ms when the untracked cache is created, then
17ms with the untracked cache alone, 9ms with fsmonitor as well, and
still 313ms with fsmonitor alone.

The documentation that ecbc23e added says as much: "While the
FSMonitor feature can be enabled without the untracked cache, the
benefits are greatly reduced in that case." But the code checks only
core.fsmonitor.

Give the remark when the untracked cache was used to enumerate the
untracked files, whether fsmonitor is enabled or not. Checking
core.untrackedCache instead would not be accurate either: the
untracked cache is enabled but not used with "--ignored" or a
pathspec, and with core.untrackedCache set to "keep", its default,
the untracked cache is used if the index already has one. So record
in struct wt_status whether dir.untracked is set after
fill_directory(), as read_directory() resets it when it cannot use
the untracked cache.

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>
@blanet
blanet force-pushed the xx/status-untracked-cache-advice branch from 7deabb9 to bf68ee0 Compare December 1, 2026 07:18
@blanet

blanet commented Dec 1, 2026

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Dec 1, 2026

Copy link
Copy Markdown

Submitted as pull.2345.git.1796112069353.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2345/blanet/xx/status-untracked-cache-advice-v1

To fetch this version to local tag pr-2345/blanet/xx/status-untracked-cache-advice-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2345/blanet/xx/status-untracked-cache-advice-v1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant