2017-09-22 16:35:48 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description="Test core.fsmonitor"
|
|
|
|
|
|
|
|
. ./perf-lib.sh
|
|
|
|
|
|
|
|
#
|
|
|
|
# Performance test for the fsmonitor feature which enables git to talk to a
|
|
|
|
# file system change monitor and avoid having to scan the working directory
|
|
|
|
# for new or modified files.
|
|
|
|
#
|
|
|
|
# By default, the performance test will utilize the Watchman file system
|
|
|
|
# monitor if it is installed. If Watchman is not installed, it will use a
|
|
|
|
# dummy integration script that does not report any new or modified files.
|
|
|
|
# The dummy script has very little overhead which provides optimistic results.
|
|
|
|
#
|
|
|
|
# The performance test will also use the untracked cache feature if it is
|
|
|
|
# available as fsmonitor uses it to speed up scanning for untracked files.
|
|
|
|
#
|
|
|
|
# There are 3 environment variables that can be used to alter the default
|
|
|
|
# behavior of the performance test:
|
|
|
|
#
|
|
|
|
# GIT_PERF_7519_UNTRACKED_CACHE: used to configure core.untrackedCache
|
|
|
|
# GIT_PERF_7519_SPLIT_INDEX: used to configure core.splitIndex
|
2020-10-26 19:32:52 +00:00
|
|
|
# GIT_PERF_7519_FSMONITOR: used to configure core.fsMonitor. May be an
|
|
|
|
# absolute path to an integration. May be a space delimited list of
|
|
|
|
# absolute paths to integrations.
|
2017-09-22 16:35:48 +00:00
|
|
|
#
|
|
|
|
# The big win for using fsmonitor is the elimination of the need to scan the
|
|
|
|
# working directory looking for changed and untracked files. If the file
|
|
|
|
# information is all cached in RAM, the benefits are reduced.
|
|
|
|
#
|
|
|
|
# GIT_PERF_7519_DROP_CACHE: if set, the OS caches are dropped between tests
|
|
|
|
#
|
2021-02-03 15:34:43 +00:00
|
|
|
# GIT_PERF_7519_TRACE: if set, enable trace logging during the test.
|
|
|
|
# Trace logs will be grouped by fsmonitor provider.
|
2017-09-22 16:35:48 +00:00
|
|
|
|
|
|
|
test_perf_large_repo
|
|
|
|
test_checkout_worktree
|
|
|
|
|
|
|
|
test_lazy_prereq UNTRACKED_CACHE '
|
|
|
|
{ git update-index --test-untracked-cache; ret=$?; } &&
|
|
|
|
test $ret -ne 1
|
|
|
|
'
|
|
|
|
|
|
|
|
test_lazy_prereq WATCHMAN '
|
2017-12-16 12:12:23 +00:00
|
|
|
command -v watchman
|
2017-09-22 16:35:48 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
if test_have_prereq WATCHMAN
|
|
|
|
then
|
|
|
|
# Convert unix style paths to escaped Windows style paths for Watchman
|
|
|
|
case "$(uname -s)" in
|
|
|
|
MSYS_NT*)
|
|
|
|
GIT_WORK_TREE="$(cygpath -aw "$PWD" | sed 's,\\,/,g')"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
GIT_WORK_TREE="$PWD"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2022-03-25 18:03:07 +00:00
|
|
|
trace_start () {
|
2021-02-03 15:34:43 +00:00
|
|
|
if test -n "$GIT_PERF_7519_TRACE"
|
|
|
|
then
|
|
|
|
name="$1"
|
|
|
|
TEST_TRACE_DIR="$TEST_OUTPUT_DIRECTORY/test-trace/p7519/"
|
|
|
|
echo "Writing trace logging to $TEST_TRACE_DIR"
|
|
|
|
|
|
|
|
mkdir -p "$TEST_TRACE_DIR"
|
|
|
|
|
|
|
|
# Start Trace2 logging and any other GIT_TRACE_* logs that you
|
|
|
|
# want for this named test case.
|
|
|
|
|
|
|
|
GIT_TRACE2_PERF="$TEST_TRACE_DIR/$name.trace2perf"
|
|
|
|
export GIT_TRACE2_PERF
|
|
|
|
|
|
|
|
>"$GIT_TRACE2_PERF"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-25 18:03:07 +00:00
|
|
|
trace_stop () {
|
2021-02-03 15:34:43 +00:00
|
|
|
if test -n "$GIT_PERF_7519_TRACE"
|
|
|
|
then
|
|
|
|
unset GIT_TRACE2_PERF
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-03-25 18:03:08 +00:00
|
|
|
touch_files () {
|
|
|
|
n=$1 &&
|
|
|
|
d="$n"_files &&
|
|
|
|
|
|
|
|
(cd $d && test_seq 1 $n | xargs touch )
|
|
|
|
}
|
|
|
|
|
2020-10-26 19:32:44 +00:00
|
|
|
test_expect_success "one time repo setup" '
|
2017-09-22 16:35:48 +00:00
|
|
|
# set untrackedCache depending on the environment
|
|
|
|
if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
|
|
|
|
then
|
|
|
|
git config core.untrackedCache "$GIT_PERF_7519_UNTRACKED_CACHE"
|
|
|
|
else
|
|
|
|
if test_have_prereq UNTRACKED_CACHE
|
|
|
|
then
|
|
|
|
git config core.untrackedCache true
|
|
|
|
else
|
|
|
|
git config core.untrackedCache false
|
|
|
|
fi
|
|
|
|
fi &&
|
|
|
|
|
|
|
|
# set core.splitindex depending on the environment
|
|
|
|
if test -n "$GIT_PERF_7519_SPLIT_INDEX"
|
|
|
|
then
|
|
|
|
git config core.splitIndex "$GIT_PERF_7519_SPLIT_INDEX"
|
|
|
|
fi &&
|
|
|
|
|
2020-10-26 19:32:44 +00:00
|
|
|
mkdir 1_file 10_files 100_files 1000_files 10000_files &&
|
2022-03-25 18:03:08 +00:00
|
|
|
: 1_file directory should be left empty &&
|
|
|
|
touch_files 10 &&
|
|
|
|
touch_files 100 &&
|
|
|
|
touch_files 1000 &&
|
|
|
|
touch_files 10000 &&
|
2020-10-26 19:32:44 +00:00
|
|
|
git add 1_file 10_files 100_files 1000_files 10000_files &&
|
2020-10-26 19:32:49 +00:00
|
|
|
git commit -qm "Add files" &&
|
2020-10-26 19:32:45 +00:00
|
|
|
|
|
|
|
# If Watchman exists, watch the work tree and attempt a query.
|
|
|
|
if test_have_prereq WATCHMAN; then
|
|
|
|
watchman watch "$GIT_WORK_TREE" &&
|
2021-02-03 15:34:41 +00:00
|
|
|
watchman watch-list | grep -q -F "p7519-fsmonitor"
|
2020-10-26 19:32:45 +00:00
|
|
|
fi
|
2020-10-26 19:32:44 +00:00
|
|
|
'
|
|
|
|
|
2022-03-25 18:03:09 +00:00
|
|
|
setup_for_fsmonitor_hook () {
|
2017-09-22 16:35:48 +00:00
|
|
|
# set INTEGRATION_SCRIPT depending on the environment
|
2020-10-26 19:32:52 +00:00
|
|
|
if test -n "$INTEGRATION_PATH"
|
2017-09-22 16:35:48 +00:00
|
|
|
then
|
2020-10-26 19:32:52 +00:00
|
|
|
INTEGRATION_SCRIPT="$INTEGRATION_PATH"
|
2017-09-22 16:35:48 +00:00
|
|
|
else
|
|
|
|
#
|
|
|
|
# Choose integration script based on existence of Watchman.
|
2020-10-26 19:32:45 +00:00
|
|
|
# Fall back to an empty integration script.
|
2017-09-22 16:35:48 +00:00
|
|
|
#
|
|
|
|
mkdir .git/hooks &&
|
|
|
|
if test_have_prereq WATCHMAN
|
|
|
|
then
|
|
|
|
INTEGRATION_SCRIPT=".git/hooks/fsmonitor-watchman" &&
|
2020-10-26 19:32:45 +00:00
|
|
|
cp "$TEST_DIRECTORY/../templates/hooks--fsmonitor-watchman.sample" "$INTEGRATION_SCRIPT"
|
2017-09-22 16:35:48 +00:00
|
|
|
else
|
|
|
|
INTEGRATION_SCRIPT=".git/hooks/fsmonitor-empty" &&
|
|
|
|
write_script "$INTEGRATION_SCRIPT"<<-\EOF
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
fi &&
|
|
|
|
|
|
|
|
git config core.fsmonitor "$INTEGRATION_SCRIPT" &&
|
2020-10-26 19:32:46 +00:00
|
|
|
git update-index --fsmonitor 2>error &&
|
p7519: allow running without watchman prereq
p7519 measures the performance of the fsmonitor code. To do this, it
uses the installed copy of Watchman. If Watchman isn't installed, a noop
integration script is installed in its place.
When in the latter mode, it is expected that the script should not write
a "last update token": in fact, it doesn't write anything at all since
the script is blank.
Commit 33226af42b (t/perf/fsmonitor: improve error message if typoing
hook name, 2020-10-26) made sure that running 'git update-index
--fsmonitor' did not write anything to stderr, but this is not the case
when using the empty Watchman script, since Git will complain that:
$ which watchman
watchman not found
$ cat .git/hooks/fsmonitor-empty
$ git -c core.fsmonitor=.git/hooks/fsmonitor-empty update-index --fsmonitor
warning: Empty last update token.
Prior to 33226af42b, the output wasn't checked at all, which allowed
this noop mode to work. But, 33226af42b breaks p7519 when running it
without a 'watchman(1)' on your system.
Handle this by only checking that the stderr is empty only when running
with a real watchman executable. Otherwise, assert that the error
message is the expected one when running in the noop mode.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Acked-by: Nipunn Koorapati <nipunn@dropbox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2021-01-04 21:35:37 +00:00
|
|
|
if test_have_prereq WATCHMAN
|
|
|
|
then
|
|
|
|
test_must_be_empty error # ensure no silent error
|
|
|
|
else
|
|
|
|
grep "Empty last update token" error
|
|
|
|
fi
|
2020-10-26 19:32:50 +00:00
|
|
|
}
|
2017-09-22 16:35:48 +00:00
|
|
|
|
2020-10-20 13:41:03 +00:00
|
|
|
test_perf_w_drop_caches () {
|
|
|
|
if test -n "$GIT_PERF_7519_DROP_CACHE"; then
|
2022-04-05 05:20:17 +00:00
|
|
|
test_perf "$1" --setup "test-tool drop-caches" "$2"
|
|
|
|
else
|
|
|
|
test_perf "$@"
|
2020-10-20 13:41:03 +00:00
|
|
|
fi
|
|
|
|
}
|
2017-09-22 16:35:48 +00:00
|
|
|
|
2022-03-25 18:03:07 +00:00
|
|
|
test_fsmonitor_suite () {
|
2022-03-25 18:03:09 +00:00
|
|
|
if test -n "$USE_FSMONITOR_DAEMON"
|
|
|
|
then
|
|
|
|
DESC="builtin fsmonitor--daemon"
|
|
|
|
elif test -n "$INTEGRATION_SCRIPT"
|
|
|
|
then
|
2020-10-26 19:32:48 +00:00
|
|
|
DESC="fsmonitor=$(basename $INTEGRATION_SCRIPT)"
|
|
|
|
else
|
|
|
|
DESC="fsmonitor=disabled"
|
|
|
|
fi
|
2020-10-26 19:32:47 +00:00
|
|
|
|
2020-10-26 19:32:51 +00:00
|
|
|
test_expect_success "test_initialization" '
|
|
|
|
git reset --hard &&
|
|
|
|
git status # Warm caches
|
|
|
|
'
|
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "status ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git status
|
|
|
|
'
|
2017-09-22 16:35:48 +00:00
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "status -uno ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git status -uno
|
|
|
|
'
|
2017-09-22 16:35:48 +00:00
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "status -uall ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git status -uall
|
|
|
|
'
|
2017-09-22 16:35:48 +00:00
|
|
|
|
2021-02-03 15:34:40 +00:00
|
|
|
# Update the mtimes on upto 100k files to make status think
|
|
|
|
# that they are dirty. For simplicity, omit any files with
|
2022-03-25 18:03:08 +00:00
|
|
|
# LFs (i.e. anything that ls-files thinks it needs to dquote)
|
|
|
|
# and any files with whitespace so that they pass thru xargs
|
|
|
|
# properly.
|
2021-02-03 15:34:40 +00:00
|
|
|
#
|
2020-10-26 19:32:53 +00:00
|
|
|
test_perf_w_drop_caches "status (dirty) ($DESC)" '
|
2021-02-03 15:34:40 +00:00
|
|
|
git ls-files | \
|
|
|
|
head -100000 | \
|
|
|
|
grep -v \" | \
|
2022-03-25 18:03:08 +00:00
|
|
|
grep -v " ." | \
|
2021-02-03 15:34:40 +00:00
|
|
|
xargs test-tool chmtime -300 &&
|
2020-10-26 19:32:53 +00:00
|
|
|
git status
|
|
|
|
'
|
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "diff ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git diff
|
|
|
|
'
|
2020-10-20 13:41:01 +00:00
|
|
|
|
2021-03-17 21:22:23 +00:00
|
|
|
test_perf_w_drop_caches "diff HEAD ($DESC)" '
|
|
|
|
git diff HEAD
|
|
|
|
'
|
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "diff -- 0_files ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git diff -- 1_file
|
|
|
|
'
|
2020-10-20 13:41:01 +00:00
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "diff -- 10_files ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git diff -- 10_files
|
|
|
|
'
|
2020-10-20 13:41:01 +00:00
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "diff -- 100_files ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git diff -- 100_files
|
|
|
|
'
|
2020-10-20 13:41:01 +00:00
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "diff -- 1000_files ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git diff -- 1000_files
|
|
|
|
'
|
2020-10-20 13:41:01 +00:00
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "diff -- 10000_files ($DESC)" '
|
2020-10-20 13:41:03 +00:00
|
|
|
git diff -- 10000_files
|
|
|
|
'
|
2020-10-20 13:41:04 +00:00
|
|
|
|
2020-10-26 19:32:47 +00:00
|
|
|
test_perf_w_drop_caches "add ($DESC)" '
|
2020-10-20 13:41:04 +00:00
|
|
|
git add --all
|
|
|
|
'
|
2020-10-20 13:41:03 +00:00
|
|
|
}
|
2020-10-20 13:41:01 +00:00
|
|
|
|
2021-02-03 15:34:42 +00:00
|
|
|
#
|
|
|
|
# Run a full set of perf tests using each Hook-based fsmonitor provider,
|
|
|
|
# such as Watchman.
|
|
|
|
#
|
|
|
|
|
2021-02-03 15:34:43 +00:00
|
|
|
trace_start fsmonitor-watchman
|
2020-10-26 19:32:52 +00:00
|
|
|
if test -n "$GIT_PERF_7519_FSMONITOR"; then
|
|
|
|
for INTEGRATION_PATH in $GIT_PERF_7519_FSMONITOR; do
|
2022-03-25 18:03:09 +00:00
|
|
|
test_expect_success "setup for fsmonitor $INTEGRATION_PATH" 'setup_for_fsmonitor_hook'
|
2020-10-26 19:32:52 +00:00
|
|
|
test_fsmonitor_suite
|
|
|
|
done
|
|
|
|
else
|
2022-03-25 18:03:09 +00:00
|
|
|
test_expect_success "setup for fsmonitor hook" 'setup_for_fsmonitor_hook'
|
2020-10-26 19:32:52 +00:00
|
|
|
test_fsmonitor_suite
|
|
|
|
fi
|
2020-10-20 13:41:01 +00:00
|
|
|
|
2017-09-22 16:35:48 +00:00
|
|
|
if test_have_prereq WATCHMAN
|
|
|
|
then
|
|
|
|
watchman watch-del "$GIT_WORK_TREE" >/dev/null 2>&1 &&
|
|
|
|
|
|
|
|
# Work around Watchman bug on Windows where it holds on to handles
|
|
|
|
# preventing the removal of the trash directory
|
|
|
|
watchman shutdown-server >/dev/null 2>&1
|
|
|
|
fi
|
2021-02-03 15:34:43 +00:00
|
|
|
trace_stop
|
2017-09-22 16:35:48 +00:00
|
|
|
|
2021-02-03 15:34:42 +00:00
|
|
|
#
|
|
|
|
# Run a full set of perf tests with the fsmonitor feature disabled.
|
|
|
|
#
|
|
|
|
|
2021-02-03 15:34:43 +00:00
|
|
|
trace_start fsmonitor-disabled
|
2021-02-03 15:34:42 +00:00
|
|
|
test_expect_success "setup without fsmonitor" '
|
|
|
|
unset INTEGRATION_SCRIPT &&
|
|
|
|
git config --unset core.fsmonitor &&
|
|
|
|
git update-index --no-fsmonitor
|
|
|
|
'
|
|
|
|
|
|
|
|
test_fsmonitor_suite
|
2021-02-03 15:34:43 +00:00
|
|
|
trace_stop
|
2017-09-22 16:35:48 +00:00
|
|
|
|
2022-03-25 18:03:09 +00:00
|
|
|
#
|
|
|
|
# Run a full set of perf tests using the built-in fsmonitor--daemon.
|
|
|
|
# It does not use the Hook API, so it has a different setup.
|
|
|
|
# Explicitly start the daemon here and before we start client commands
|
|
|
|
# so that we can later add custom tracing.
|
|
|
|
#
|
|
|
|
if test_have_prereq FSMONITOR_DAEMON
|
|
|
|
then
|
|
|
|
USE_FSMONITOR_DAEMON=t
|
|
|
|
|
|
|
|
test_expect_success "setup for builtin fsmonitor" '
|
|
|
|
trace_start fsmonitor--daemon--server &&
|
|
|
|
git fsmonitor--daemon start &&
|
|
|
|
|
|
|
|
trace_start fsmonitor--daemon--client &&
|
|
|
|
|
|
|
|
git config core.fsmonitor true &&
|
|
|
|
git update-index --fsmonitor
|
|
|
|
'
|
|
|
|
|
|
|
|
test_fsmonitor_suite
|
|
|
|
|
|
|
|
git fsmonitor--daemon stop
|
|
|
|
trace_stop
|
|
|
|
fi
|
|
|
|
|
2017-09-22 16:35:48 +00:00
|
|
|
test_done
|