Skip to content

Commit 774fc5b

Browse files
avargitster
authored andcommitted
perf: add a performance test for core.fsmonitor
Add a performance test for the new core.fsmonitor facility using the sample query-fsmonitor hook. This is WIP code for the reasons explained in the setup comments, unfortunately the perf code doesn't easily allow you to run different setup code for different versions you're testing. This test will stop working if the fsmonitor is merged into the master branch. Output against linxu.git: $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux GIT_PERF_MAKE_OPTS='-j8' ./run origin/master avar/fsmonitor ./p7519-fsmonitor.sh [...] Test origin/master avar/fsmonitor ----------------------------------------------------------------------- 7519.2: status (first) 0.08(0.04+0.09) 0.12(0.07+0.10) +50.0% 7519.3: status (subsequent) 0.08(0.04+0.09) 0.12(0.06+0.11) +50.0% 7519.4: status -uno 0.02(0.02+0.05) 0.06(0.05+0.06) +200.0% 7519.5: status -uall 0.08(0.06+0.07) 0.12(0.07+0.10) +50.0% And against a larger in-house monorepo I have here, with the same options (except the repo path): Test origin/master avar/fsmonitor ----------------------------------------------------------------------- 7519.2: status (first) 0.20(0.11+0.18) 0.27(0.15+0.21) +35.0% 7519.3: status (subsequent) 0.20(0.11+0.18) 0.27(0.15+0.21) +35.0% 7519.4: status -uno 0.04(0.03+0.10) 0.22(0.08+0.12) +450.0% 7519.5: status -uall 0.20(0.13+0.16) 0.27(0.18+0.19) +35.0% Against linux.git with a hack to flush the FS cache (on Linux) before running the first 'git status', only running one test so the result isn't discarded as the slowest of N: $ GIT_PERF_REPEAT_COUNT=1 GIT_PERF_LARGE_REPO=~/g/linux GIT_PERF_MAKE_COMMAND='sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null && make -j8' ./run origin/master avar/fsmonitor ./p7519-fsmonitor.sh [...] Test origin/master avar/fsmonitor ------------------------------------------------------------------------ 7519.2: status (first) 0.30(0.18+0.10) 8.26(0.22+0.10) +2653.3% 7519.3: status (subsequent) 0.08(0.04+0.08) 0.81(0.09+0.07) +912.5% 7519.4: status -uno 0.02(0.01+0.06) 0.08(0.04+0.07) +300.0% 7519.5: status -uall 0.08(0.06+0.07) 0.15(0.08+0.09) +87.5% Now obviously due to 1 run that has a lot of noise, but I would expect that first invocation to be blindingly fast since watchman has info on what files were modified since the cache was flushed. The same on the large monorepo noted above: Test origin/master avar/fsmonitor ----------------------------------------------------------------------- 7519.2: status (first) 0.59(0.28+0.24) 0.93(0.35+0.19) +57.6% 7519.3: status (subsequent) 0.20(0.10+0.19) 0.28(0.16+0.20) +40.0% 7519.4: status -uno 0.04(0.04+0.09) 0.11(0.08+0.12) +175.0% 7519.5: status -uall 0.29(0.11+0.18) 0.40(0.16+0.19) +37.9% Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c12b6d commit 774fc5b

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

t/perf/p7519-fsmonitor.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
3+
test_description="Test core.fsmonitor"
4+
5+
. ./perf-lib.sh
6+
7+
test_perf_large_repo
8+
test_checkout_worktree
9+
10+
test_expect_success 'setup' '
11+
# Maybe set untrackedCache & splitIndex depending on the
12+
# environment, defaulting to false.
13+
if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
14+
then
15+
git config core.untrackedCache true
16+
else
17+
git config core.untrackedCache false
18+
fi &&
19+
if test -n "$GIT_PERF_7519_SPLIT_INDEX"
20+
then
21+
git config core.splitIndex true
22+
else
23+
git config core.splitIndex false
24+
fi &&
25+
26+
# Relies on core.fsmonitor not being merged into master. Needs
27+
# better per-test ways to disable it if it gets merged.
28+
git config core.fsmonitor true &&
29+
30+
# Hook scaffolding
31+
mkdir .git/hooks &&
32+
cp ../../../templates/hooks--query-fsmonitor.sample .git/hooks/query-fsmonitor &&
33+
34+
# Setup watchman & ensure it is actually watching
35+
watchman watch-del "$PWD" >/dev/null 2>&1 &&
36+
watchman watch "$PWD" >/dev/null 2>&1 &&
37+
watchman watch-list | grep -q -F "$PWD"
38+
'
39+
40+
# Setting:
41+
#
42+
# GIT_PERF_REPEAT_COUNT=1 GIT_PERF_MAKE_COMMAND='sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && make -j8'
43+
#
44+
# Can be used as a hack to performance test 'git status' on a cold fs
45+
# cache with an existing watchman watching the directory, which should
46+
# be blindingly fast, compared to amazingly slow without watchman.
47+
test_perf 'status (first)' 'git status'
48+
49+
50+
# The same git-status once the fs cache has been warmed, if using the
51+
# GIT_PERF_MAKE_COMMAND above. Otherwise the same as above.
52+
test_perf 'status (subsequent)' 'git status'
53+
54+
# Let's see if -uno & -uall make any difference
55+
test_perf 'status -uno' 'git status -uno'
56+
test_perf 'status -uall' 'git status -uall'
57+
58+
test_done

0 commit comments

Comments
 (0)