Skip to content

Commit fbf274a

Browse files
authored
Merge pull request simdjson#727 from simdjson/jkeiser/cmake-checkperf
Add checkperf to cmake
2 parents d94cd65 + 7556445 commit fbf274a

9 files changed

Lines changed: 111 additions & 68 deletions

File tree

.circleci/config.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ executors:
88
environment:
99
CXX: g++
1010
BUILD_FLAGS: -j
11-
CTEST_FLAGS: -j --output-on-failure
11+
CTEST_FLAGS: -j4 --output-on-failure
1212

1313
gcc8:
1414
docker:
1515
- image: gcc:8
1616
environment:
1717
CXX: g++
1818
BUILD_FLAGS: -j
19-
CTEST_FLAGS: -j --output-on-failure
19+
CTEST_FLAGS: -j4 --output-on-failure
2020

2121
gcc9:
2222
docker:
2323
- image: gcc:9
2424
environment:
2525
CXX: g++
2626
BUILD_FLAGS: -j
27-
CTEST_FLAGS: -j --output-on-failure
27+
CTEST_FLAGS: -j4 --output-on-failure
2828

2929
clang6:
3030
docker:
3131
- image: ubuntu:18.04
3232
environment:
3333
CXX: clang++-6.0
3434
BUILD_FLAGS: -j
35-
CTEST_FLAGS: -j --output-on-failure
35+
CTEST_FLAGS: -j4 --output-on-failure
3636

3737
# Reusable test commands (and initializer for clang 6)
3838
commands:
@@ -67,7 +67,7 @@ commands:
6767
steps:
6868
- cmake_build
6969
- run: ctest $CTEST_FLAGS -L acceptance
70-
- run: ctest $CTEST_FLAGS -LE acceptance
70+
- run: ctest $CTEST_FLAGS -LE acceptance -E checkperf
7171

7272
cmake_test_all:
7373
steps:
@@ -99,20 +99,15 @@ jobs:
9999
steps: [ init_clang6, cmake_test_all, cmake_install_test ]
100100

101101
# sanitize
102-
sanitize-gcc7:
103-
description: Build and run tests on GCC 7 and AVX 2 with a cmake sanitize build
104-
executor: gcc7
105-
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, BUILD_FLAGS: "" } # gcc sanitize seems to have bugs with -j :(
106-
steps: [ cmake_test_all ]
107102
sanitize-gcc9:
108103
description: Build and run tests on GCC 9 and AVX 2 with a cmake sanitize build
109104
executor: gcc9
110-
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
105+
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: -j4 --output-on-failure -E checkperf }
111106
steps: [ cmake_test_all ]
112107
sanitize-clang6:
113108
description: Build and run tests on clang 6 and AVX 2 with a cmake sanitize build
114109
executor: clang6
115-
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
110+
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON, CTEST_FLAGS: -j4 --output-on-failure -E checkperf }
116111
steps: [ init_clang6, cmake_test_all ]
117112

118113
# dynamic
@@ -181,7 +176,6 @@ workflows:
181176
- clang6
182177

183178
# full single-implementation tests
184-
- sanitize-gcc7
185179
- sanitize-gcc9
186180
- sanitize-clang6
187181
- dynamic-gcc7

