Skip to content

Commit cc14ba6

Browse files
committed
Merge branch 'ps/meson-build-perf-bench'
The build procedure based on Meson learned to drive the benchmarking tests. * ps/meson-build-perf-bench: meson: wire up benchmarking options meson: wire up benchmarks t/perf: fix benchmarks with out-of-tree builds t/perf: use configured PERL_PATH t/perf: fix benchmarks with alternate repo formats
2 parents b50795d + c3fc5c6 commit cc14ba6

File tree

6 files changed

+133
-14
lines changed

6 files changed

+133
-14
lines changed

meson.build

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,15 @@
7070
# # Execute single test interactively such that features like `debug ()` work.
7171
# $ meson test -i --test-args='-ix' t1400-update-ref
7272
#
73-
# Test execution is parallelized by default and scales with the number of
74-
# processor cores available. You can change the number of processes by passing
75-
# the `-jN` flag to `meson test`.
73+
# # Execute all benchmarks.
74+
# $ meson test -i --benchmark
75+
#
76+
# # Execute single benchmark.
77+
# $ meson test -i --benchmark p0000-*
78+
#
79+
# Test execution (but not benchmark execution) is parallelized by default and
80+
# scales with the number of processor cores available. You can change the
81+
# number of processes by passing the `-jN` flag to `meson test`.
7682
#
7783
# 4. Install the Git distribution. Again, this can be done via Meson, Ninja or
7884
# Samurai:
@@ -235,6 +241,7 @@ git = find_program('git', dirs: program_path, native: true, required: false)
235241
sed = find_program('sed', dirs: program_path, native: true)
236242
shell = find_program('sh', dirs: program_path, native: true)
237243
tar = find_program('tar', dirs: program_path, native: true)
244+
time = find_program('time', dirs: program_path, required: get_option('benchmarks'))
238245

239246
target_shell = find_program('sh', dirs: program_path, native: false)
240247

