This is an archive of the discontinued Mercurial Phabricator instance.

dirstate-v2: Skip readdir in status based on directory mtime
ClosedPublic

Authored by SimonSapin on Jun 1 2021, 12:50 PM.

Details

Summary

When calling read_dir during status and the directory is found to be
eligible for caching (see code comments), write the directory’s mtime to the
dirstate. The presence of a directory mtime in the dirstate is meaningful
and indicates eligibility.

When an eligible directory mtime is found in the dirstate and stat() shows
that the mtime has not changed, status can skip calling read_dir again
and instead rely on the names of child nodes in the dirstate tree.

The tempfile crate is used to create a temporary file in order to use its
modification time as "current time" with the same truncation as other files
and directories would have in their own modification time.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

SimonSapin created this revision.Jun 1 2021, 12:50 PM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.
baymax updated this revision to Diff 28384.Jun 1 2021, 5:05 PM

✅ refresh by Heptapod after a successful CI run (🐙 💚)

Alphare added a subscriber: Alphare.Jun 2 2021, 4:08 AM

I have mostly feeback on form, here for posterity and for your follow-up patches.

rust/hg-core/src/dirstate_tree/status.rs
158

I would point to the ambiguity resolution due to insufficient granularity in this comment so that we don't get the impression that this is naive too fast.

372

I find an early return (for the true case) would be easier to read since it would lead to less indentation.

680

This should probably log::debug that it failed to write a tempfile?