Skip to content

Commit 11aa560

Browse files
committed
Merge branch 'bp/refresh-index-using-preload'
The helper function to refresh the cached stat information in the in-core index has learned to perform the lstat() part of the operation in parallel on multi-core platforms. * bp/refresh-index-using-preload: refresh_index: remove unnecessary calls to preload_index() speed up refresh_index() by utilizing preload_index()
2 parents 409b3f2 + 6c5b7f5 commit 11aa560

File tree

7 files changed

+17
-8
lines changed

7 files changed

+17
-8
lines changed

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13631363
if (status_format != STATUS_FORMAT_PORCELAIN &&
13641364
status_format != STATUS_FORMAT_PORCELAIN_V2)
13651365
progress_flag = REFRESH_PROGRESS;
1366-
read_index_preload(&the_index, &s.pathspec, progress_flag);
1366+
read_index(&the_index);
13671367
refresh_index(&the_index,
13681368
REFRESH_QUIET|REFRESH_UNMERGED|progress_flag,
13691369
&s.pathspec, NULL, NULL);

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
629629
struct argv_array args = ARGV_ARRAY_INIT;
630630
int fd, result;
631631

632-
read_cache_preload(NULL);
632+
read_cache();
633633
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
634634
NULL, NULL, NULL);
635635
fd = hold_locked_index(&index_lock, 0);

builtin/update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ struct refresh_params {
782782
static int refresh(struct refresh_params *o, unsigned int flag)
783783
{
784784
setup_work_tree();
785-
read_cache_preload(NULL);
785+
read_cache();
786786
*o->has_errors |= refresh_cache(o->flags | flag);
787787
return 0;
788788
}

cache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,9 @@ extern int daemonize(void);
661661
/* Initialize and use the cache information */
662662
struct lock_file;
663663
extern int read_index(struct index_state *);
664+
extern void preload_index(struct index_state *index,
665+
const struct pathspec *pathspec,
666+
unsigned int refresh_flags);
664667
extern int read_index_preload(struct index_state *,
665668
const struct pathspec *pathspec,
666669
unsigned int refresh_flags);

preload-index.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "progress.h"
1010

1111
#ifdef NO_PTHREADS
12-
static void preload_index(struct index_state *index,
12+
void preload_index(struct index_state *index,
1313
const struct pathspec *pathspec,
1414
unsigned int refresh_flags)
1515
{
@@ -100,9 +100,9 @@ static void *preload_thread(void *_data)
100100
return NULL;
101101
}
102102

103-
static void preload_index(struct index_state *index,
104-
const struct pathspec *pathspec,
105-
unsigned int refresh_flags)
103+
void preload_index(struct index_state *index,
104+
const struct pathspec *pathspec,
105+
unsigned int refresh_flags)
106106
{
107107
int threads, i, work, offset;
108108
struct thread_data data[MAX_PARALLEL];

read-cache.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,12 @@ int refresh_index(struct index_state *istate, unsigned int flags,
14961496
typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
14971497
added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
14981498
unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
1499+
/*
1500+
* Use the multi-threaded preload_index() to refresh most of the
1501+
* cache entries quickly then in the single threaded loop below,
1502+
* we only have to do the special cases that are left.
1503+
*/
1504+
preload_index(istate, pathspec, 0);
14991505
for (i = 0; i < istate->cache_nr; i++) {
15001506
struct cache_entry *ce, *new_entry;
15011507
int cache_errno = 0;

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ static int read_and_refresh_cache(struct replay_opts *opts)
19691969
{
19701970
struct lock_file index_lock = LOCK_INIT;
19711971
int index_fd = hold_locked_index(&index_lock, 0);
1972-
if (read_index_preload(&the_index, NULL, 0) < 0) {
1972+
if (read_index(&the_index) < 0) {
19731973
rollback_lock_file(&index_lock);
19741974
return error(_("git %s: failed to read the index"),
19751975
_(action_name(opts)));

0 commit comments

Comments
 (0)