]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/perf/p7519-fsmonitor.sh
Merge branch 'jh/fsmonitor-prework'
[thirdparty/git.git] / t / perf / p7519-fsmonitor.sh
index 1e20a184c70e67c51a5feb41baed92b987394173..b657564aed603557a86916df9f450c6e067af74e 100755 (executable)
@@ -32,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
@@ -70,6 +72,32 @@ then
        fi
 fi
 
+trace_start() {
+       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
+}
+
+trace_stop() {
+       if test -n "$GIT_PERF_7519_TRACE"
+       then
+               unset GIT_TRACE2_PERF
+       fi
+}
+
 test_expect_success "one time repo setup" '
        # set untrackedCache depending on the environment
        if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
@@ -101,7 +129,7 @@ test_expect_success "one time repo setup" '
        # 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 "$GIT_WORK_TREE"
+               watchman watch-list | grep -q -F "p7519-fsmonitor"
        fi
 '
 
@@ -169,8 +197,18 @@ test_fsmonitor_suite() {
                git status -uall
        '
 
+       # 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).
+       # Then fully backslash-quote the paths to capture any
+       # whitespace so that they pass thru xargs properly.
+       #
        test_perf_w_drop_caches "status (dirty) ($DESC)" '
-               git ls-files | head -100000 | xargs -d "\n" touch -h &&
+               git ls-files | \
+                       head -100000 | \
+                       grep -v \" | \
+                       sed '\''s/\(.\)/\\\1/g'\'' | \
+                       xargs test-tool chmtime -300 &&
                git status
        '
 
@@ -203,6 +241,12 @@ test_fsmonitor_suite() {
        '
 }
 
+#
+# 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'
@@ -213,14 +257,6 @@ else
        test_fsmonitor_suite
 fi
 
-test_expect_success "setup without fsmonitor" '
-       unset INTEGRATION_SCRIPT &&
-       git config --unset core.fsmonitor &&
-       git update-index --no-fsmonitor
-'
-
-test_fsmonitor_suite
-
 if test_have_prereq WATCHMAN
 then
        watchman watch-del "$GIT_WORK_TREE" >/dev/null 2>&1 &&
@@ -229,5 +265,20 @@ 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
 
 test_done