Merge branch 'nd/unpack-trees-with-cache-tree'
The unpack_trees() API used in checking out a branch and merging walks one or more trees along with the index. When the cache-tree in the index tells us that we are walking a tree whose flattened contents is known (i.e. matches a span in the index), as linearly scanning a span in the index is much more efficient than having to open tree objects recursively and listing their entries, the walk can be optimized, which is done in this topic. * nd/unpack-trees-with-cache-tree: Document update for nd/unpack-trees-with-cache-tree cache-tree: verify valid cache-tree in the test suite unpack-trees: add missing cache invalidation unpack-trees: reuse (still valid) cache-tree from src_index unpack-trees: reduce malloc in cache-tree walk unpack-trees: optimize walking same trees with cache-tree unpack-trees: add performance tracing trace.h: support nested performance tracing
This commit is contained in:
16
read-cache.c
16
read-cache.c
@ -1476,8 +1476,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
|
||||
const char *typechange_fmt;
|
||||
const char *added_fmt;
|
||||
const char *unmerged_fmt;
|
||||
uint64_t start = getnanotime();
|
||||
|
||||
trace_performance_enter();
|
||||
modified_fmt = (in_porcelain ? "M\t%s\n" : "%s: needs update\n");
|
||||
deleted_fmt = (in_porcelain ? "D\t%s\n" : "%s: needs update\n");
|
||||
typechange_fmt = (in_porcelain ? "T\t%s\n" : "%s needs update\n");
|
||||
@ -1547,7 +1547,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
|
||||
|
||||
replace_index_entry(istate, i, new_entry);
|
||||
}
|
||||
trace_performance_since(start, "refresh index");
|
||||
trace_performance_leave("refresh index");
|
||||
return has_errors;
|
||||
}
|
||||
|
||||
@ -2002,7 +2002,6 @@ static void freshen_shared_index(const char *shared_index, int warn)
|
||||
int read_index_from(struct index_state *istate, const char *path,
|
||||
const char *gitdir)
|
||||
{
|
||||
uint64_t start = getnanotime();
|
||||
struct split_index *split_index;
|
||||
int ret;
|
||||
char *base_oid_hex;
|
||||
@ -2012,8 +2011,9 @@ int read_index_from(struct index_state *istate, const char *path,
|
||||
if (istate->initialized)
|
||||
return istate->cache_nr;
|
||||
|
||||
trace_performance_enter();
|
||||
ret = do_read_index(istate, path, 0);
|
||||
trace_performance_since(start, "read cache %s", path);
|
||||
trace_performance_leave("read cache %s", path);
|
||||
|
||||
split_index = istate->split_index;
|
||||
if (!split_index || is_null_oid(&split_index->base_oid)) {
|
||||
@ -2021,6 +2021,7 @@ int read_index_from(struct index_state *istate, const char *path,
|
||||
return ret;
|
||||
}
|
||||
|
||||
trace_performance_enter();
|
||||
if (split_index->base)
|
||||
discard_index(split_index->base);
|
||||
else
|
||||
@ -2037,8 +2038,8 @@ int read_index_from(struct index_state *istate, const char *path,
|
||||
freshen_shared_index(base_path, 0);
|
||||
merge_base_index(istate);
|
||||
post_read_index_from(istate);
|
||||
trace_performance_since(start, "read cache %s", base_path);
|
||||
free(base_path);
|
||||
trace_performance_leave("read cache %s", base_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2743,6 +2744,9 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,
|
||||
int new_shared_index, ret;
|
||||
struct split_index *si = istate->split_index;
|
||||
|
||||
if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0))
|
||||
cache_tree_verify(istate);
|
||||
|
||||
if ((flags & SKIP_IF_UNCHANGED) && !istate->cache_changed) {
|
||||
if (flags & COMMIT_LOCK)
|
||||
rollback_lock_file(lock);
|
||||
@ -2939,6 +2943,8 @@ void move_index_extensions(struct index_state *dst, struct index_state *src)
|
||||
{
|
||||
dst->untracked = src->untracked;
|
||||
src->untracked = NULL;
|
||||
dst->cache_tree = src->cache_tree;
|
||||
src->cache_tree = NULL;
|
||||
}
|
||||
|
||||
struct cache_entry *dup_cache_entry(const struct cache_entry *ce,
|
||||
|
Reference in New Issue
Block a user