Skip to content

Commit c8d50a6

Browse files
jkeiserlemire
authored andcommitted
Make perf validation more stable, check no-AVX as well (simdjson#275)
* Compare against v0.2.1, fail only if perf is less 6 times in a row * Run AVX and no-AVX perf tests in Circle CI * Set % difference threshold to 0.2%
1 parent 6a2728e commit c8d50a6

4 files changed

Lines changed: 45 additions & 20 deletions

File tree

.circleci/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
name: Running tests (gcc)
2525
command: make quiettest amalgamate
2626

27+
- run:
28+
name: Comparing perf against reference (gcc)
29+
command: make checkperf
30+
2731
- run:
2832
name: Building (gcc, cmake, dynamic)
2933
command: |
@@ -51,6 +55,7 @@ jobs:
5155
command: |
5256
cd buildstatic
5357
make test
58+
5459
- run:
5560
name: Building (gcc, cmake, sanitize)
5661
command: |
@@ -88,6 +93,10 @@ jobs:
8893
- run:
8994
name: Running tests (gcc)
9095
command: ARCHFLAGS="-march=nehalem" make quiettest amalgamate
96+
97+
- run:
98+
name: Comparing perf against reference (gcc)
99+
command: ARCHFLAGS="-march=nehalem" make checkperf
91100

92101
- run:
93102
name: Building (gcc, cmake, dynamic)
@@ -154,6 +163,10 @@ jobs:
154163
name: Running tests (clang)
155164
command: make quiettest amalgamate
156165

166+
- run:
167+
name: Comparing perf against reference (clang)
168+
command: make checkperf
169+
157170
- run:
158171
name: Building (clang, cmake, dynamic)
159172
command: |
@@ -220,6 +233,10 @@ jobs:
220233
name: Running tests (clang)
221234
command: ARCHFLAGS="-march=nehalem" make quiettest amalgamate
222235

236+
- run:
237+
name: Comparing perf against reference (clang)
238+
command: ARCHFLAGS="-march=nehalem" make checkperf
239+
223240
- run:
224241
name: Building (clang, cmake, dynamic)
225242
command: |

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
REFERENCE_VERSION = v0.2.1
12

23
.SUFFIXES:
34
#
@@ -127,7 +128,7 @@ perfdiff: benchmark/perfdiff.cpp
127128
$(CXX) $(CXXFLAGS) -o perfdiff benchmark/perfdiff.cpp $(LIBFLAGS)
128129

129130
checkperf:
130-
bash ./scripts/checkperf.sh
131+
bash ./scripts/checkperf.sh $(REFERENCE_VERSION)
131132

132133
statisticalmodel: benchmark/statisticalmodel.cpp $(HEADERS) $(LIBFILES)
133134
$(CXX) $(CXXFLAGS) -o statisticalmodel $(LIBFILES) benchmark/statisticalmodel.cpp $(LIBFLAGS)

benchmark/perfdiff.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,37 @@ double readThroughput(std::string parseOutput) {
4444
return result / numResults;
4545
}
4646

47-
const double ERROR_MARGIN = 10; // 10%
48-
const double INTERLEAVED_ATTEMPTS = 4;
47+
const double INTERLEAVED_ATTEMPTS = 6;
48+
const double PERCENT_DIFFERENCE_THRESHOLD = -0.2;
4949

5050
int main(int argc, char *argv[]) {
5151
if (argc != 3) {
52-
std::cerr << "Usage: " << argv[0] << " <new parse cmd> <reference parse cmd>";
52+
std::cerr << "Usage: " << argv[0] << " <new parse cmd> <reference parse cmd>" << std::endl;
5353
return 1;
5454
}
55-
double newThroughput = 0;
56-
double referenceThroughput = 0;
5755
for (int attempt=0; attempt < INTERLEAVED_ATTEMPTS; attempt++) {
58-
newThroughput += readThroughput(exec(argv[1]));
59-
referenceThroughput += readThroughput(exec(argv[2]));
60-
}
61-
newThroughput /= INTERLEAVED_ATTEMPTS;
62-
referenceThroughput /= INTERLEAVED_ATTEMPTS;
56+
if (attempt > 0) {
57+
std::cout << "Running again to check whether it's a fluke ..." << std::endl;
58+
}
59+
std::cout << "Attempt #" << (attempt+1) << " of up to " << INTERLEAVED_ATTEMPTS << std::endl;
6360

64-
std::cout << "New throughput: " << newThroughput << std::endl;
65-
std::cout << "Ref throughput: " << referenceThroughput << std::endl;
66-
double percentDifference = ((newThroughput / referenceThroughput) - 1.0) * 100;
67-
std::cout << "Difference: " << percentDifference << "%" << std::endl;
68-
if (percentDifference < -ERROR_MARGIN) {
69-
std::cerr << "New throughput is more than " << ERROR_MARGIN << "% degraded from reference throughput!" << std::endl;
70-
return 1;
61+
// Read new throughput
62+
double newThroughput = readThroughput(exec(argv[1]));
63+
std::cout << "New throughput: " << newThroughput << std::endl;
64+
65+
// Read reference throughput
66+
double referenceThroughput = readThroughput(exec(argv[2]));
67+
std::cout << "Ref throughput: " << referenceThroughput << std::endl;
68+
69+
// Check if % difference > 0
70+
double percentDifference = ((newThroughput / referenceThroughput) - 1.0) * 100;
71+
std::cout << "Difference: " << percentDifference << "%" << std::endl;
72+
if (percentDifference >= PERCENT_DIFFERENCE_THRESHOLD) {
73+
std::cout << "New throughput is same or better." << std::endl;
74+
return 0;
75+
} else {
76+
std::cout << "New throughput is lower!";
77+
}
7178
}
72-
return 0;
79+
return 1;
7380
}

scripts/checkperf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if [ -z "$*" ]; then perftests="jsonexamples/twitter.json"; else perftests=$*; f
99

1010
# Clone and build the reference branch's parse
1111
echo "Cloning and build the reference branch ($reference_branch) ..."
12+
current=$SCRIPTPATH/..
1213
reference=$current/benchbranch/$reference_branch
1314
rm -rf $reference
1415
mkdir -p $reference
@@ -18,7 +19,6 @@ make parse
1819

1920
# Build the current branch's parse
2021
echo "Building the current branch ..."
21-
current=$SCRIPTPATH/..
2222
cd $current
2323
make clean
2424
make parse

0 commit comments

Comments
 (0)