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()
This commit is contained in:
Junio C Hamano 2018-11-13 22:37:25 +09:00
commit 11aa560de9
7 changed files with 17 additions and 8 deletions

View File

@ -1363,7 +1363,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
if (status_format != STATUS_FORMAT_PORCELAIN &&
status_format != STATUS_FORMAT_PORCELAIN_V2)
progress_flag = REFRESH_PROGRESS;
read_index_preload(&the_index, &s.pathspec, progress_flag);
read_index(&the_index);
refresh_index(&the_index,
REFRESH_QUIET|REFRESH_UNMERGED|progress_flag,
&s.pathspec, NULL, NULL);

View File

@ -629,7 +629,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
struct argv_array args = ARGV_ARRAY_INIT;
int fd, result;
read_cache_preload(NULL);
read_cache();
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED,
NULL, NULL, NULL);
fd = hold_locked_index(&index_lock, 0);

View File

@ -782,7 +782,7 @@ struct refresh_params {
static int refresh(struct refresh_params *o, unsigned int flag)
{
setup_work_tree();
read_cache_preload(NULL);
read_cache();
*o->has_errors |= refresh_cache(o->flags | flag);
return 0;
}

View File

@ -661,6 +661,9 @@ extern int daemonize(void);
/* Initialize and use the cache information */
struct lock_file;
extern int read_index(struct index_state *);
extern void preload_index(struct index_state *index,
const struct pathspec *pathspec,
unsigned int refresh_flags);
extern int read_index_preload(struct index_state *,
const struct pathspec *pathspec,
unsigned int refresh_flags);

View File

@ -9,7 +9,7 @@
#include "progress.h"
#ifdef NO_PTHREADS
static void preload_index(struct index_state *index,
void preload_index(struct index_state *index,
const struct pathspec *pathspec,
unsigned int refresh_flags)
{
@ -100,7 +100,7 @@ static void *preload_thread(void *_data)
return NULL;
}
static void preload_index(struct index_state *index,
void preload_index(struct index_state *index,
const struct pathspec *pathspec,
unsigned int refresh_flags)
{

View File

@ -1496,6 +1496,12 @@ int refresh_index(struct index_state *istate, unsigned int flags,
typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
added_fmt = (in_porcelain ? "A\t%s\n" : "%s needs update\n");
unmerged_fmt = (in_porcelain ? "U\t%s\n" : "%s: needs merge\n");
/*
* Use the multi-threaded preload_index() to refresh most of the
* cache entries quickly then in the single threaded loop below,
* we only have to do the special cases that are left.
*/
preload_index(istate, pathspec, 0);
for (i = 0; i < istate->cache_nr; i++) {
struct cache_entry *ce, *new_entry;
int cache_errno = 0;

View File

@ -1969,7 +1969,7 @@ static int read_and_refresh_cache(struct replay_opts *opts)
{
struct lock_file index_lock = LOCK_INIT;
int index_fd = hold_locked_index(&index_lock, 0);
if (read_index_preload(&the_index, NULL, 0) < 0) {
if (read_index(&the_index) < 0) {
rollback_lock_file(&index_lock);
return error(_("git %s: failed to read the index"),
_(action_name(opts)));