Make perf validation more stable, check no-AVX as well (#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%
This commit is contained in:
John Keiser 2019-08-15 17:43:21 -07:00 committed by Daniel Lemire
parent 6a2728e730
commit c8d50a6060
4 changed files with 45 additions and 20 deletions

View File

@ -24,6 +24,10 @@ jobs:
name: Running tests (gcc) name: Running tests (gcc)
command: make quiettest amalgamate command: make quiettest amalgamate
- run:
name: Comparing perf against reference (gcc)
command: make checkperf
- run: - run:
name: Building (gcc, cmake, dynamic) name: Building (gcc, cmake, dynamic)
command: | command: |
@ -51,6 +55,7 @@ jobs:
command: | command: |
cd buildstatic cd buildstatic
make test make test
- run: - run:
name: Building (gcc, cmake, sanitize) name: Building (gcc, cmake, sanitize)
command: | command: |
@ -89,6 +94,10 @@ jobs:
name: Running tests (gcc) name: Running tests (gcc)
command: ARCHFLAGS="-march=nehalem" make quiettest amalgamate command: ARCHFLAGS="-march=nehalem" make quiettest amalgamate
- run:
name: Comparing perf against reference (gcc)
command: ARCHFLAGS="-march=nehalem" make checkperf
- run: - run:
name: Building (gcc, cmake, dynamic) name: Building (gcc, cmake, dynamic)
command: | command: |
@ -154,6 +163,10 @@ jobs:
name: Running tests (clang) name: Running tests (clang)
command: make quiettest amalgamate command: make quiettest amalgamate
- run:
name: Comparing perf against reference (clang)
command: make checkperf
- run: - run:
name: Building (clang, cmake, dynamic) name: Building (clang, cmake, dynamic)
command: | command: |
@ -220,6 +233,10 @@ jobs:
name: Running tests (clang) name: Running tests (clang)
command: ARCHFLAGS="-march=nehalem" make quiettest amalgamate command: ARCHFLAGS="-march=nehalem" make quiettest amalgamate
- run:
name: Comparing perf against reference (clang)
command: ARCHFLAGS="-march=nehalem" make checkperf
- run: - run:
name: Building (clang, cmake, dynamic) name: Building (clang, cmake, dynamic)
command: | command: |

View File

@ -1,3 +1,4 @@
REFERENCE_VERSION = v0.2.1
.SUFFIXES: .SUFFIXES:
# #
@ -127,7 +128,7 @@ perfdiff: benchmark/perfdiff.cpp
$(CXX) $(CXXFLAGS) -o perfdiff benchmark/perfdiff.cpp $(LIBFLAGS) $(CXX) $(CXXFLAGS) -o perfdiff benchmark/perfdiff.cpp $(LIBFLAGS)
checkperf: checkperf:
bash ./scripts/checkperf.sh bash ./scripts/checkperf.sh $(REFERENCE_VERSION)
statisticalmodel: benchmark/statisticalmodel.cpp $(HEADERS) $(LIBFILES) statisticalmodel: benchmark/statisticalmodel.cpp $(HEADERS) $(LIBFILES)
$(CXX) $(CXXFLAGS) -o statisticalmodel $(LIBFILES) benchmark/statisticalmodel.cpp $(LIBFLAGS) $(CXX) $(CXXFLAGS) -o statisticalmodel $(LIBFILES) benchmark/statisticalmodel.cpp $(LIBFLAGS)

View File

@ -44,30 +44,37 @@ double readThroughput(std::string parseOutput) {
return result / numResults; return result / numResults;
} }
const double ERROR_MARGIN = 10; // 10% const double INTERLEAVED_ATTEMPTS = 6;
const double INTERLEAVED_ATTEMPTS = 4; const double PERCENT_DIFFERENCE_THRESHOLD = -0.2;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
if (argc != 3) { if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " <new parse cmd> <reference parse cmd>"; std::cerr << "Usage: " << argv[0] << " <new parse cmd> <reference parse cmd>" << std::endl;
return 1; return 1;
} }
double newThroughput = 0;
double referenceThroughput = 0;
for (int attempt=0; attempt < INTERLEAVED_ATTEMPTS; attempt++) { for (int attempt=0; attempt < INTERLEAVED_ATTEMPTS; attempt++) {
newThroughput += readThroughput(exec(argv[1])); if (attempt > 0) {
referenceThroughput += readThroughput(exec(argv[2])); std::cout << "Running again to check whether it's a fluke ..." << std::endl;
} }
newThroughput /= INTERLEAVED_ATTEMPTS; std::cout << "Attempt #" << (attempt+1) << " of up to " << INTERLEAVED_ATTEMPTS << std::endl;
referenceThroughput /= INTERLEAVED_ATTEMPTS;
// Read new throughput
double newThroughput = readThroughput(exec(argv[1]));
std::cout << "New throughput: " << newThroughput << std::endl; std::cout << "New throughput: " << newThroughput << std::endl;
// Read reference throughput
double referenceThroughput = readThroughput(exec(argv[2]));
std::cout << "Ref throughput: " << referenceThroughput << std::endl; std::cout << "Ref throughput: " << referenceThroughput << std::endl;
// Check if % difference > 0
double percentDifference = ((newThroughput / referenceThroughput) - 1.0) * 100; double percentDifference = ((newThroughput / referenceThroughput) - 1.0) * 100;
std::cout << "Difference: " << percentDifference << "%" << std::endl; std::cout << "Difference: " << percentDifference << "%" << std::endl;
if (percentDifference < -ERROR_MARGIN) { if (percentDifference >= PERCENT_DIFFERENCE_THRESHOLD) {
std::cerr << "New throughput is more than " << ERROR_MARGIN << "% degraded from reference throughput!" << std::endl; std::cout << "New throughput is same or better." << std::endl;
return 0;
} else {
std::cout << "New throughput is lower!";
}
}
return 1; return 1;
} }
return 0;
}

View File

@ -9,6 +9,7 @@ if [ -z "$*" ]; then perftests="jsonexamples/twitter.json"; else perftests=$*; f
# Clone and build the reference branch's parse # Clone and build the reference branch's parse
echo "Cloning and build the reference branch ($reference_branch) ..." echo "Cloning and build the reference branch ($reference_branch) ..."
current=$SCRIPTPATH/..
reference=$current/benchbranch/$reference_branch reference=$current/benchbranch/$reference_branch
rm -rf $reference rm -rf $reference
mkdir -p $reference mkdir -p $reference
@ -18,7 +19,6 @@ make parse
# Build the current branch's parse # Build the current branch's parse
echo "Building the current branch ..." echo "Building the current branch ..."
current=$SCRIPTPATH/..
cd $current cd $current
make clean make clean
make parse make parse