Skip to content

Commit 1ba1384

Browse files
author
drh
committed
Update JSON performance testing procedures for clarity and to describe how to
do performance testing of JSONB. FossilOrigin-Name: b115b4f75bc7c4e6d9bab5edf13297f27a36f30083c80d2c502b01208da5dfc0
1 parent f537bba commit 1ba1384

5 files changed

Lines changed: 59 additions & 40 deletions

File tree

manifest

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
C Update\sextension\sext/misc/totext.c\sto\savoid\sboth\subsan\swarnings\sand\sdubious\sreal->integer\sconversions.
2-
D 2024-01-06T13:58:54.947
1+
C Update\sJSON\sperformance\stesting\sprocedures\sfor\sclarity\sand\sto\sdescribe\show\sto\ndo\sperformance\stesting\sof\sJSONB.
2+
D 2024-01-06T15:22:16.679
33
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
44
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
55
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -1330,11 +1330,11 @@ F test/journal3.test 7c3cf23ffc77db06601c1fcfc9743de8441cb77db9d1aa931863d94f5ff
13301330
F test/jrnlmode.test 9b5bc01dac22223cb60ec2d5f97acf568d73820794386de5634dcadbea9e1946
13311331
F test/jrnlmode2.test 8759a1d4657c064637f8b079592651530db738419e1d649c6df7048cd724363d
13321332
F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa
1333-
F test/json/README.md 63e3e589e1df8fd3cc1588ba1faaff659214003f8b77a15af5c6452b35e30ee2
1333+
F test/json/README.md de59d5ba0bd2796d797115688630a6405bbf43a2891bad445ac6b9f38b83f236
13341334
F test/json/json-generator.tcl dc0dd0f393800c98658fc4c47eaa6af29d4e17527380cd28656fb261bddc8a3f
1335-
F test/json/json-q1-b.txt 1e180fe6491efab307e318b22879e3a736ac9a96539bbde7911a13ee5b33abc7
13361335
F test/json/json-q1.txt 65f9d1cdcc4cffa9823fb73ed936aae5658700cd001fde448f68bfb91c807307
1337-
F test/json/json-speed-check.sh b060a9a6c696c0a807d8929400fa11bd7113edc58b0d66b9795f424f8d0db326 x
1336+
F test/json/json-speed-check.sh 912ee03e700a65c827ee0c7b4752c21ec5ef69cf7679d2f482ca817042bead52 x
1337+
F test/json/jsonb-q1.txt 1e180fe6491efab307e318b22879e3a736ac9a96539bbde7911a13ee5b33abc7 w test/json/json-q1-b.txt
13381338
F test/json101.test 70587d7d35ef9e2126364ba70f0c951f70827cfbd28649d779ff3df7e8f87547
13391339
F test/json102.test 557a46e16df1aa9bdbc4076a71a45814ea0e7503d6621d87d42a8c04cbc2b0ef
13401340
F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe
@@ -2156,9 +2156,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
21562156
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
21572157
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
21582158
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
2159-
P 8940e2a1054fbc19fae3f76e743d744840c3a5aad001be8d3d56ca134226c34b c626aa108a7a30cef54af8d93ac9e45749568ed38e4e06623a6bad6b4bf6e8ec
2160-
R a29b7304699ca19c7db12a157b970ee6
2161-
T +closed c626aa108a7a30cef54af8d93ac9e45749568ed38e4e06623a6bad6b4bf6e8ec
2162-
U dan
2163-
Z 28d29fe86f310229597cb641cf92c44b
2159+
P 541436004df6458dc2f38bdfa421099f78cab397f5f4795ca5f227531aaa6a3e
2160+
R c74cb5aaebf0a262676ed62bd81f26fe
2161+
U drh
2162+
Z 94bd0ff810d06e79fd9f6572dcfe8940
21642163
# Remove this line to create a well-formed Fossil manifest.

manifest.uuid

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
541436004df6458dc2f38bdfa421099f78cab397f5f4795ca5f227531aaa6a3e
1+
b115b4f75bc7c4e6d9bab5edf13297f27a36f30083c80d2c502b01208da5dfc0

test/json/README.md

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,63 @@ JSON inputs.
44

55
# 1.0 Prerequisites
66

7-
1. Valgrind
7+
* Standard SQLite build environment (SQLite source tree, compiler, make, etc.)
88

9-
2. Fossil
9+
* Valgrind
1010

11-
3. tclsh
11+
* Fossil (only the "fossil xdiff" command is used by this procedure)
12+
13+
* tclsh
1214

1315
# 2.0 Setup
1416

15-
1. Run: "`tclsh json-generator.tcl | sqlite3 json100mb.db`" to create
17+
* Run: "`tclsh json-generator.tcl | sqlite3 json100mb.db`" to create
1618
the 100 megabyte test database. Do this so that the "json100mb.db"
1719
file lands in the directory from which you will run tests, not in
1820
the test/json subdirectory of the source tree.
1921

