Web lists-archives.com

Re: [PATCH v1] dir.c: don't flag the index as dirty for changes to the untracked cache

On 2/5/2018 3:55 PM, Junio C Hamano wrote:
Ben Peart <benpeart@xxxxxxxxxxxxx> writes:

The untracked cache saves its current state in the UNTR index extension.
Currently, _any_ change to that state causes the index to be flagged as dirty
and written out to disk.  Unfortunately, the cost to write out the index can
exceed the savings gained by using the untracked cache.  Since it is a cache
that can be updated from the current state of the working directory, there is
no functional requirement that the index be written out for every change to the
untracked cache.

Update the untracked cache logic so that it no longer forces the index to be
written to disk except in the case where the extension is being turned on or
off.  When some other git command requires the index to be written to disk, the
untracked cache will take advantage of that to save it's updated state as well.
This results in a performance win when looked at over common sequences of git
commands (ie such as a status followed by add, commit, etc).

After this patch, all the logic to track statistics for the untracked cache
could be removed as it is only used by debug tracing used to debug the untracked

Signed-off-by: Ben Peart <benpeart@xxxxxxxxxxxxx>

OK, so in other words (note: not a suggestion to use different
wording in the log message; just making sure I got the motivation
behind this change correctly), without this new environment
variable, changes to untracked cache alone (due to observed changes
in the filesystem) does not count as "in-core index changed so we
need to write it back to the disk".


That makes sense to me.

Is it envisioned that we want to have similar but different "testing
only" behaviour around this area?  If not, this environment variable
sounds more like "force-flush untracked cache", not "test untracked
cache", to me.

Many of the tests make a change and then verify that the on disk structure was updated correctly. This was the simplest way to keep those tests functioning. I don't imagine this would be used for anything other than enabling the tests. I hate naming so am happy to name it which ever you think is best. :)

  sync_mtime () {
  	find . -type d -ls >/dev/null

base-commit: 5be1f00a9a701532232f57958efab4be8c959a29