On Mon, Mar 28, 2022 at 5:42 PM Neeraj Singh via GitGitGadget <gitgitgadget@xxxxxxxxx> wrote: > > From: Neeraj Singh <neerajsi@xxxxxxxxxxxxx> > > Add basic performance tests 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 full fsync. > > Signed-off-by: Neeraj Singh <neerajsi@xxxxxxxxxxxxx> > --- > t/perf/p3700-add.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 59 insertions(+) > create mode 100755 t/perf/p3700-add.sh > > diff --git a/t/perf/p3700-add.sh b/t/perf/p3700-add.sh > new file mode 100755 > index 00000000000..ef6024f9897 > --- /dev/null > +++ b/t/perf/p3700-add.sh > @@ -0,0 +1,59 @@ > +#!/bin/sh > +# > +# This test measures the performance of adding new files to the object database > +# and index. The test was originally added to measure the effect of the > +# core.fsyncMethod=batch mode, which is why we are testing different values > +# of that setting explicitly and creating a lot of unique objects. > + > +test_description="Tests performance of adding things to the object database" > + > +# Fsync is normally turned off for the test suite. > +GIT_TEST_FSYNC=1 > +export GIT_TEST_FSYNC > + > +. ./perf-lib.sh > + > +. $TEST_DIRECTORY/lib-unique-files.sh > + > +test_perf_fresh_repo > +test_checkout_worktree > + > +dir_count=10 > +files_per_dir=50 > +total_files=$((dir_count * files_per_dir)) > + > +for mode in false true batch > +do > + case $mode in > + false) > + FSYNC_CONFIG='-c core.fsync=-loose-object -c core.fsyncmethod=fsync' > + ;; > + true) > + FSYNC_CONFIG='-c core.fsync=loose-object -c core.fsyncmethod=fsync' > + ;; > + batch) > + FSYNC_CONFIG='-c core.fsync=loose-object -c core.fsyncmethod=batch' > + ;; > + esac > + > + test_perf "add $total_files files (object_fsyncing=$mode)" \ > + --setup " > + (rm -rf .git || 1) && > + git init && > + test_create_unique_files $dir_count $files_per_dir files_$mode > + " " > + git $FSYNC_CONFIG add files_$mode > + " > + > + test_perf "stash $total_files files (object_fsyncing=$mode)" \ > + --setup " > + (rm -rf .git || 1) && > + git init && > + test_commit first && > + test_create_unique_files $dir_count $files_per_dir stash_files_$mode > + " " > + git $FSYNC_CONFIG stash push -u -- stash_files_$mode > + " > +done > + > +test_done > -- > gitgitgadget > Ævar suggested that it's a bit funny to have a stash test in a file named 'p3700-add.sh'. So I'm thinking that I'll move these tests to a p0008-odb-fsync.sh instead, and add a test for unpack-object and git-commit as well. I'm also going to adopt Ævar's scheme for iterating over the configs.