setup: fix leaking repository format
[alt-git.git] / t / perf / p7527-builtin-fsmonitor.sh
blobc3f9a4caa4caadca271982c2e9f872d977c3610b
1 #!/bin/sh
3 test_description="Perf test for the builtin FSMonitor"
5 . ./perf-lib.sh
7 if ! test_have_prereq FSMONITOR_DAEMON
8 then
9 skip_all="fsmonitor--daemon is not supported on this platform"
10 test_done
13 test_lazy_prereq UNTRACKED_CACHE '
14 { git update-index --test-untracked-cache; ret=$?; } &&
15 test $ret -ne 1
18 # Lie to perf-lib and ask for a new empty repo and avoid
19 # the complaints about GIT_PERF_REPO not being big enough
20 # the perf hit when GIT_PERF_LARGE_REPO is copied into
21 # the trash directory.
23 # NEEDSWORK: It would be nice if perf-lib had an option to
24 # "borrow" an existing large repo (especially for gigantic
25 # monorepos) and use it in-place. For now, fake it here.
27 test_perf_fresh_repo
30 # Use a generated synthetic monorepo. If it doesn't exist, we will
31 # generate it. If it does exist, we will put it in a known state
32 # before we start our timings.
34 PARAM_D=5
35 PARAM_W=10
36 PARAM_F=9
38 PARAMS="$PARAM_D"."$PARAM_W"."$PARAM_F"
40 BALLAST_BR=p0006-ballast
41 export BALLAST_BR
43 TMP_BR=tmp_br
44 export TMP_BR
46 REPO=../repos/gen-many-files-"$PARAMS".git
47 export REPO
49 if ! test -d $REPO
50 then
51 (cd ../repos; ./many-files.sh -d $PARAM_D -w $PARAM_W -f $PARAM_F)
55 enable_uc () {
56 git -C $REPO config core.untrackedcache true
57 git -C $REPO update-index --untracked-cache
58 git -C $REPO status >/dev/null 2>&1
61 disable_uc () {
62 git -C $REPO config core.untrackedcache false
63 git -C $REPO update-index --no-untracked-cache
64 git -C $REPO status >/dev/null 2>&1
67 start_fsm () {
68 git -C $REPO fsmonitor--daemon start
69 git -C $REPO fsmonitor--daemon status
70 git -C $REPO config core.fsmonitor true
71 git -C $REPO update-index --fsmonitor
72 git -C $REPO status >/dev/null 2>&1
75 stop_fsm () {
76 git -C $REPO config --unset core.fsmonitor
77 git -C $REPO update-index --no-fsmonitor
78 test_might_fail git -C $REPO fsmonitor--daemon stop 2>/dev/null
79 git -C $REPO status >/dev/null 2>&1
83 # Ensure that FSMonitor is turned off on the borrowed repo.
85 test_expect_success "Setup borrowed repo (fsm+uc)" "
86 stop_fsm &&
87 disable_uc
90 # Also ensure that it starts in a known state.
92 # Because we assume that $GIT_PERF_REPEAT_COUNT > 1, we are not going to time
93 # the ballast checkout, since only the first invocation does any work and the
94 # subsequent ones just print "already on branch" and quit, so the reported
95 # time is not useful.
97 # Create a temp branch and do all work relative to it so that we don't
98 # accidentially alter the real ballast branch.
100 test_expect_success "Setup borrowed repo (temp ballast branch)" "
101 test_might_fail git -C $REPO checkout $BALLAST_BR &&
102 test_might_fail git -C $REPO reset --hard &&
103 git -C $REPO clean -d -f &&
104 test_might_fail git -C $REPO branch -D $TMP_BR &&
105 git -C $REPO branch $TMP_BR $BALLAST_BR &&
106 git -C $REPO checkout $TMP_BR
110 echo Data >data.txt
112 # NEEDSWORK: We assume that $GIT_PERF_REPEAT_COUNT > 1. With
113 # FSMonitor enabled, we can get a skewed view of status times, since
114 # the index MAY (or may not) be updated after the first invocation
115 # which will update the FSMonitor Token, so the subsequent invocations
116 # may get a smaller response from the daemon.
118 do_status () {
119 msg=$1
121 test_perf "$msg" "
122 git -C $REPO status >/dev/null 2>&1
126 do_matrix () {
127 uc=$1
128 fsm=$2
130 t="[uc $uc][fsm $fsm]"
131 MATRIX_BR="$TMP_BR-$uc-$fsm"
133 test_expect_success "$t Setup matrix branch" "
134 git -C $REPO clean -d -f &&
135 git -C $REPO checkout $TMP_BR &&
136 test_might_fail git -C $REPO branch -D $MATRIX_BR &&
137 git -C $REPO branch $MATRIX_BR $TMP_BR &&
138 git -C $REPO checkout $MATRIX_BR
141 if test $uc = true
142 then
143 enable_uc
144 else
145 disable_uc
148 if test $fsm = true
149 then
150 start_fsm
151 else
152 stop_fsm
155 do_status "$t status after checkout"
157 # Modify many files in the matrix branch.
158 # Stage them.
159 # Commit them.
160 # Rollback.
162 test_expect_success "$t modify tracked files" "
163 find $REPO -name file1 -exec cp data.txt {} \\;
166 do_status "$t status after big change"
168 # Don't bother timing the "add" because _REPEAT_COUNT
169 # issue described above.
171 test_expect_success "$t add all" "
172 git -C $REPO add -A
175 do_status "$t status after add all"
177 test_expect_success "$t add dot" "
178 git -C $REPO add .
181 do_status "$t status after add dot"
183 test_expect_success "$t commit staged" "
184 git -C $REPO commit -a -m data
187 do_status "$t status after commit"
189 test_expect_success "$t reset HEAD~1 hard" "
190 git -C $REPO reset --hard HEAD~1 >/dev/null 2>&1
193 do_status "$t status after reset hard"
195 # Create some untracked files.
197 test_expect_success "$t create untracked files" "
198 cp -R $REPO/ballast/dir1 $REPO/ballast/xxx1
201 do_status "$t status after create untracked files"
203 # Remove the new untracked files.
205 test_expect_success "$t clean -df" "
206 git -C $REPO clean -d -f
209 do_status "$t status after clean"
211 if test $fsm = true
212 then
213 stop_fsm
217 # Begin testing each case in the matrix that we care about.
219 uc_values="false"
220 test_have_prereq UNTRACKED_CACHE && uc_values="false true"
222 fsm_values="false true"
224 for uc_val in $uc_values
226 for fsm_val in $fsm_values
228 do_matrix $uc_val $fsm_val
229 done
230 done
232 cleanup () {
233 uc=$1
234 fsm=$2
236 MATRIX_BR="$TMP_BR-$uc-$fsm"
238 test_might_fail git -C $REPO branch -D $MATRIX_BR
242 # We're borrowing this repo. We should leave it in a clean state.
244 test_expect_success "Cleanup temp and matrix branches" "
245 git -C $REPO clean -d -f &&
246 test_might_fail git -C $REPO checkout $BALLAST_BR &&
247 test_might_fail git -C $REPO branch -D $TMP_BR &&
248 for uc_val in $uc_values
250 for fsm_val in $fsm_values
252 cleanup $uc_val $fsm_val || return 1
253 done
254 done
257 test_done