summaryrefslogtreecommitdiff
path: root/t/perf/p7519-fsmonitor.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/perf/p7519-fsmonitor.sh')
-rwxr-xr-xt/perf/p7519-fsmonitor.sh255
1 files changed, 193 insertions, 62 deletions
diff --git a/t/perf/p7519-fsmonitor.sh b/t/perf/p7519-fsmonitor.sh
index def7ecd..b1cb238 100755
--- a/t/perf/p7519-fsmonitor.sh
+++ b/t/perf/p7519-fsmonitor.sh
@@ -22,7 +22,9 @@ test_description="Test core.fsmonitor"
#
# GIT_PERF_7519_UNTRACKED_CACHE: used to configure core.untrackedCache
# GIT_PERF_7519_SPLIT_INDEX: used to configure core.splitIndex
-# GIT_PERF_7519_FSMONITOR: used to configure core.fsMonitor
+# 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.
#
# 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
@@ -30,6 +32,8 @@ test_description="Test core.fsmonitor"
#
# GIT_PERF_7519_DROP_CACHE: if set, the OS caches are dropped between tests
#
+# GIT_PERF_7519_TRACE: if set, enable trace logging during the test.
+# Trace logs will be grouped by fsmonitor provider.
test_perf_large_repo
test_checkout_worktree
@@ -56,19 +60,40 @@ then
esac
fi
-if test -n "$GIT_PERF_7519_DROP_CACHE"
-then
- # When using GIT_PERF_7519_DROP_CACHE, GIT_PERF_REPEAT_COUNT must be 1 to
- # generate valid results. Otherwise the caching that happens for the nth
- # run will negate the validity of the comparisons.
- if test "$GIT_PERF_REPEAT_COUNT" -ne 1
+trace_start () {
+ if test -n "$GIT_PERF_7519_TRACE"
then
- echo "warning: Setting GIT_PERF_REPEAT_COUNT=1" >&2
- GIT_PERF_REPEAT_COUNT=1
+ 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
-fi
+}
+
+trace_stop () {
+ if test -n "$GIT_PERF_7519_TRACE"
+ then
+ unset GIT_TRACE2_PERF
+ fi
+}
-test_expect_success "setup for fsmonitor" '
+touch_files () {
+ n=$1 &&
+ d="$n"_files &&
+
+ (cd $d && test_seq 1 $n | xargs touch )
+}
+
+test_expect_success "one time repo setup" '
# set untrackedCache depending on the environment
if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
then
@@ -88,24 +113,37 @@ test_expect_success "setup for fsmonitor" '
git config core.splitIndex "$GIT_PERF_7519_SPLIT_INDEX"
fi &&
+ mkdir 1_file 10_files 100_files 1000_files 10000_files &&
+ : 1_file directory should be left empty &&
+ touch_files 10 &&
+ touch_files 100 &&
+ touch_files 1000 &&
+ touch_files 10000 &&
+ git add 1_file 10_files 100_files 1000_files 10000_files &&
+ git commit -qm "Add files" &&
+
+ # If Watchman exists, watch the work tree and attempt a query.
+ if test_have_prereq WATCHMAN; then
+ watchman watch "$GIT_WORK_TREE" &&
+ watchman watch-list | grep -q -F "p7519-fsmonitor"
+ fi
+'
+
+setup_for_fsmonitor_hook () {
# set INTEGRATION_SCRIPT depending on the environment
- if test -n "$GIT_PERF_7519_FSMONITOR"
+ if test -n "$INTEGRATION_PATH"
then
- INTEGRATION_SCRIPT="$GIT_PERF_7519_FSMONITOR"
+ INTEGRATION_SCRIPT="$INTEGRATION_PATH"
else
#
# Choose integration script based on existence of Watchman.
- # If Watchman exists, watch the work tree and attempt a query.
- # If everything succeeds, use Watchman integration script,
- # else fall back to an empty integration script.
+ # Fall back to an empty integration script.
#
mkdir .git/hooks &&
if test_have_prereq WATCHMAN
then
INTEGRATION_SCRIPT=".git/hooks/fsmonitor-watchman" &&
- cp "$TEST_DIRECTORY/../templates/hooks--fsmonitor-watchman.sample" "$INTEGRATION_SCRIPT" &&
- watchman watch "$GIT_WORK_TREE" &&
- watchman watch-list | grep -q -F "$GIT_WORK_TREE"
+ cp "$TEST_DIRECTORY/../templates/hooks--fsmonitor-watchman.sample" "$INTEGRATION_SCRIPT"
else
INTEGRATION_SCRIPT=".git/hooks/fsmonitor-empty" &&
write_script "$INTEGRATION_SCRIPT"<<-\EOF
@@ -114,62 +152,114 @@ test_expect_success "setup for fsmonitor" '
fi &&
git config core.fsmonitor "$INTEGRATION_SCRIPT" &&
- git update-index --fsmonitor
-'
+ git update-index --fsmonitor 2>error &&
+ if test_have_prereq WATCHMAN
+ then
+ test_must_be_empty error # ensure no silent error
+ else
+ grep "Empty last update token" error
+ fi
+}
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+test_perf_w_drop_caches () {
+ if test -n "$GIT_PERF_7519_DROP_CACHE"; then
+ test_perf "$1" --setup "test-tool drop-caches" "$2"
+ else
+ test_perf "$@"
+ fi
+}
-test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status
-'
+test_fsmonitor_suite () {
+ if test -n "$USE_FSMONITOR_DAEMON"
+ then
+ DESC="builtin fsmonitor--daemon"
+ elif test -n "$INTEGRATION_SCRIPT"
+ then
+ DESC="fsmonitor=$(basename $INTEGRATION_SCRIPT)"
+ else
+ DESC="fsmonitor=disabled"
+ fi
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+ test_expect_success "test_initialization" '
+ git reset --hard &&
+ git status # Warm caches
+ '
-test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status -uno
-'
+ test_perf_w_drop_caches "status ($DESC)" '
+ git status
+ '
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+ test_perf_w_drop_caches "status -uno ($DESC)" '
+ git status -uno
+ '
-test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status -uall
-'
+ test_perf_w_drop_caches "status -uall ($DESC)" '
+ git status -uall
+ '
-test_expect_success "setup without fsmonitor" '
- unset INTEGRATION_SCRIPT &&
- git config --unset core.fsmonitor &&
- git update-index --no-fsmonitor
-'
+ # Update the mtimes on upto 100k files to make status think
+ # that they are dirty. For simplicity, omit any files with
+ # LFs (i.e. anything that ls-files thinks it needs to dquote)
+ # and any files with whitespace so that they pass thru xargs
+ # properly.
+ #
+ test_perf_w_drop_caches "status (dirty) ($DESC)" '
+ git ls-files | \
+ head -100000 | \
+ grep -v \" | \
+ grep -v " ." | \
+ xargs test-tool chmtime -300 &&
+ git status
+ '
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+ test_perf_w_drop_caches "diff ($DESC)" '
+ git diff
+ '
-test_perf "status (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status
-'
+ test_perf_w_drop_caches "diff HEAD ($DESC)" '
+ git diff HEAD
+ '
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+ test_perf_w_drop_caches "diff -- 0_files ($DESC)" '
+ git diff -- 1_file
+ '
-test_perf "status -uno (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status -uno
-'
+ test_perf_w_drop_caches "diff -- 10_files ($DESC)" '
+ git diff -- 10_files
+ '
-if test -n "$GIT_PERF_7519_DROP_CACHE"; then
- test-tool drop-caches
-fi
+ test_perf_w_drop_caches "diff -- 100_files ($DESC)" '
+ git diff -- 100_files
+ '
-test_perf "status -uall (fsmonitor=$INTEGRATION_SCRIPT)" '
- git status -uall
-'
+ test_perf_w_drop_caches "diff -- 1000_files ($DESC)" '
+ git diff -- 1000_files
+ '
+
+ test_perf_w_drop_caches "diff -- 10000_files ($DESC)" '
+ git diff -- 10000_files
+ '
+
+ test_perf_w_drop_caches "add ($DESC)" '
+ git add --all
+ '
+}
+
+#
+# Run a full set of perf tests using each Hook-based fsmonitor provider,
+# such as Watchman.
+#
+
+trace_start fsmonitor-watchman
+if test -n "$GIT_PERF_7519_FSMONITOR"; then
+ for INTEGRATION_PATH in $GIT_PERF_7519_FSMONITOR; do
+ test_expect_success "setup for fsmonitor $INTEGRATION_PATH" 'setup_for_fsmonitor_hook'
+ test_fsmonitor_suite
+ done
+else
+ test_expect_success "setup for fsmonitor hook" 'setup_for_fsmonitor_hook'
+ test_fsmonitor_suite
+fi
if test_have_prereq WATCHMAN
then
@@ -179,5 +269,46 @@ then
# preventing the removal of the trash directory
watchman shutdown-server >/dev/null 2>&1
fi
+trace_stop
+
+#
+# Run a full set of perf tests with the fsmonitor feature disabled.
+#
+
+trace_start fsmonitor-disabled
+test_expect_success "setup without fsmonitor" '
+ unset INTEGRATION_SCRIPT &&
+ git config --unset core.fsmonitor &&
+ git update-index --no-fsmonitor
+'
+
+test_fsmonitor_suite
+trace_stop
+
+#
+# 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
test_done