.drone.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ steps:
231231
- mkdir build && cd build
232232
- cmake $CMAKE_FLAGS ..
233233
- make -j
234-
- ctest -j --output-on-failure
234+
- ctest -j4 --output-on-failure -E checkperf
235235
---
236236
kind: pipeline
237237
name: amd64_clang_cmake_no_exceptions
@@ -254,7 +254,7 @@ steps:
254254
- mkdir build && cd build
255255
- cmake $CMAKE_FLAGS ..
256256
- make -j
257-
- ctest -j --output-on-failure
257+
- ctest -j4 --output-on-failure -E checkperf
258258
---
259259
kind: pipeline
260260
name: amd64_clang_cmake_static
@@ -277,7 +277,7 @@ steps:
277277
- mkdir build && cd build
278278
- cmake $CMAKE_FLAGS ..
279279
- make -j
280-
- ctest -j --output-on-failure
280+
- ctest -j4 --output-on-failure -E checkperf
281281
---
282282
kind: pipeline
283283
name: amd64_gcc_cmake_static
@@ -300,7 +300,7 @@ steps:
300300
- mkdir build && cd build
301301
- cmake $CMAKE_FLAGS ..
302302
- make -j
303-
- ctest -j --output-on-failure
303+
- ctest -j4 --output-on-failure -E checkperf
304304
---
305305
kind: pipeline
306306
name: amd64_gcc_cmake_dynamic
@@ -323,7 +323,7 @@ steps:
323323
- mkdir build && cd build
324324
- cmake $CMAKE_FLAGS ..
325325
- make -j
326-
- ctest -j --output-on-failure
326+
- ctest -j4 --output-on-failure -E checkperf
327327
---
328328
kind: pipeline
329329
name: arm64_clang_cmake_dynamic
@@ -346,7 +346,7 @@ steps:
346346
- mkdir build && cd build
347347
- cmake $CMAKE_FLAGS ..
348348
- make -j
349-
- ctest -j --output-on-failure
349+
- ctest -j4 --output-on-failure -E checkperf
350350
---
351351
kind: pipeline
352352
name: arm64_gcc_cmake_dynamic
@@ -369,7 +369,7 @@ steps:
369369
- mkdir build && cd build
370370
- cmake $CMAKE_FLAGS ..
371371
- make -j
372-
- ctest -j --output-on-failure
372+
- ctest -j4 --output-on-failure -E checkperf
373373
---
374374
kind: pipeline
375375
name: arm64_clang_cmake_static
@@ -392,7 +392,7 @@ steps:
392392
- mkdir build && cd build
393393
- cmake $CMAKE_FLAGS ..
394394
- make -j
395-
- ctest -j --output-on-failure
395+
- ctest -j4 --output-on-failure -E checkperf
396396
---
397397
kind: pipeline
398398
name: arm64_gcc_cmake_static
@@ -415,7 +415,7 @@ steps:
415415
- mkdir build && cd build
416416
- cmake $CMAKE_FLAGS ..
417417
- make -j
418-
- ctest -j --output-on-failure
418+
- ctest -j4 --output-on-failure -E checkperf
419419

420420
---
421421
kind: pipeline
@@ -439,7 +439,7 @@ steps:
439439
- mkdir build && cd build
440440
- cmake $CMAKE_FLAGS ..
441441
- make -j
442-
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
442+
- ASAN_OPTIONS="detect_leaks=0" ctest -j4 --output-on-failure -E checkperf
443443
---
444444
kind: pipeline
445445
name: arm64_gcc_cmake_sanitize
@@ -462,7 +462,7 @@ steps:
462462
- mkdir build && cd build
463463
- cmake $CMAKE_FLAGS ..
464464
- make -j
465-
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
465+
- ASAN_OPTIONS="detect_leaks=0" ctest -j4 --output-on-failure -E checkperf
466466

467467
---
468468
kind: pipeline
@@ -486,7 +486,7 @@ steps:
486486
- mkdir build && cd build
487487
- cmake $CMAKE_FLAGS ..
488488
- make -j
489-
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
489+
- ASAN_OPTIONS="detect_leaks=0" ctest -j4 --output-on-failure -E checkperf
490490
---
491491
kind: pipeline
492492
name: amd64_gcc_cmake_sanitize
@@ -509,7 +509,7 @@ steps:
509509
- mkdir build && cd build
510510
- cmake $CMAKE_FLAGS ..
511511
- make -j
512-
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
512+
- ASAN_OPTIONS="detect_leaks=0" ctest -j4 --output-on-failure -E checkperf
513513