@@ -699,11 +706,11 @@ builtin_sources += custom_target(
699706
# build options to our tests.
700707
build_options_config = configuration_data()
701708
build_options_config.set('GIT_INTEROP_MAKE_OPTS', '')
702-
build_options_config.set('GIT_PERF_LARGE_REPO', '')
709+
build_options_config.set_quoted('GIT_PERF_LARGE_REPO', get_option('benchmark_large_repo'))
703710
build_options_config.set('GIT_PERF_MAKE_COMMAND', '')
704711
build_options_config.set('GIT_PERF_MAKE_OPTS', '')
705-
build_options_config.set('GIT_PERF_REPEAT_COUNT', '')
706-
build_options_config.set('GIT_PERF_REPO', '')
712+
build_options_config.set_quoted('GIT_PERF_REPEAT_COUNT', get_option('benchmark_repeat_count').to_string())
713+
build_options_config.set_quoted('GIT_PERF_REPO', get_option('benchmark_repo'))
707714
build_options_config.set('GIT_TEST_CMP_USE_COPIED_CONTEXT', '')
708715
build_options_config.set('GIT_TEST_INDEX_VERSION', '')
709716
build_options_config.set('GIT_TEST_OPTS', '')
@@ -836,7 +843,7 @@ endif
836843
# features. It is optional if you want to neither execute tests nor use any of
837844
# these optional features.
838845
perl_required = get_option('perl')
839-
if get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers')
846+
if get_option('benchmarks').enabled() or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers')
840847
perl_required = true
841848
endif
842849

@@ -2082,6 +2089,7 @@ meson.add_dist_script(
20822089
)
20832090

20842091
summary({
2092+
'benchmarks': get_option('tests') and perl.found() and time.found(),
20852093
'curl': curl.found(),
20862094
'expat': expat.found(),
20872095
'gettext': intl.found(),

meson_options.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ option('docs_backend', type: 'combo', choices: ['asciidoc', 'asciidoctor', 'auto
101101
description: 'Which backend to use to generate documentation.')
102102

103103
# Testing.
104+
option('benchmarks', type: 'feature', value: 'auto',
105+
description: 'Enable benchmarks. This requires Perl and GNU time.')
106+
option('benchmark_repo', type: 'string', value: '',
107+
description: 'Repository to copy for the performance tests. Should be at least the size of the Git repository.')
108+
option('benchmark_large_repo', type: 'string', value: '',
109+
description: 'Large repository to copy for the performance tests. Should be at least the size of the Linux repository.')
110+
option('benchmark_repeat_count', type: 'integer', value: 3,
111+
description: 'Number of times a test should be repeated for best-of-N measurements.')
104112
option('coccinelle', type: 'feature', value: 'auto',
105113
description: 'Provide a coccicheck target that generates a Coccinelle patch.')
106114
option('tests', type: 'boolean', value: true,

t/meson.build

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,11 +1097,71 @@ integration_tests = [
10971097
't9903-bash-prompt.sh',
10981098
]
10991099

1100+
benchmarks = [
1101+
'perf/p0000-perf-lib-sanity.sh',
1102+
'perf/p0001-rev-list.sh',
1103+
'perf/p0002-read-cache.sh',
1104+
'perf/p0003-delta-base-cache.sh',
1105+
'perf/p0004-lazy-init-name-hash.sh',
1106+
'perf/p0005-status.sh',
1107+
'perf/p0006-read-tree-checkout.sh',
1108+
'perf/p0007-write-cache.sh',
1109+
'perf/p0008-odb-fsync.sh',
1110+
'perf/p0071-sort.sh',
1111+
'perf/p0090-cache-tree.sh',
1112+
'perf/p0100-globbing.sh',
1113+
'perf/p1006-cat-file.sh',
1114+
'perf/p1400-update-ref.sh',
1115+
'perf/p1450-fsck.sh',
1116+
'perf/p1451-fsck-skip-list.sh',
1117+
'perf/p1500-graph-walks.sh',
1118+
'perf/p2000-sparse-operations.sh',
1119+
'perf/p3400-rebase.sh',
1120+
'perf/p3404-rebase-interactive.sh',
1121+
'perf/p4000-diff-algorithms.sh',
1122+
'perf/p4001-diff-no-index.sh',
1123+
'perf/p4002-diff-color-moved.sh',
1124+
'perf/p4205-log-pretty-formats.sh',
1125+
'perf/p4209-pickaxe.sh',
1126+
'perf/p4211-line-log.sh',
1127+
'perf/p4220-log-grep-engines.sh',
1128+
'perf/p4221-log-grep-engines-fixed.sh',
1129+
'perf/p5302-pack-index.sh',
1130+
'perf/p5303-many-packs.sh',
1131+
'perf/p5304-prune.sh',
1132+
'perf/p5310-pack-bitmaps.sh',
1133+
'perf/p5311-pack-bitmaps-fetch.sh',
1134+
'perf/p5312-pack-bitmaps-revs.sh',
1135+
'perf/p5313-pack-objects.sh',
1136+
'perf/p5314-name-hash.sh',
1137+
'perf/p5326-multi-pack-bitmaps.sh',
1138+
'perf/p5332-multi-pack-reuse.sh',
1139+
'perf/p5333-pseudo-merge-bitmaps.sh',
1140+
'perf/p5550-fetch-tags.sh',
1141+
'perf/p5551-fetch-rescan.sh',
1142+
'perf/p5600-partial-clone.sh',
1143+
'perf/p5601-clone-reference.sh',
1144+
'perf/p6100-describe.sh',
1145+
'perf/p6300-for-each-ref.sh',
1146+
'perf/p7000-filter-branch.sh',
1147+
'perf/p7102-reset.sh',
1148+
'perf/p7300-clean.sh',
1149+
'perf/p7519-fsmonitor.sh',
1150+
'perf/p7527-builtin-fsmonitor.sh',
1151+
'perf/p7810-grep.sh',
1152+
'perf/p7820-grep-engines.sh',
1153+
'perf/p7821-grep-engines-fixed.sh',
1154+
'perf/p7822-grep-perl-character.sh',
1155+
'perf/p9210-scalar.sh',
1156+
'perf/p9300-fast-import-export.sh',
1157+
]
1158+
11001159
# Sanity check that we are not missing any tests present in 't/'. This check
11011160
# only runs once at configure time and is thus best-effort, only. It is
11021161
# sufficient to catch missing test suites in our CI though.
11031162
foreach glob, tests : {
11041163
't[0-9][0-9][0-9][0-9]-*.sh': integration_tests,
1164+
'perf/p[0-9][0-9][0-9][0-9]-*.sh': benchmarks,
11051165
'unit-tests/t-*.c': unit_test_programs,
11061166
'unit-tests/u-*.c': clar_test_suites,
11071167
}
@@ -1153,3 +1213,20 @@ foreach integration_test : integration_tests
11531213
timeout: 0,
11541214
)
11551215
endforeach
1216+
1217+
if perl.found() and time.found()
1218+
benchmark_environment = test_environment
1219+
benchmark_environment.set('GTIME', time.full_path())
1220+
1221+
foreach benchmark : benchmarks
1222+
benchmark(fs.stem(benchmark), shell,
1223+
args: [
1224+
fs.name(benchmark),
1225+
],
1226+
workdir: meson.current_source_dir() / 'perf',
1227+
env: benchmark_environment,
1228+
depends: test_dependencies + bin_wrappers,
1229+
timeout: 0,
1230+
)
1231+
endforeach
1232+
endif

t/perf/aggregate.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/perl
1+
#!/usr/bin/env perl
22

33
use lib '../../perl/build/lib';
44
use strict;

t/perf/perf-lib.sh

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,31 @@ git_perf_settings="$(env |
3636
s/^\\([^=]*=\\)\\(.*\\)/\\1'\\2'/p
3737
}")"
3838

39-
. ../test-lib.sh
39+
# While test-lib.sh computes the build directory for us, we also have to do the
40+
# same thing in order to locate the script via GIT-BUILD-OPTIONS in the first
41+
# place.
42+
GIT_BUILD_DIR="${GIT_BUILD_DIR:-$TEST_DIRECTORY/..}"
43+
if test -f "$GIT_BUILD_DIR/GIT-BUILD-DIR"
44+
then
45+
GIT_BUILD_DIR="$(cat "$GIT_BUILD_DIR/GIT-BUILD-DIR")" || exit 1
46+
# On Windows, we must convert Windows paths lest they contain a colon
47+
case "$(uname -s)" in
48+
*MINGW*)
49+
GIT_BUILD_DIR="$(cygpath -au "$GIT_BUILD_DIR")"
50+
;;
51+
esac
52+
fi
53+
54+
if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
55+
then
56+
echo >&2 'error: GIT-BUILD-OPTIONS missing (has Git been built?).'
57+
exit 1
58+
fi
59+
60+
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
61+
. "$GIT_SOURCE_DIR"/t/test-lib.sh
62+
63+
# Then restore GIT_PERF_* settings.
4064
eval "$git_perf_settings"
4165

4266
unset GIT_CONFIG_NOSYSTEM
@@ -110,6 +134,8 @@ test_perf_create_repo_from () {
110134
source_git="$("$MODERN_GIT" -C "$source" rev-parse --git-dir)"
111135
objects_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-path objects)"
112136
common_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-common-dir)"
137+
refformat="$("$MODERN_GIT" -C "$source" rev-parse --show-ref-format)"
138+
objectformat="$("$MODERN_GIT" -C "$source" rev-parse --show-object-format)"
113139
mkdir -p "$repo/.git"
114140
(
115141
cd "$source" &&
@@ -126,7 +152,7 @@ test_perf_create_repo_from () {
126152
) &&
127153
(
128154
cd "$repo" &&
129-
"$MODERN_GIT" init -q &&
155+
"$MODERN_GIT" init -q --ref-format="$refformat" --object-format="$objectformat" &&
130156
test_perf_do_repo_symlink_config_ &&
131157
mv .git/hooks .git/hooks-disabled 2>/dev/null &&
132158
if test -f .git/index.lock
@@ -286,7 +312,7 @@ test_perf_ () {
286312
else
287313
test_ok_ "$1"
288314
fi
289-
"$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result
315+
"$PERL_PATH" "$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result
290316
rm test_time.*
291317
}
292318

@@ -334,7 +360,7 @@ test_at_end_hook_ () {
334360
if test -z "$GIT_PERF_AGGREGATING_LATER"; then
335361
(
336362
cd "$TEST_DIRECTORY"/perf &&
337-
./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0")
363+
"$PERL_PATH" "$GIT_SOURCE_DIR"/t/perf/aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0")
338364
)
339365
fi
340366
}

t/perf/run

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ run_subsection () {
192192

193193
if test -z "$GIT_PERF_SEND_TO_CODESPEED"
194194
then
195-
./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $codespeed_opt "$@"
195+
"$PERL_PATH" ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $codespeed_opt "$@"
196196
else
197197
json_res_file=""$TEST_RESULTS_DIR"/$GIT_PERF_SUBSECTION/aggregate.json"
198-
./aggregate.perl --results-dir="$TEST_RESULTS_DIR" --codespeed "$@" | tee "$json_res_file"
198+
"$PERL_PATH" ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" --codespeed "$@" | tee "$json_res_file"
199199
send_data_url="$GIT_PERF_SEND_TO_CODESPEED/result/add/json/"
200200
curl -v --request POST --data-urlencode "json=$(cat "$json_res_file")" "$send_data_url"
201201
fi

0 commit comments

Comments
 (0)