@matheusbsbs / matheus-bagliano / commits / 218389b9f3
Fork 0

p5302: count up to online-cpus for thread tests

When PERF_EXTRA is enabled, p5302 checks the performance of index-pack with various numbers of threads. This can be useful for deciding what the default should be (which is currently capped at 3 threads based on the results of this script). However, we only go up to 8 threads, and modern machines may have more. Let's get the number of CPUs from test-tool, and test various numbers of threads between one and that maximum. Note that the current tests aren't all identical, as we have to set GIT_FORCE_THREADS for the --threads=1 test (which measures the overhead of starting a single worker thread versus the "0" case of using the main thread). To keep the loop simple, we'll keep the "0" case out of it, and set GIT_FORCE_THREADS=1 for all of the other cases (it's a noop for all but the "1" case, since numbers higher than 1 would always need threads). Note also that we could skip running "test-tool" if PERF_EXTRA isn't set. However, there's some small value in knowing the number of threads, so that we can mark each test as skipped in the output. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 21, 2020 at 13:54 UTC 218389b9f3d1b5c8583cc0e944692f7c66af8a03
1 file changed +24 -23
t/perf/p5302-pack-index.sh
+24 -23
@@ -13,35 +13,36 @@ test_expect_success 'repack' '
13 export PACK
14 '
15
16 -test_perf PERF_EXTRA '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
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
27 '
28
22 -test_perf PERF_EXTRA '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
26 -'
27 -
28 -test_perf PERF_EXTRA 'index-pack 2 threads' '
29 - rm -rf repo.git &&
30 - git init --bare repo.git &&
31 - GIT_DIR=repo.git git index-pack --threads=2 --stdin < $PACK
32 -'
33 -
34 -test_perf PERF_EXTRA 'index-pack 4 threads' '
29 +test_perf PERF_EXTRA 'index-pack 0 threads' '
30 rm -rf repo.git &&
31 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
33 '
34
40 -test_perf PERF_EXTRA '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
46
47 test_perf 'index-pack default number of threads' '
48 rm -rf repo.git &&