514514
---
515515
kind: pipeline
@@ -533,7 +533,7 @@ steps:
533533
- mkdir build && cd build
534534
- cmake $CMAKE_FLAGS ..
535535
- make -j
536-
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
536+
- ASAN_OPTIONS="detect_leaks=0" ctest -j4 --output-on-failure -E checkperf
537537
---
538538
kind: pipeline
539539
name: amd64_gcc_cmake_sanitize_noavx
@@ -556,4 +556,4 @@ steps:
556556
- mkdir build && cd build
557557
- cmake $CMAKE_FLAGS ..
558558
- make -j
559-
- ASAN_OPTIONS="detect_leaks=0" ctest -j --output-on-failure
559+
- ASAN_OPTIONS="detect_leaks=0" ctest -j4 --output-on-failure -E checkperf

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ libs
5353
objs
5454

5555
# Build outputs (TODO build to a subdir so we can exclude that instead)
56+
/.simdjson-user-CMakeCache.txt
5657
/allparserscheckfile
5758
/allparsingcompetition
5859
/basictests
@@ -71,6 +72,7 @@ objs
7172
/benchmark/parse_stream
7273
/benchmark/parsingcompetition
7374
/benchmark/perfdiff
75+
/benchmark/simdjson-master
7476
/benchmark/statisticalmodel
7577
/build/
7678
/build-ossfuzz-*/
@@ -123,14 +125,15 @@ objs
123125
/stringparsingcheck
124126
/submodules
125127
/ujdecode.o
126-
/amalgamation_demo.cpp
128+
/amalgamate_demo.cpp
127129
/simdjson.cpp
128130
/simdjson.h
129-
/singleheader/amalgamation_demo
131+
/singleheader/amalgamate_demo
130132
/singleheader/demo
131133
/tests/allparserscheckfile
132134
/tests/basictests
133135
/tests/checkimplementation
136+
/tests/compilation_failure_tests/example_compiletest_should_compile
134137
/tests/errortests
135138
/tests/extracting_values_example
136139
/tests/integer_tests

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ set(PROJECT_VERSION_MINOR 3)
1717
set(PROJECT_VERSION_PATCH 1)
1818
set(SIMDJSON_LIB_VERSION "0.3.1" CACHE STRING "simdjson library version")
1919
set(SIMDJSON_LIB_SOVERSION "1" CACHE STRING "simdjson library soversion")
20+
set(SIMDJSON_GITHUB_REPOSITORY https://github.com/simdjson/simdjson)
2021

2122
if(MSVC)
2223
option(SIMDJSON_BUILD_STATIC "Build a static library" ON) # turning it on disables the production of a dynamic library
@@ -120,6 +121,23 @@ endfunction()
120121

121122
export_private_library(simdjson-flags)
122123

124+
#
125+
# ${SIMDJSON_USER_CMAKECACHE} contains the *user-specified* simdjson options so you can call cmake on
126+
# another branch or repository with the same options.
127+
#
128+
# Not supported on Windows at present, because the only thing that uses it is checkperf, which we
129+
# don't run on Windows.
130+
#
131+
if (NOT MSVC)
132+
set(SIMDJSON_USER_CMAKECACHE ${CMAKE_CURRENT_BINARY_DIR}/.simdjson-user-CMakeCache.txt)
133+
add_custom_command(
134+
OUTPUT ${SIMDJSON_USER_CMAKECACHE}
135+
COMMAND bash -c "grep SIMDJSON_ ${PROJECT_BINARY_DIR}/CMakeCache.txt | grep -v SIMDJSON_LIB_ > ${SIMDJSON_USER_CMAKECACHE}"
136+
VERBATIM # Makes it not do weird escaping with the command
137+
)
138+
add_custom_target(simdjson-user-cmakecache ALL DEPENDS ${SIMDJSON_USER_CMAKECACHE})
139+
endif()
140+
123141
#
124142
# Create the top level simdjson library (must be done at this level to use both src/ and include/
125143
# directories) and tools

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
REFERENCE_VERSION = master
1+
CHECKPERF_BRANCH = master
22

33
.SUFFIXES:
44
#
@@ -207,8 +207,8 @@ benchfeatures: benchmark/benchfeatures.cpp benchmark/event_counter.h benchmark/b
207207
perfdiff: benchmark/perfdiff.cpp
208208
$(CXX) $(CXXFLAGS) -o perfdiff benchmark/perfdiff.cpp $(LIBFILES) $(LIBFLAGS)
209209

210-
checkperf:
211-
bash ./scripts/checkperf.sh $(REFERENCE_VERSION)
210+
checkperf: parse perfdiff
211+
CHECKPERF_BRANCH=$(CHECKPERF_BRANCH) bash ./benchmark/checkperf.sh jsonexamples/twitter.json
212212

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

benchmark/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ if (SIMDJSON_COMPETITION)
3434
target_link_libraries(allparsingcompetition competition-all)
3535
target_compile_definitions(allparsingcompetition PRIVATE ALLPARSER)
3636
endif()
37+
38+
if (NOT MSVC)
39+
add_test(NAME checkperf
40+
COMMAND ${CMAKE_COMMAND} -E env
41+
CHECKPERF_REPOSITORY=https://github.com/simdjson/simdjson
42+
CHECKPERF_BRANCH=master
43+
CHECKPERF_DIR=${CMAKE_CURRENT_BINARY_DIR}/simdjson-master
44+
CHECKPERF_CMAKECACHE=${SIMDJSON_USER_CMAKECACHE}
45+
bash ${CMAKE_CURRENT_SOURCE_DIR}/checkperf.sh ${PROJECT_SOURCE_DIR}/jsonexamples/twitter.json)
46+
set_property(TEST checkperf APPEND PROPERTY LABELS per_implementation)
47+
set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${SIMDJSON_USER_CMAKECACHE})
48+
set_property(TEST checkperf PROPERTY RUN_SERIAL TRUE)
49+
endif()

