Skip to content

Commit 15b79f7

Browse files
committed
core.fsyncmethod: performance tests for add and stash
Add a basic performance test for "git add" and "git stash" of a lot of new objects with various fsync settings. This shows the benefit of batch mode relative to an ordinary stash command. Signed-off-by: Neeraj Singh <neerajsi@microsoft.com>
1 parent 016aa8b commit 15b79f7

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

t/perf/p3700-add.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh
2+
#
3+
# This test measures the performance of adding new files to the object database
4+
# and index. The test was originally added to measure the effect of the
5+
# core.fsyncObjectFiles=batch mode, which is why we are testing different values
6+
# of that setting explicitly and creating a lot of unique objects.
7+
8+
test_description="Tests performance of add"
9+
10+
. ./perf-lib.sh
11+
12+
. $TEST_DIRECTORY/lib-unique-files.sh
13+
14+
test_perf_default_repo
15+
test_checkout_worktree
16+
17+
dir_count=10
18+
files_per_dir=50
19+
total_files=$((dir_count * files_per_dir))
20+
21+
# We need to create the files each time we run the perf test, but
22+
# we do not want to measure the cost of creating the files, so run
23+
# the test once.
24+
if test "${GIT_PERF_REPEAT_COUNT-1}" -ne 1
25+
then
26+
echo "warning: Setting GIT_PERF_REPEAT_COUNT=1" >&2
27+
GIT_PERF_REPEAT_COUNT=1
28+
fi
29+
30+
for m in false true batch
31+
do
32+
test_expect_success "create the files for object_fsyncing=$m" '
33+
git reset --hard &&
34+
# create files across directories
35+
test_create_unique_files $dir_count $files_per_dir files
36+
'
37+
38+
case $m in
39+
false)
40+
FSYNC_CONFIG='-c core.fsync=default,-loose-object -c core.fsyncmethod=fsync'
41+
;;
42+
true)
43+
FSYNC_CONFIG='-c core.fsync=default,loose-object -c core.fsyncmethod=fsync'
44+
;;
45+
batch)
46+
FSYNC_CONFIG='-c core.fsync=default,loose-object -c core.fsyncmethod=batch'
47+
;;
48+
esac
49+
50+
test_perf "add $total_files files (object_fsyncing=$m)" "
51+
git $FSYNC_CONFIG add files
52+
"
53+
done
54+
55+
test_done

t/perf/p3900-stash.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/sh
2+
#
3+
# This test measures the performance of adding new files to the object database
4+
# and index. The test was originally added to measure the effect of the
5+
# core.fsyncObjectFiles=batch mode, which is why we are testing different values
6+
# of that setting explicitly and creating a lot of unique objects.
7+
8+
test_description="Tests performance of stash"
9+
10+
. ./perf-lib.sh
11+
12+
. $TEST_DIRECTORY/lib-unique-files.sh
13+
14+
test_perf_default_repo
15+
test_checkout_worktree
16+
17+
dir_count=10
18+
files_per_dir=50
19+
total_files=$((dir_count * files_per_dir))
20+
21+
# We need to create the files each time we run the perf test, but
22+
# we do not want to measure the cost of creating the files, so run
23+
# the test once.
24+
if test "${GIT_PERF_REPEAT_COUNT-1}" -ne 1
25+
then
26+
echo "warning: Setting GIT_PERF_REPEAT_COUNT=1" >&2
27+
GIT_PERF_REPEAT_COUNT=1
28+
fi
29+
30+
for m in false true batch
31+
do
32+
test_expect_success "create the files for object_fsyncing=$m" '
33+
git reset --hard &&
34+
# create files across directories
35+
test_create_unique_files $dir_count $files_per_dir files
36+
'
37+
38+
case $m in
39+
false)
40+
FSYNC_CONFIG='-c core.fsync=default,-loose-object -c core.fsyncmethod=fsync'
41+
;;
42+
true)
43+
FSYNC_CONFIG='-c core.fsync=default,loose-object -c core.fsyncmethod=fsync'
44+
;;
45+
batch)
46+
FSYNC_CONFIG='-c core.fsync=default,loose-object -c core.fsyncmethod=batch'
47+
;;
48+
esac
49+
50+
# We only stash files in the 'files' subdirectory since
51+
# the perf test infrastructure creates files in the
52+
# current working directory that need to be preserved
53+
test_perf "stash $total_files files (object_fsyncing=$m)" "
54+
git $FSYNC_CONFIG stash push -u -- files
55+
"
56+
done
57+
58+
test_done

0 commit comments

Comments
 (0)