Skip to content

Commit 71a9dd9

Browse files
dschoGit for Windows Build Agent
authored andcommitted
add: enable FSCache around repo_read_index_preload() (#6216)
This is a companion of microsoft#899. Trace2 + GIT_TRACE_FSCACHE evidence on Windows ARM64 (Snapdragon X Elite, ReFS Dev Drive) shows that the heaviest lstat-bound work in git add happens inside repo_read_index_preload(), which currently runs before enable_fscache() is called. Moving the enable up so the preload phase is wrapped lets the existing batched NtQueryDirectoryFile cache cover the bulk of the lstat traffic. This patch gave me a ~30% performance improvement on a large git repo with a batched add. Also at the end of cmd_add(): the cleanup site called enable_fscache(0) again instead of disable_fscache(), leaking the refcount.
2 parents ea8689a + add7a58 commit 71a9dd9

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

builtin/add.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,13 @@ int cmd_add(int argc,
492492
(!(addremove || take_worktree_changes)
493493
? ADD_CACHE_IGNORE_REMOVAL : 0));
494494

495+
enable_fscache(0);
495496
if (repo_read_index_preload(repo, &pathspec, 0) < 0)
496497
die(_("index file corrupt"));
497498

498499
die_in_unpopulated_submodule(repo->index, prefix);
499500
die_path_inside_submodule(repo->index, &pathspec);
500501

501-
enable_fscache(0);
502502
/* We do not really re-read the index but update the up-to-date flags */
503503
preload_index(repo->index, &pathspec, 0);
504504

@@ -614,6 +614,6 @@ int cmd_add(int argc,
614614
free(ps_matched);
615615
dir_clear(&dir);
616616
clear_pathspec(&pathspec);
617-
enable_fscache(0);
617+
disable_fscache();
618618
return exit_status;
619619
}

0 commit comments

Comments
 (0)