benchmark/checkperf.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
set | grep CHECKPERF
6+
7+
if [ -z "$CHECKPERF_REPOSITORY" ]; then CHECKPERF_REPOSITORY=.; fi
8+
9+
# Arguments: perfdiff.sh <branch> <test json files>
10+
if [ -z "$CHECKPERF_BRANCH" ]; then CHECKPERF_BRANCH=master; fi
11+
if [ -z "$CHECKPERF_DIR" ]; then CHECKPERF_DIR=benchbranch/$CHECKPERF_BRANCH; fi
12+
if [ -z "$CHECKPERF_ARGS" ]; then
13+
if [ -z "$*" ]; then
14+
CHECKPERF_ARGS=jsonexamples/twitter.json;
15+
else
16+
CHECKPERF_ARGS=$*;
17+
fi
18+
fi
19+
20+
# Clone and build the reference branch's parse
21+
if [ -d $CHECKPERF_DIR/.git ]; then
22+
echo "Checking out the reference branch ($CHECKPERF_BRANCH) into $CHECKPERF_DIR ..."
23+
pushd $CHECKPERF_DIR
24+
git remote update
25+
git reset --hard origin/$CHECKPERF_BRANCH
26+
else
27+
echo "Cloning the reference branch ($CHECKPERF_BRANCH) into $CHECKPERF_DIR ..."
28+
mkdir -p $CHECKPERF_DIR
29+
git clone --depth 1 -b $CHECKPERF_BRANCH $CHECKPERF_REPOSITORY $CHECKPERF_DIR
30+
pushd $CHECKPERF_DIR
31+
fi
32+
33+
echo "Building $CHECKPERF_DIR/parse ..."
34+
if [ -n "$CHECKPERF_CMAKECACHE" ]; then
35+
cp $CHECKPERF_CMAKECACHE $CHECKPERF_DIR/CMakeCache.txt
36+
cmake -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_COMPETITION=OFF .
37+
make parse
38+
REFERENCE_PARSE=$CHECKPERF_DIR/benchmark/parse
39+
else
40+
make parse
41+
REFERENCE_PARSE=$CHECKPERF_DIR/parse
42+
fi
43+
popd
44+
45+
# Run them and diff performance
46+
echo "Running perfdiff:"
47+
echo ./perfdiff \"./parse -t $CHECKPERF_ARGS\" \"$REFERENCE_PARSE -t $CHECKPERF_ARGS\"
48+
./perfdiff "./parse -t $CHECKPERF_ARGS" "$REFERENCE_PARSE -t $CHECKPERF_ARGS"

scripts/checkperf.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)