Skip to content

Commit 62ca75a

Browse files
avargitster
authored andcommitted
perf: add test showing exponential growth in path globbing
Add a test showing that runtimes of the wildmatch() function used for globbing in git grow exponentially in the face of some pathological globs. This issue affects both globs matching filenames via e.g. ls-files, and globs matching refnames via e.g. for-each-ref. As noted in the test description this is a test to see whether Git suffers from the issue noted in an article Russ Cox posted today about common bugs in various glob implementations: https://research.swtch.com/glob Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 91de27c commit 62ca75a

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

t/perf/p0100-globbing.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
test_description="Tests pathological globbing performance
4+
5+
Shows how Git's globbing performance performs when given the sort of
6+
pathological patterns described in at https://research.swtch.com/glob
7+
"
8+
9+
. ./perf-lib.sh
10+
11+
test_globs_big='10 25 50 75 100'
12+
test_globs_small='1 2 3 4 5 6'
13+
14+
test_perf_fresh_repo
15+
16+
test_expect_success 'setup' '
17+
for i in $(test_seq 1 100)
18+
do
19+
printf "a" >>refname &&
20+
for j in $(test_seq 1 $i)
21+
do
22+
printf "a*" >>refglob.$i
23+
done &&
24+
echo b >>refglob.$i
25+
done &&
26+
test_commit test $(cat refname).t "" $(cat refname).t
27+
'
28+
29+
for i in $test_globs_small
30+
do
31+
test_perf "refglob((a*)^nb) against tag (a^100).t; n = $i" '
32+
git for-each-ref "refs/tags/$(cat refglob.'$i')b"
33+
'
34+
done
35+
36+
for i in $test_globs_small
37+
do
38+
test_perf "fileglob((a*)^nb) against file (a^100).t; n = $i" '
39+
git ls-files "$(cat refglob.'$i')b"
40+
'
41+
done
42+
43+
test_done

0 commit comments

Comments
 (0)