Skip to content

Commit 53015c9

Browse files
committed
Merge branch 'jk/index-pack-w-more-threads'
Long ago, we decided to use 3 threads by default when running the index-pack task in parallel, which has been adjusted a bit upwards. * jk/index-pack-w-more-threads: index-pack: adjust default threading cap p5302: count up to online-cpus for thread tests p5302: disable thread-count parameter tests by default
2 parents e177238 + fbff95b commit 53015c9

File tree

4 files changed

+51
-26
lines changed

4 files changed

+51
-26
lines changed

builtin/index-pack.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,9 +1798,22 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
17981798

17991799
if (HAVE_THREADS && !nr_threads) {
18001800
nr_threads = online_cpus();
1801-
/* An experiment showed that more threads does not mean faster */
1802-
if (nr_threads > 3)
1803-
nr_threads = 3;
1801+
/*
1802+
* Experiments show that going above 20 threads doesn't help,
1803+
* no matter how many cores you have. Below that, we tend to
1804+
* max at half the number of online_cpus(), presumably because
1805+
* half of those are hyperthreads rather than full cores. We'll
1806+
* never reduce the level below "3", though, to match a
1807+
* historical value that nobody complained about.
1808+
*/
1809+
if (nr_threads < 4)
1810+
; /* too few cores to consider capping */
1811+
else if (nr_threads < 6)
1812+
nr_threads = 3; /* historic cap */
1813+
else if (nr_threads < 40)
1814+
nr_threads /= 2;
1815+
else
1816+
nr_threads = 20; /* hard cap */
18041817
}
18051818

18061819
curr_pack = open_pack_file(pack_name);

t/perf/README

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ You can set the following variables (also in your config.mak):
8484
probably be about linux.git size for optimal results.
8585
Both default to the git.git you are running from.
8686

87+
GIT_PERF_EXTRA
88+
Boolean to enable additional tests. Most test scripts are
89+
written to detect regressions between two versions of Git, and
90+
the output will compare timings for individual tests between
91+
those versions. Some scripts have additional tests which are not
92+
run by default, that show patterns within a single version of
93+
Git (e.g., performance of index-pack as the number of threads
94+
changes). These can be enabled with GIT_PERF_EXTRA.
95+
8796
You can also pass the options taken by ordinary git tests; the most
8897
useful one is:
8998

t/perf/p5302-pack-index.sh

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,36 @@ test_expect_success 'repack' '
1313
export PACK
1414
'
1515

16-
test_perf 'index-pack 0 threads' '
17-
rm -rf repo.git &&
18-
git init --bare repo.git &&
19-
GIT_DIR=repo.git git index-pack --threads=1 --stdin < $PACK
20-
'
21-
22-
test_perf 'index-pack 1 thread ' '
23-
rm -rf repo.git &&
24-
git init --bare repo.git &&
25-
GIT_DIR=repo.git GIT_FORCE_THREADS=1 git index-pack --threads=1 --stdin < $PACK
16+
# Rather than counting up and doubling each time, count down from the endpoint,
17+
# halving each time. That ensures that our final test uses as many threads as
18+
# CPUs, even if it isn't a power of 2.
19+
test_expect_success 'set up thread-counting tests' '
20+
t=$(test-tool online-cpus) &&
21+
threads= &&
22+
while test $t -gt 0
23+
do
24+
threads="$t $threads"
25+
t=$((t / 2))
26+
done
2627
'
2728

28-
test_perf 'index-pack 2 threads' '
29+
test_perf PERF_EXTRA 'index-pack 0 threads' '
2930
rm -rf repo.git &&
3031
git init --bare repo.git &&
31-
GIT_DIR=repo.git git index-pack --threads=2 --stdin < $PACK
32-
'
33-
34-
test_perf 'index-pack 4 threads' '
35-
rm -rf repo.git &&
36-
git init --bare repo.git &&
37-
GIT_DIR=repo.git git index-pack --threads=4 --stdin < $PACK
32+
GIT_DIR=repo.git git index-pack --threads=1 --stdin < $PACK
3833
'
3934

40-
test_perf 'index-pack 8 threads' '
41-
rm -rf repo.git &&
42-
git init --bare repo.git &&
43-
GIT_DIR=repo.git git index-pack --threads=8 --stdin < $PACK
44-
'
35+
for t in $threads
36+
do
37+
THREADS=$t
38+
export THREADS
39+
test_perf PERF_EXTRA "index-pack $t threads" '
40+
rm -rf repo.git &&
41+
git init --bare repo.git &&
42+
GIT_DIR=repo.git GIT_FORCE_THREADS=1 \
43+
git index-pack --threads=$THREADS --stdin <$PACK
44+
'
45+
done
4546

4647
test_perf 'index-pack default number of threads' '
4748
rm -rf repo.git &&

t/perf/perf-lib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,5 @@ test_at_end_hook_ () {
245245
test_export () {
246246
export "$@"
247247
}
248+
249+
test_lazy_prereq PERF_EXTRA 'test_bool_env GIT_PERF_EXTRA false'

0 commit comments

Comments
 (0)