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:
Junio C Hamano
2018-09-17 13:53:53 -07:00
12 changed files with 344 additions and 22 deletions

9
dir.c
View File

@ -2268,10 +2268,13 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
const char *path, int len, const struct pathspec *pathspec)
{
struct untracked_cache_dir *untracked;
uint64_t start = getnanotime();
if (has_symlink_leading_path(path, len))
trace_performance_enter();
if (has_symlink_leading_path(path, len)) {
trace_performance_leave("read directory %.*s", len, path);
return dir->nr;
}
untracked = validate_untracked_cache(dir, len, pathspec);
if (!untracked)
@ -2307,7 +2310,7 @@ int read_directory(struct dir_struct *dir, struct index_state *istate,
dir->nr = i;
}
trace_performance_since(start, "read directory %.*s", len, path);
trace_performance_leave("read directory %.*s", len, path);
if (dir->untracked) {
static int force_untracked_cache = -1;
static struct trace_key trace_untracked_stats = TRACE_KEY_INIT(UNTRACKED_STATS);