20-
2. Build the baseline sqlite3.c file with sqlite3.h and shell.c.
21-
("`CFLAGS='-Os -g' make -e clean sqlite3.c`")
22+
* Make a copy of "json100mb.db" into "jsonb100mb.db" - change the prefix
23+
from "json" to "jsonb".
24+
25+
* Bring up jsonb100mb.db in the sqlite3 command-line shell.
26+
Convert all of the content into JSONB using a commands like this:
27+
28+
> UPDATE data1 SET x=jsonb(x);
29+
> VACUUM;
30+
31+
* Build the baseline sqlite3.c file with sqlite3.h and shell.c.
32+
33+
> make clean sqlite3.c
2234
23-
3. Run "`sh json-speed-check.sh trunk`". This creates the baseline
24-
profile in "jout-trunk.txt".
35+
* Run "`sh json-speed-check.sh trunk`". This creates the baseline
36+
profile in "jout-trunk.txt" for the preformance test using text JSON.
37+
38+
* Run "`sh json-speed-check.sh trunk --jsonb`". This creates the
39+
baseline profile in "joutb-trunk.txt" for the performance test
40+
for processing JSONB
41+
42+
* (Optional) Verify that the json100mb.db database really does contain
43+
approximately 100MB of JSON content by running:
44+
45+
> SELECT sum(length(x)) FROM data1;
46+
> SELECT * FROM data1 WHERE NOT json_valid(x);
2547
2648
# 3.0 Testing
2749

28-
1. Build the sqlite3.c (with sqlite3.h and shell.c) to be tested.
50+
* Build the sqlite3.c (with sqlite3.h and shell.c) to be tested.
2951

30-
2. Run "`sh json-speed-check.sh x1`". The profile output will appear
52+
* Run "`sh json-speed-check.sh x1`". The profile output will appear
3153
in jout-x1.txt. Substitute any label you want in place of "x1".
3254

33-
3. Run the script shown below in the CLI.
55+
* Run "`sh json-speed-check.sh x1 --jsonb`". The profile output will appear
56+
in joutb-x1.txt. Substitute any label you want in place of "x1".
57+
58+
* Run the script shown below in the CLI.
3459
Divide 2500 by the real elapse time from this test
3560
to get an estimate for number of MB/s that the JSON parser is
3661
able to process.
3762

38-
> ~~~~
39-
.open json100mb.db
40-
.timer on
41-
WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<25)
42-
SELECT sum(json_valid(x)) FROM c, data1;
43-
~~~~
63+
> .open json100mb.db
64+
> .timer on
65+
> WITH RECURSIVE c(n) AS (VALUES(1) UNION ALL SELECT n+1 FROM c WHERE n<25)
66+
> SELECT sum(json_valid(x)) FROM c, data1;

test/json/json-speed-check.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_PROGRESS_CALLBACK"
3535
LEAN_OPTS="$LEAN_OPTS -DSQLITE_OMIT_SHARED_CACHE"
3636
LEAN_OPTS="$LEAN_OPTS -DSQLITE_USE_ALLOCA"
3737
BASELINE="trunk"
38+
TYPE="json"
3839
doExplain=0
3940
doCachegrind=1
4041
doVdbeProfile=0
@@ -57,6 +58,7 @@ while test "$1" != ""; do
5758
;;
5859
--jsonb)
5960
doJsonB=1
61+
TYPE="jsonb"
6062
;;
6163
-*)
6264
CC_OPTS="$CC_OPTS $1"
@@ -73,18 +75,13 @@ rm -f cachegrind.out.* jsonshell
7375
$CC -g -Os -Wall -I. $CC_OPTS ./shell.c ./sqlite3.c -o jsonshell -ldl -lpthread
7476
ls -l jsonshell | tee -a summary-$NAME.txt
7577
home=`echo $0 | sed -e 's,/[^/]*$,,'`
76-
if test $doJsonB -eq 1; then
77-
echo ./jsonshell json100mb_b.db "<$home/json-q1-b.txt"
78-
valgrind --tool=cachegrind ./jsonshell json100mb_b.db <$home/json-q1-b.txt \
78+
DB=$TYPE''100mb.db
79+
echo ./jsonshell $DB "<$home/$TYPE-q1.txt"
80+
valgrind --tool=cachegrind ./jsonshell json100mb_b.db <$home/$TYPE-q1.txt \
7981
2>&1 | tee -a summary-$NAME.txt
80-
else
81-
echo ./jsonshell json100mb.db "<$home/json-q1.txt"
82-
valgrind --tool=cachegrind ./jsonshell json100mb.db <$home/json-q1.txt \
83-
2>&1 | tee -a summary-$NAME.txt
84-
fi
85-
cg_anno.tcl cachegrind.out.* >jout-$NAME.txt
86-
echo '*****************************************************' >>jout-$NAME.txt
87-
sed 's/^[0-9=-]\{9\}/==00000==/' summary-$NAME.txt >>jout-$NAME.txt
82+
cg_anno.tcl cachegrind.out.* >$TYPE-$NAME.txt
83+
echo '*****************************************************' >>$TYPE-$NAME.txt
84+
sed 's/^[0-9=-]\{9\}/==00000==/' summary-$NAME.txt >>$TYPE-$NAME.txt
8885
if test "$NAME" != "$BASELINE" -a $doDiff -ne 0; then
89-
fossil xdiff --tk -c 20 jout-$BASELINE.txt jout-$NAME.txt
86+
fossil xdiff --tk -c 20 $TYPE-$BASELINE.txt $TYPE-$NAME.txt
9087
fi

0 commit comments

Comments
 (0)