Skip to content

Commit 4f2009d

Browse files
jeffhostetlergitster
authored andcommitted
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 <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a7556c3 commit 4f2009d

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

t/perf/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/build/
22
/test-results/
3+
/test-trace/
34
/trash directory*/

t/perf/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ perf: pre-clean
77
./run
88

99
pre-clean:
10-
rm -rf test-results
10+
rm -rf test-results test-trace
1111

1212
clean:
13-
rm -rf build "trash directory".* test-results
13+
rm -rf build "trash directory".* test-results test-trace
1414

1515
test-lint:
1616
$(MAKE) -C .. test-lint

t/perf/p7519-fsmonitor.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ test_description="Test core.fsmonitor"
3232
#
3333
# GIT_PERF_7519_DROP_CACHE: if set, the OS caches are dropped between tests
3434
#
35+
# GIT_PERF_7519_TRACE: if set, enable trace logging during the test.
36+
# Trace logs will be grouped by fsmonitor provider.
3537

3638
test_perf_large_repo
3739
test_checkout_worktree
@@ -70,6 +72,32 @@ then
7072
fi
7173
fi
7274

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+
73101
test_expect_success "one time repo setup" '
74102
# set untrackedCache depending on the environment
75103
if test -n "$GIT_PERF_7519_UNTRACKED_CACHE"
@@ -213,6 +241,7 @@ test_fsmonitor_suite() {
213241
# such as Watchman.
214242
#
215243

244+
trace_start fsmonitor-watchman
216245
if test -n "$GIT_PERF_7519_FSMONITOR"; then
217246
for INTEGRATION_PATH in $GIT_PERF_7519_FSMONITOR; do
218247
test_expect_success "setup for fsmonitor $INTEGRATION_PATH" 'setup_for_fsmonitor'
@@ -231,17 +260,20 @@ then
231260
# preventing the removal of the trash directory
232261
watchman shutdown-server >/dev/null 2>&1
233262
fi
263+
trace_stop
234264

235265
#
236266
# Run a full set of perf tests with the fsmonitor feature disabled.
237267
#
238268

269+
trace_start fsmonitor-disabled
239270
test_expect_success "setup without fsmonitor" '
240271
unset INTEGRATION_SCRIPT &&
241272
git config --unset core.fsmonitor &&
242273
git update-index --no-fsmonitor
243274
'
244275

245276
test_fsmonitor_suite
277+
trace_stop
246278

247279
test_done

0 commit comments

Comments
 (0)