core.fsyncmethod: performance tests for batch mode
Add basic performance tests for git commands that can add data to the object database. We cover: * git add * git stash * git update-index (via git stash) * git unpack-objects * git commit --all We cover all currently available fsync methods as well. Signed-off-by: Neeraj Singh <neerajsi@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Neeraj Singh committed
Apr 4, 2022 at 22:20 UTC
112a9fe60d7c5f02ee1a805d8730d54a458b7ad1
1 file changed
+82
t/perf/p0008-odb-fsync.sh
new
+82
@@ -0,0 +1,82 @@
1
+#!/bin/sh
2
+#
3
+# This test measures the performance of adding new files to the object
4
+# database. The test was originally added to measure the effect of the
5
+# core.fsyncMethod=batch mode, which is why we are testing different values of
6
+# that setting explicitly and creating a lot of unique objects.
7
+
8
+test_description="Tests performance of adding things to the object database"
9
+
10
+. ./perf-lib.sh
11
+
12
+. $TEST_DIRECTORY/lib-unique-files.sh
13
+
14
+test_perf_fresh_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
+populate_files () {
22
+ test_create_unique_files $dir_count $files_per_dir files
23
+}
24
+
25
+setup_repo () {
26
+ (rm -rf .git || 1) &&
27
+ git init &&
28
+ test_commit first &&
29
+ populate_files
30
+}
31
+
32
+test_perf_fsync_cfgs () {
33
+ local method &&
34
+ local cfg &&
35
+ for method in none fsync batch writeout-only
36
+ do
37
+ case $method in
38
+ none)
39
+ cfg="-c core.fsync=none"
40
+ ;;
41
+ *)
42
+ cfg="-c core.fsync=loose-object -c core.fsyncMethod=$method"
43
+ esac &&
44
+
45
+ # Set GIT_TEST_FSYNC=1 explicitly since fsync is normally
46
+ # disabled by t/test-lib.sh.
47
+ if ! test_perf "$1 (fsyncMethod=$method)" \
48
+ --setup "$2" \
49
+ "GIT_TEST_FSYNC=1 git $cfg $3"
50
+ then
51
+ break
52
+ fi
53
+ done
54
+}
55
+
56
+test_perf_fsync_cfgs "add $total_files files" \
57
+ "setup_repo" \
58
+ "add -- files"
59
+
60
+test_perf_fsync_cfgs "stash $total_files files" \
61
+ "setup_repo" \
62
+ "stash push -u -- files"
63
+
64
+test_perf_fsync_cfgs "unpack $total_files files" \
65
+ "
66
+ setup_repo &&
67
+ git -c core.fsync=none add -- files &&
68
+ git -c core.fsync=none commit -q -m second &&
69
+ echo HEAD | git pack-objects -q --stdout --revs >test_pack.pack &&
70
+ setup_repo
71
+ " \
72
+ "unpack-objects -q <test_pack.pack"
73
+
74
+test_perf_fsync_cfgs "commit $total_files files" \
75
+ "
76
+ setup_repo &&
77
+ git -c core.fsync=none add -- files &&
78
+ populate_files
79
+ " \
80
+ "commit -q -a -m test"
81
+
82
+test_done