p7519: add trace logging during perf test
Add optional trace logging to allow us to better compare performance of various fsmonitor providers and compare results with non-fsmonitor runs. Currently, this includes Trace2 logging, but may be extended to include other trace targets, such as GIT_TRACE_FSMONITOR if desired. Using this logging helped me explain an odd behavior on MacOS where the kernel was dropping events and causing the hook to Watchman to timeout. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
Feb 3, 2021 at 15:34 UTC
4f2009dce2d270ded8bb94417becf6cc2143c70c
3 files changed
+35
-2
t/perf/.gitignore
+1
@@ -1,3 +1,4 @@
1
/build/
2
/test-results/
3
+/test-trace/
4
/trash directory*/
t/perf/Makefile
+2
-2
@@ -7,10 +7,10 @@ perf: pre-clean
7
./run
8
9
pre-clean:
10
- rm -rf test-results
10
+ rm -rf test-results test-trace
11
12
clean:
13
- rm -rf build "trash directory".* test-results
13
+ rm -rf build "trash directory".* test-results test-trace
14
15
test-lint:
16
$(MAKE) -C .. test-lint
t/perf/p7519-fsmonitor.sh
+32
@@ -32,6 +32,8 @@ test_description="Test core.fsmonitor"
32
#
33
# GIT_PERF_7519_DROP_CACHE: if set, the OS caches are dropped between tests
34
#
35
+# GIT_PERF_7519_TRACE: if set, enable trace logging during the test.
36
+# Trace logs will be grouped by fsmonitor provider.
37
38
test_perf_large_repo
39
test_checkout_worktree
@@ -70,6 +72,32 @@ then
72
fi
73
fi
74
75
+trace_start() {
76
+ if test -n "$GIT_PERF_7519_TRACE"
77
+ then
78
+ name="$1"
79
+ TEST_TRACE_DIR="$TEST_OUTPUT_DIRECTORY/test-trace/p7519/"
80
+ echo "Writing trace logging to $TEST_TRACE_DIR"
81
+
82
+ mkdir -p "$TEST_TRACE_DIR"
83
+
84
+ # Start Trace2 logging and any other GIT_TRACE_* logs that you
85
+ # want for this named test case.
86
+
87
+ GIT_TRACE2_PERF="$TEST_TRACE_DIR/$name.trace2perf"
88
+ export GIT_TRACE2_PERF
89
+
90
+ >"$GIT_TRACE2_PERF"
91
+ fi
92
+}
93
+
94
+trace_stop() {
95
+ if test -n "$GIT_PERF_7519_TRACE"
96
+ then
97
+ unset GIT_TRACE2_PERF
98
+ fi
99
+}
100
+
101
test_expect_success "one time repo setup" '
102
# set untrackedCache depending on the environment
103
if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
@@ -213,6 +241,7 @@ test_fsmonitor_suite() {
241
# such as Watchman.
242
#
243
244
+trace_start fsmonitor-watchman
245
if test -n "$GIT_PERF_7519_FSMONITOR"; then
246
for INTEGRATION_PATH in $GIT_PERF_7519_FSMONITOR; do
247
test_expect_success "setup for fsmonitor $INTEGRATION_PATH" 'setup_for_fsmonitor'
@@ -231,11 +260,13 @@ then
260
# preventing the removal of the trash directory
261
watchman shutdown-server >/dev/null 2>&1
262
fi
263
+trace_stop
264
265
#
266
# Run a full set of perf tests with the fsmonitor feature disabled.
267
#
268
269
+trace_start fsmonitor-disabled
270
test_expect_success "setup without fsmonitor" '
271
unset INTEGRATION_SCRIPT &&
272
git config --unset core.fsmonitor &&
@@ -243,5 +274,6 @@ test_expect_success "setup without fsmonitor" '
274
'
275
276
test_fsmonitor_suite
277
+trace_stop
278
279
test_done