|
| 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 cfg && |
| 34 | + for method in none fsync batch writeout-only |
| 35 | + do |
| 36 | + case $method in |
| 37 | + none) |
| 38 | + cfg="-c core.fsync=none" |
| 39 | + ;; |
| 40 | + *) |
| 41 | + cfg="-c core.fsync=loose-object -c core.fsyncMethod=$method" |
| 42 | + esac && |
| 43 | + |
| 44 | + # Set GIT_TEST_FSYNC=1 explicitly since fsync is normally |
| 45 | + # disabled by t/test-lib.sh. |
| 46 | + if ! test_perf "$1 (fsyncMethod=$method)" \ |
| 47 | + --setup "$2" \ |
| 48 | + "GIT_TEST_FSYNC=1 git $cfg $3" |
| 49 | + then |
| 50 | + break |
| 51 | + fi |
| 52 | + done |
| 53 | +} |
| 54 | + |
| 55 | +test_perf_fsync_cfgs "add $total_files files" \ |
| 56 | + "setup_repo" \ |
| 57 | + "add -- files" |
| 58 | + |
| 59 | +test_perf_fsync_cfgs "stash $total_files files" \ |
| 60 | + "setup_repo" \ |
| 61 | + "stash push -u -- files" |
| 62 | + |
| 63 | +test_perf_fsync_cfgs "unpack $total_files files" \ |
| 64 | + " |
| 65 | + setup_repo && |
| 66 | + git -c core.fsync=none add -- files && |
| 67 | + git -c core.fsync=none commit -q -m second && |
| 68 | + echo HEAD | git pack-objects -q --stdout --revs >test_pack.pack && |
| 69 | + setup_repo |
| 70 | + " \ |
| 71 | + "unpack-objects -q <test_pack.pack" |
| 72 | + |
| 73 | +test_perf_fsync_cfgs "commit $total_files files" \ |
| 74 | + " |
| 75 | + setup_repo && |
| 76 | + git -c core.fsync=none add -- files && |
| 77 | + populate_files |
| 78 | + " \ |
| 79 | + "commit -q -a -m test" |
| 80 | + |
| 81 | +test_done |
0 commit comments