Skip to content

Commit 38df35b

Browse files
committed
add: use preload-index and fscache for performance
Teach "add" to use preload-index and fscache features to improve performance on very large repositories. During an "add", a call is made to run_diff_files() which calls check_remove() for each index-entry. This calls lstat(). On Windows, the fscache code intercepts the lstat() calls and builds a private cache using the FindFirst/FindNext routines, which are much faster. Somewhat independent of this, is the preload-index code which distributes some of the start-up costs across multiple threads. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 6619f79 commit 38df35b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

builtin/add.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
376376
return 0;
377377
}
378378

379-
if (read_cache() < 0)
380-
die(_("index file corrupt"));
381-
382379
/*
383380
* Check the "pathspec '%s' did not match any files" block
384381
* below before enabling new magic.
@@ -389,6 +386,10 @@ int cmd_add(int argc, const char **argv, const char *prefix)
389386
PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE,
390387
prefix, argv);
391388

389+
enable_fscache(1);
390+
if (read_cache_preload(&pathspec) < 0)
391+
die(_("index file corrupt"));
392+
392393
if (add_new_files) {
393394
int baselen;
394395

0 commit comments

Comments
 (0)