summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorUtsav Shah <utsav@dropbox.com>2019-11-20 08:32:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-21 03:48:18 (GMT)
commit679f2f9fdd2173d87251aee357dd0e46ce977f42 (patch)
treeaba26ef4deb496411e0deda85828b5ff3a3f39bd /unpack-trees.c
parent61eea521fef11c6878a4157bcc0fca6e981a58b2 (diff)
downloadgit-679f2f9fdd2173d87251aee357dd0e46ce977f42.zip
git-679f2f9fdd2173d87251aee357dd0e46ce977f42.tar.gz
git-679f2f9fdd2173d87251aee357dd0e46ce977f42.tar.bz2
unpack-trees: skip stat on fsmonitor-valid files
The index might be aware that a file hasn't modified via fsmonitor, but unpack-trees did not pay attention to it and checked via ie_match_stat which can be inefficient on certain filesystems. This significantly slows down commands that run oneway_merge, like checkout and reset --hard. This patch makes oneway_merge check whether a file is considered unchanged through fsmonitor and skips ie_match_stat on it. unpack-trees also now correctly copies over fsmonitor validity state from the source index. Finally, for correctness, we force a refresh of fsmonitor state in tweak_fsmonitor. After this change, commands like stash (that use reset --hard internally) go from 8s or more to ~2s on a 250k file repository on a mac. Helped-by: Junio C Hamano <gitster@pobox.com> Helped-by: Kevin Willford <Kevin.Willford@microsoft.com> Signed-off-by: Utsav Shah <utsav@dropbox.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 62276d4..35313d1 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1494,6 +1494,9 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
o->merge_size = len;
mark_all_ce_unused(o->src_index);
+ if (o->src_index->fsmonitor_last_update)
+ o->result.fsmonitor_last_update = o->src_index->fsmonitor_last_update;
+
/*
* Sparse checkout loop #1: set NEW_SKIP_WORKTREE on existing entries
*/
@@ -2374,7 +2377,8 @@ int oneway_merge(const struct cache_entry * const *src,
if (old && same(old, a)) {
int update = 0;
- if (o->reset && o->update && !ce_uptodate(old) && !ce_skip_worktree(old)) {
+ if (o->reset && o->update && !ce_uptodate(old) && !ce_skip_worktree(old) &&
+ !(old->ce_flags & CE_FSMONITOR_VALID)) {
struct stat st;
if (lstat(old->name, &st) ||
ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE))