diff options
author | Victoria Dye <vdye@github.com> | 2022-11-10 20:06:02 +0100 |
---|---|---|
committer | Taylor Blau <me@ttaylorr.com> | 2022-11-11 03:49:34 +0100 |
commit | 68fcd48bafa1ef51b1ba40a41cb0fcdbad7acce1 (patch) | |
tree | af43307d536f90cb9d7738b003d2328424cc6841 /unpack-trees.c | |
parent | cache-tree: add perf test comparing update and prime (diff) | |
download | git-68fcd48bafa1ef51b1ba40a41cb0fcdbad7acce1.tar.xz git-68fcd48bafa1ef51b1ba40a41cb0fcdbad7acce1.zip |
unpack-trees: add 'skip_cache_tree_update' option
Add (disabled by default) option to skip the 'cache_tree_update()' at the
end of 'unpack_trees()'. In many cases, this cache tree update is redundant
because the caller of 'unpack_trees()' immediately follows it with
'prime_cache_tree()', rebuilding the entire cache tree from scratch. While
these operations aren't the most expensive part of operations like 'git
reset', the duplicate calls still create a minor unnecessary slowdown.
Introduce an option for callers to skip the 'cache_tree_update()' in
'unpack_trees()' if it is redundant (that is, if 'prime_cache_tree()' is
called afterwards). At the moment, no 'unpack_trees()' callers use the new
option; they will be updated in subsequent patches.
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index bae812156c..8a762aa077 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -2043,7 +2043,8 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options if (!ret) { if (git_env_bool("GIT_TEST_CHECK_CACHE_TREE", 0)) cache_tree_verify(the_repository, &o->result); - if (!cache_tree_fully_valid(o->result.cache_tree)) + if (!o->skip_cache_tree_update && + !cache_tree_fully_valid(o->result.cache_tree)) cache_tree_update(&o->result, WRITE_TREE_SILENT | WRITE_TREE_REPAIR); |