Skip to content

Commit 6d20654

Browse files
authored
Port "builtin/add: enable fscache around repo_read_index_preload" to vfs-2.54.0 (#902)
This is a companion of #899 and git-for-windows#6216. 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 d1778a9 + add7a58 commit 6d20654

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
@@ -500,13 +500,13 @@ int cmd_add(int argc,
500500
(!(addremove || take_worktree_changes)
501501
? ADD_CACHE_IGNORE_REMOVAL : 0));
502502

503+
enable_fscache(0);
503504
if (repo_read_index_preload(repo, &pathspec, 0) < 0)
504505
die(_("index file corrupt"));
505506

506507
die_in_unpopulated_submodule(repo->index, prefix);
507508
die_path_inside_submodule(repo->index, &pathspec);
508509

509-
enable_fscache(0);
510510
/* We do not really re-read the index but update the up-to-date flags */
511511
preload_index(repo->index, &pathspec, 0);
512512

@@ -625,6 +625,6 @@ int cmd_add(int argc,
625625
free(ps_matched);
626626
dir_clear(&dir);
627627
clear_pathspec(&pathspec);
628-
enable_fscache(0);
628+
disable_fscache();
629629
return exit_status;
630630
}

0 commit comments

Comments
 (0)