Skip to content

Commit 53996fe

Browse files
torvaldsgitster
authored andcommitted
Teach 'git checkout' to preload the index contents
This makes git checkout know to use the threaded index preloading if it is enabled in the config file. You need to have [core] preloadindex = true in your config file to see it, and for that feature to make sense your filesystem needs to be able to do concurrent 'lstat()' lookups, but when that is the case (especially NFS over a high-latency network), this can be a noticeable performance win. But with a low-latency network and at least older Linux NFS clients, this will clearly potentially cause a lot of lock contention. It may still speed up the uncached case, but the threading and locking overhead will result in the cached case likely slowing down. That was almost certainly fixed by Linux commit fc0f684 ("NFS: Remove BKL from NFS lookup code"), but that one got merged into 2.6.27-rc1, so older kernel versions than 2.6.27 will not scale very well. But regardless, it's the right thing to do. If your filesystem doesn't scale, don't enable index preloading. Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 658dd48 commit 53996fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin-checkout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,
228228
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
229229

230230
newfd = hold_locked_index(lock_file, 1);
231-
if (read_cache() < 0)
231+
if (read_cache_preload(pathspec) < 0)
232232
return error("corrupt index file");
233233

234234
if (source_tree)
@@ -373,7 +373,7 @@ static int merge_working_tree(struct checkout_opts *opts,
373373
struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
374374
int newfd = hold_locked_index(lock_file, 1);
375375

376-
if (read_cache() < 0)
376+
if (read_cache_preload(NULL) < 0)
377377
return error("corrupt index file");
378378

379379
if (opts->force) {

0 commit comments

Comments
 (0)