Skip to content

Commit 110b1db

Browse files
derrickstoleedscho
authored andcommitted
unpack-trees: enable fscache for sparse-checkout
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. Since enable_fscache() calls nest, the disable_fscache() method decrements a counter and would only clear the cache if that counter reaches zero. 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 ~6 seconds. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f29f562 commit 110b1db

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

unpack-trees.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,9 @@ static void mark_new_skip_worktree(struct pattern_list *pl,
18001800
* 2. Widen worktree according to sparse-checkout file.
18011801
* Matched entries will have skip_wt_flag cleared (i.e. "in")
18021802
*/
1803+
enable_fscache(istate->cache_nr);
18031804
clear_ce_flags(istate, select_flag, skip_wt_flag, pl, show_progress);
1805+
disable_fscache();
18041806
}
18051807

18061808
static void populate_from_existing_patterns(struct unpack_trees_options *o,

0 commit comments

Comments
 (0)