Skip to content

Commit a643735

Browse files
committed
Merge branch 'nk/perf-fsmonitor'
Add t/perf support for fsmonitor. * nk/perf-fsmonitor: t/perf/fsmonitor: add benchmark for dirty status t/perf/fsmonitor: perf comparison of multiple fsmonitor integrations t/perf/fsmonitor: initialize test with git reset t/perf/fsmonitor: factor setup for fsmonitor into function t/perf/fsmonitor: silence initial git commit t/perf/fsmonitor: shorten DESC to basename t/perf/fsmonitor: factor description out for readability t/perf/fsmonitor: improve error message if typoing hook name t/perf/fsmonitor: move watchman setup to one-time-repo-setup t/perf/fsmonitor: separate one time repo initialization
2 parents 66c62ea + 1c6833c commit a643735

File tree

1 file changed

+63
-31
lines changed

1 file changed

+63
-31
lines changed

t/perf/p7519-fsmonitor.sh

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ test_description="Test core.fsmonitor"
2222
#
2323
# GIT_PERF_7519_UNTRACKED_CACHE: used to configure core.untrackedCache
2424
# GIT_PERF_7519_SPLIT_INDEX: used to configure core.splitIndex
25-
# GIT_PERF_7519_FSMONITOR: used to configure core.fsMonitor
25+
# GIT_PERF_7519_FSMONITOR: used to configure core.fsMonitor. May be an
26+
# absolute path to an integration. May be a space delimited list of
27+
# absolute paths to integrations.
2628
#
2729
# The big win for using fsmonitor is the elimination of the need to scan the
2830
# working directory looking for changed and untracked files. If the file
@@ -68,7 +70,7 @@ then
6870
fi
6971
fi
7072

71-
test_expect_success "setup for fsmonitor" '
73+
test_expect_success "one time repo setup" '
7274
# set untrackedCache depending on the environment
7375
if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
7476
then
@@ -88,24 +90,36 @@ test_expect_success "setup for fsmonitor" '
8890
git config core.splitIndex "$GIT_PERF_7519_SPLIT_INDEX"
8991
fi &&
9092
93+
mkdir 1_file 10_files 100_files 1000_files 10000_files &&
94+
for i in $(test_seq 1 10); do touch 10_files/$i; done &&
95+
for i in $(test_seq 1 100); do touch 100_files/$i; done &&
96+
for i in $(test_seq 1 1000); do touch 1000_files/$i; done &&
97+
for i in $(test_seq 1 10000); do touch 10000_files/$i; done &&
98+
git add 1_file 10_files 100_files 1000_files 10000_files &&
99+
git commit -qm "Add files" &&
100+
101+
# If Watchman exists, watch the work tree and attempt a query.
102+
if test_have_prereq WATCHMAN; then
103+
watchman watch "$GIT_WORK_TREE" &&
104+
watchman watch-list | grep -q -F "$GIT_WORK_TREE"
105+
fi
106+
'
107+
108+
setup_for_fsmonitor() {
91109
# set INTEGRATION_SCRIPT depending on the environment
92-
if test -n "$GIT_PERF_7519_FSMONITOR"
110+
if test -n "$INTEGRATION_PATH"
93111
then
94-
INTEGRATION_SCRIPT="$GIT_PERF_7519_FSMONITOR"
112+
INTEGRATION_SCRIPT="$INTEGRATION_PATH"
95113
else
96114
#
97115
# Choose integration script based on existence of Watchman.
98-
# If Watchman exists, watch the work tree and attempt a query.
99-
# If everything succeeds, use Watchman integration script,
100-
# else fall back to an empty integration script.
116+
# Fall back to an empty integration script.
101117
#
102118
mkdir .git/hooks &&
103119
if test_have_prereq WATCHMAN
104120
then
105121
INTEGRATION_SCRIPT=".git/hooks/fsmonitor-watchman" &&
106-
cp "$TEST_DIRECTORY/../templates/hooks--fsmonitor-watchman.sample" "$INTEGRATION_SCRIPT" &&
107-
watchman watch "$GIT_WORK_TREE" &&
108-
watchman watch-list | grep -q -F "$GIT_WORK_TREE"
122+
cp "$TEST_DIRECTORY/../templates/hooks--fsmonitor-watchman.sample" "$INTEGRATION_SCRIPT"
109123
else
110124
INTEGRATION_SCRIPT=".git/hooks/fsmonitor-empty" &&
111125
write_script "$INTEGRATION_SCRIPT"<<-\EOF
@@ -114,16 +128,10 @@ test_expect_success "setup for fsmonitor" '
114128
fi &&
115129

116130
git config core.fsmonitor "$INTEGRATION_SCRIPT" &&
117-
git update-index --fsmonitor &&
118-
mkdir 1_file 10_files 100_files 1000_files 10000_files &&
119-
for i in $(test_seq 1 10); do touch 10_files/$i; done &&
120-
for i in $(test_seq 1 100); do touch 100_files/$i; done &&
121-
for i in $(test_seq 1 1000); do touch 1000_files/$i; done &&
122-
for i in $(test_seq 1 10000); do touch 10000_files/$i; done &&
123-
git add 1_file 10_files 100_files 1000_files 10000_files &&
124-
git commit -m "Add files" &&
125-
git status # Warm caches
126-
'
131+
git update-index --fsmonitor 2>error &&
132+
cat error &&
133+
[ ! -s error ] # ensure no silent error
134+
}
127135

