Skip to content

Commit

Permalink
Merge branch 'fscache-and-sparse-checkout'
Browse files Browse the repository at this point in the history
When updating the skip-worktree bits in the index to align with new
values in a sparse-checkout file, Git scans the entire working
directory with lstat() calls. In a sparse-checkout, many of these
lstat() calls are for paths that do not exist.

Enable the fscache feature during this scan.

In a local test of a repo with ~2.2 million paths, updating the index
with `git read-tree -m -u HEAD` with a sparse-checkout file containing
only `/.gitattributes` improved from 2-3 minutes to 15-20 seconds.

More work could be done to stop running lstat() calls when recursing
into directories that are known to not exist.
  • Loading branch information
derrickstolee authored and dscho committed Jan 7, 2025
2 parents d121dcb + 91f4f90 commit 7b6af3b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,9 @@ static void mark_new_skip_worktree(struct pattern_list *pl,
* 2. Widen worktree according to sparse-checkout file.
* Matched entries will have skip_wt_flag cleared (i.e. "in")
*/
enable_fscache(istate->cache_nr);
clear_ce_flags(istate, select_flag, skip_wt_flag, pl, show_progress);
disable_fscache();
}

static void populate_from_existing_patterns(struct unpack_trees_options *o,
Expand Down

0 comments on commit 7b6af3b

Please sign in to comment.