128136
test_perf_w_drop_caches () {
129137
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
@@ -134,48 +142,72 @@ test_perf_w_drop_caches () {
134142
}
135143

136144
test_fsmonitor_suite() {
137-
test_perf_w_drop_caches "status (fsmonitor=$INTEGRATION_SCRIPT)" '
145+
if test -n "$INTEGRATION_SCRIPT"; then
146+
DESC="fsmonitor=$(basename $INTEGRATION_SCRIPT)"
147+
else
148+
DESC="fsmonitor=disabled"
149+
fi
150+
151+
test_expect_success "test_initialization" '
152+
git reset --hard &&
153+
git status # Warm caches
154+
'
155+
156+
test_perf_w_drop_caches "status ($DESC)" '
138157
git status
139158
'
140159

141-
test_perf_w_drop_caches "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
160+
test_perf_w_drop_caches "status -uno ($DESC)" '
142161
git status -uno
143162
'
144163

145-
test_perf_w_drop_caches "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
164+
test_perf_w_drop_caches "status -uall ($DESC)" '
146165
git status -uall
147166
'
148167

149-
test_perf_w_drop_caches "diff (fsmonitor=$INTEGRATION_SCRIPT)" '
168+
test_perf_w_drop_caches "status (dirty) ($DESC)" '
169+
git ls-files | head -100000 | xargs -d "\n" touch -h &&
170+
git status
171+
'
172+
173+
test_perf_w_drop_caches "diff ($DESC)" '
150174
git diff
151175
'
152176

153-
test_perf_w_drop_caches "diff -- 0_files (fsmonitor=$INTEGRATION_SCRIPT)" '
177+
test_perf_w_drop_caches "diff -- 0_files ($DESC)" '
154178
git diff -- 1_file
155179
'
156180

157-
test_perf_w_drop_caches "diff -- 10_files (fsmonitor=$INTEGRATION_SCRIPT)" '
181+
test_perf_w_drop_caches "diff -- 10_files ($DESC)" '
158182
git diff -- 10_files
159183
'
160184

161-
test_perf_w_drop_caches "diff -- 100_files (fsmonitor=$INTEGRATION_SCRIPT)" '
185+
test_perf_w_drop_caches "diff -- 100_files ($DESC)" '
162186
git diff -- 100_files
163187
'
164188

165-
test_perf_w_drop_caches "diff -- 1000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
189+
test_perf_w_drop_caches "diff -- 1000_files ($DESC)" '
166190
git diff -- 1000_files
167191
'
168192

169-
test_perf_w_drop_caches "diff -- 10000_files (fsmonitor=$INTEGRATION_SCRIPT)" '
193+
test_perf_w_drop_caches "diff -- 10000_files ($DESC)" '
170194
git diff -- 10000_files
171195
'
172196

173-
test_perf_w_drop_caches "add (fsmonitor=$INTEGRATION_SCRIPT)" '
197+
test_perf_w_drop_caches "add ($DESC)" '
174198
git add --all
175199
'
176200
}
177201

178-
test_fsmonitor_suite
202+
if test -n "$GIT_PERF_7519_FSMONITOR"; then
203+
for INTEGRATION_PATH in $GIT_PERF_7519_FSMONITOR; do
204+
test_expect_success "setup for fsmonitor $INTEGRATION_PATH" 'setup_for_fsmonitor'
205+
test_fsmonitor_suite
206+
done
207+
else
208+
test_expect_success "setup for fsmonitor" 'setup_for_fsmonitor'
209+
test_fsmonitor_suite
210+
fi
179211

180212
test_expect_success "setup without fsmonitor" '
181213
unset INTEGRATION_SCRIPT &&

0 commit comments

Comments
 (0)