diff --git a/.gitignore b/.gitignore index 1b409d1d..f94335a6 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ bazel-* tpcc/profiling/ ldbc/profiling/ *.json + +# OpenStack credentials +openrc.sh diff --git a/tool/mongodb/install-driver.sh b/tool/mongodb/install-driver.sh index 8ee8e920..fd8a52a1 100755 --- a/tool/mongodb/install-driver.sh +++ b/tool/mongodb/install-driver.sh @@ -2,6 +2,8 @@ set -eu echo 'installing driver...' sudo apt update -y -sudo apt install -y python3-pip -python3 -m pip install pymongo -echo 'installing driver done' \ No newline at end of file +sudo apt install -y python3-pip python3-venv +if [ ! -x venv ]; then python3 -m venv venv; fi +. venv/bin/activate +pip install pymongo +echo 'installing driver done' diff --git a/tool/neo4j/install-driver.sh b/tool/neo4j/install-driver.sh index 5c19f012..2fd62a98 100755 --- a/tool/neo4j/install-driver.sh +++ b/tool/neo4j/install-driver.sh @@ -1,4 +1,7 @@ set -eu -sudo apt install -y python3-pip +sudo apt update -y +sudo apt install -y python3-pip python3-venv +if [ ! -x venv ]; then python3 -m venv venv; fi +. venv/bin/activate pip install neo4j diff --git a/tool/neo4j/install-server.sh b/tool/neo4j/install-server.sh index d3dc385b..4fb68b19 100755 --- a/tool/neo4j/install-server.sh +++ b/tool/neo4j/install-server.sh @@ -10,5 +10,5 @@ echo 'deb [signed-by=/etc/apt/keyrings/neotechnology.gpg] https://debian.neo4j.c sudo apt update -y sudo apt install -y neo4j=1:$SERVER_VERSION -sudo update-java-alternatives --jre --set java-1.21.0-openjdk-amd64 +# sudo update-java-alternatives --jre --set java-1.21.0-openjdk-amd64 sudo sed -i 's/#dbms.security.auth_enabled=.*/dbms.security.auth_enabled=false/' /etc/neo4j/neo4j.conf diff --git a/tool/neo4j/start-server.sh b/tool/neo4j/start-server.sh index 1c8486dd..0a9ceb94 100755 --- a/tool/neo4j/start-server.sh +++ b/tool/neo4j/start-server.sh @@ -4,7 +4,7 @@ sudo nohup neo4j start >&/dev/null & # wait until ready set +e -POLL_INTERVAL_SECS=0.5 +POLL_INTERVAL_SECS=1 RETRY_NUM=20 while [[ $RETRY_NUM -gt 0 ]]; do lsof -i :7687 > /dev/null diff --git a/tool/ovh/clone-repo.sh b/tool/ovh/clone-repo.sh new file mode 100755 index 00000000..901235ea --- /dev/null +++ b/tool/ovh/clone-repo.sh @@ -0,0 +1,7 @@ +set -eu + +tool/ovh/ssh-exec.sh "'git clone https://github.com/typedb/typedb-benchmark.git'" +if [ $# -eq 1 ]; then + REF=$1 + tool/ovh/ssh-exec.sh "'cd typedb-benchmark && git fetch origin $REF && git checkout $REF'" +fi diff --git a/tool/ovh/create.sh b/tool/ovh/create.sh new file mode 100755 index 00000000..1b9cd71c --- /dev/null +++ b/tool/ovh/create.sh @@ -0,0 +1,12 @@ +set -eu + +openstack server create "$MACHINE_NAME" \ + --key-name "$OS_KEY_ID" \ + --flavor "$MACHINE_TYPE" \ + --image "$IMAGE" \ + --network Ext-Net + +for _ in `seq 60`; do + STATUS=$(openstack server show "$MACHINE_NAME" |& grep '\bstatus' | awk '{print $4}') + if [[ $STATUS == "ACTIVE" ]]; then break; fi +done diff --git a/tool/ovh/download-result.sh b/tool/ovh/download-result.sh new file mode 100755 index 00000000..767aa3ba --- /dev/null +++ b/tool/ovh/download-result.sh @@ -0,0 +1,6 @@ +openstack server ssh $MACHINE_NAME -4 --address-type Ext-Net -- -i $OS_PRIVATE_KEY -l ubuntu -o StrictHostKeychecking=no "cat ~/typedb-benchmark/results.log" > result-$MACHINE_NAME.log +# resolve typedb folder using glob '*', as there's exactly one typedb folder +if [[ $DB =~ typedb ]]; then + openstack server ssh $MACHINE_NAME -4 --address-type Ext-Net -- -i $OS_PRIVATE_KEY -l ubuntu -o StrictHostKeychecking=no "cat ~/typedb-benchmark/typedb-all-linux-x86_64-*/log" > result-$MACHINE_NAME-server.log +fi + diff --git a/tool/ovh/profile.sh b/tool/ovh/profile.sh new file mode 100755 index 00000000..2ff70577 --- /dev/null +++ b/tool/ovh/profile.sh @@ -0,0 +1,45 @@ +set -eu + +# TPCC config +DB=${DB:-typedb3} +source tool/$DB/config.sh # export the DB server and driver version +SCALE_FACTOR=${SCALE_FACTOR:-1} # 0.5, 1 +WAREHOUSES=${WAREHOUSES:-1} # 1, 5, 10, --- 100, 300, 500, 1000 +CLIENTS=${CLIENTS:-1} # 4, 8, 16, 32, 48, 64 +DURATION=${DURATION:-600} + +# machine config +MACHINE_TYPE=b2-15 + +# cloud provider config +if [ ! -v OS_TENANT_ID -o ! -v OS_TENANT_NAME ]; then + echo "OS_TENANT_ID and OS_TENANT_NAME must be set; download and source openrc.sh" + exit 1 +fi + +if [ ! -v OS_USERNAME -o ! -v OS_PASSWORD ]; then + echo "OS_USERNAME and OS_PASSWORD must be set; download and source openrc.sh" + exit 1 +fi + +if [ ! -v OS_KEY_ID -o ! -v OS_PRIVATE_KEY ]; then + echo "OS_KEY_ID and OS_PRIVATE_KEY must be set" + exit 1 +fi + +PROJECT=vaticle-engineers +ZONE=europe-west2-c +IMAGE="Ubuntu 24.10" +IMAGE_PROJECT=vaticle-factory-prod + +# four digit random number with zero padding +ID=0000$RANDOM +ID=${ID:(-4)} + +# extrapolation +DB_SHORT="${DB:0:1}${DB: -1}" +SERVER_VERSION_SHORT=${SERVER_VERSION:0:4} +SERVER_VERSION_SHORT=${SERVER_VERSION_SHORT//\./-} # replace '.'s in version with hyphens +DRIVER_VERSION_SHORT="eac3" # TODO: update according to DRIVER_VERSION +BENCH_ID=$USER-$DB_SHORT-$SERVER_VERSION_SHORT-$DRIVER_VERSION_SHORT-$MACHINE_TYPE-sf$SCALE_FACTOR-w$WAREHOUSES-c$CLIENTS-dur$DURATION-$ID +MACHINE_NAME=$BENCH_ID diff --git a/tool/ovh/ssh-exec.sh b/tool/ovh/ssh-exec.sh new file mode 100755 index 00000000..431b18b3 --- /dev/null +++ b/tool/ovh/ssh-exec.sh @@ -0,0 +1,3 @@ +set -eu + +openstack server ssh $MACHINE_NAME -4 --address-type Ext-Net -- -i $OS_PRIVATE_KEY -l ubuntu -o StrictHostKeychecking=no "$@" diff --git a/tool/ovh/ssh.sh b/tool/ovh/ssh.sh new file mode 100755 index 00000000..244abab9 --- /dev/null +++ b/tool/ovh/ssh.sh @@ -0,0 +1,3 @@ +set -eu + +openstack server ssh $MACHINE_NAME -4 --address-type Ext-Net -- -i $OS_PRIVATE_KEY -l ubuntu diff --git a/tool/ovh/tpcc.sh b/tool/ovh/tpcc.sh new file mode 100755 index 00000000..1ef76e66 --- /dev/null +++ b/tool/ovh/tpcc.sh @@ -0,0 +1,57 @@ +set -euo allexport + +usage() { + echo "Usage: $0 [-d ] [-s SCALE_FACTOR] [-w WAREHOUSES] [-c CLIENTS] [-t DURATION] [-k]" 1>&2 + echo "Default: $0 -d typedb3 -s 1 -w 1 -c 1 -t 600" 1>&2 + echo "-d DATABASE target database" + echo "-s SCALE_FACTOR benchmark scale factor" + echo "-w WAREHOUSES number of warehouses" + echo "-c CLIENTS number of clients" + echo "-t DURATION how long to run the execution portion of the benchmark (seconds)" + echo "-k keep the server instance (default: deletes)" + exit 1 +} + +KEEP_SERVER= +while getopts ":d:w:c:s:t:k" opt; do + case $opt in + d) DB="$OPTARG" ;; + s) SCALE_FACTOR="$OPTARG" ;; + w) WAREHOUSES="$OPTARG" ;; + c) CLIENTS="$OPTARG" ;; + t) DURATION="$OPTARG" ;; + k) KEEP_SERVER=1 ;; + *) usage ;; + esac +done + +source tool/ovh/profile.sh + +echo Machine name: $MACHINE_NAME + +function cleanup { + tool/ovh/download-result.sh + + if [[ -z $KEEP_SERVER ]]; then + openstack server delete $MACHINE_NAME + fi +} +trap cleanup ERR +trap cleanup EXIT + +tool/ovh/create.sh +sleep 40 +tool/ovh/clone-repo.sh $(git rev-parse HEAD) + +tool/ovh/ssh-exec.sh "'cd typedb-benchmark && tool/$DB/setup.sh'" +tool/ovh/ssh-exec.sh "'cd typedb-benchmark && tool/postgres/setup.sh'" + +tool/ovh/ssh-exec.sh "' + cd typedb-benchmark && . venv/bin/activate && + nohup tool/execute-tpcc.sh --no-execute --reset --scalefactor=$SCALE_FACTOR --warehouses=$WAREHOUSES --clients=$CLIENTS --duration=$DURATION --verify $DB & wait \$! + '" + +tool/ovh/ssh-exec.sh "' + cd typedb-benchmark && . venv/bin/activate && + nohup tool/execute-tpcc.sh --no-load --scalefactor=$SCALE_FACTOR --warehouses=$WAREHOUSES --clients=$CLIENTS --duration=$DURATION --verify $DB & wait \$! + '" diff --git a/tool/ovh/watch.sh b/tool/ovh/watch.sh new file mode 100755 index 00000000..4d327b9f --- /dev/null +++ b/tool/ovh/watch.sh @@ -0,0 +1,3 @@ +set -eu + +tool/ovh/ssh-exec.sh "tail -n +1 -F typedb-benchmark/results.log" diff --git a/tool/postgres/install-driver.sh b/tool/postgres/install-driver.sh index 600bfafc..028f58c5 100755 --- a/tool/postgres/install-driver.sh +++ b/tool/postgres/install-driver.sh @@ -2,6 +2,8 @@ set -eu echo 'installing driver...' sudo apt update -y -sudo apt install -y python3-pip +sudo apt install -y python3-pip python3-venv +if [ ! -x venv ]; then python3 -m venv venv; fi +. venv/bin/activate pip install psycopg2-binary echo 'installing driver done' diff --git a/tool/run_batched.sh b/tool/run_batched.sh new file mode 100755 index 00000000..050fadb7 --- /dev/null +++ b/tool/run_batched.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# usage: for ...; do echo cmd; done | run_batched.sh + +MAX_JOBS=8 + +while true; do + CUR_JOBS=$(jobs | wc -l) + if ((CUR_JOBS < MAX_JOBS)); then + read cmd || break + echo "$cmd" + bash -c "$cmd" & + else + sleep 60 + fi +done + +echo "scheduled all jobs" + +wait $(jobs -p) diff --git a/tool/typedb2/install-driver.sh b/tool/typedb2/install-driver.sh index d6a39f57..289bc7b8 100755 --- a/tool/typedb2/install-driver.sh +++ b/tool/typedb2/install-driver.sh @@ -3,5 +3,7 @@ set -eu source tool/typedb2/config.sh sudo apt update -y -sudo apt install -y python3-pip -pip install typedb-driver=="$DRIVER_VERSION" \ No newline at end of file +sudo apt install -y python3-pip python3-venv +if [ ! -x venv ]; then python3 -m venv venv; fi +. venv/bin/activate +pip install typedb-driver=="$DRIVER_VERSION" diff --git a/tool/typedb2/start-server.sh b/tool/typedb2/start-server.sh index 50ba7478..28f4e962 100755 --- a/tool/typedb2/start-server.sh +++ b/tool/typedb2/start-server.sh @@ -9,7 +9,7 @@ tmux new-session -d -s "typedb" "./$DISTRIBUTION_DIR/typedb server > ./$DISTRIBU # wait until ready set +e -POLL_INTERVAL_SECS=0.5 +POLL_INTERVAL_SECS=1 RETRY_NUM=20 while [[ $RETRY_NUM -gt 0 ]]; do lsof -i :1729 > /dev/null diff --git a/tool/typedb3/config.sh b/tool/typedb3/config.sh index c98f5118..b6ca64dc 100755 --- a/tool/typedb3/config.sh +++ b/tool/typedb3/config.sh @@ -1,4 +1,4 @@ set -eu -SERVER_VERSION=3.1.0 -DRIVER_VERSION=3.1.0 +SERVER_VERSION=cf3da89684083876900877bd2f95731e5ea4dceb +DRIVER_VERSION=3.4.0 diff --git a/tool/typedb3/install-driver.sh b/tool/typedb3/install-driver.sh index 6f1b29cf..4d695658 100755 --- a/tool/typedb3/install-driver.sh +++ b/tool/typedb3/install-driver.sh @@ -3,5 +3,7 @@ set -eu source tool/typedb3/config.sh sudo apt update -y -sudo apt install -y python3-pip +sudo apt install -y python3-pip python3-venv +if [ ! -x venv ]; then python3 -m venv venv; fi +. venv/bin/activate pip install typedb-driver=="$DRIVER_VERSION" --extra-index-url https://repo.typedb.com/public/public-snapshot/python/simple/ diff --git a/tool/typedb3/install-server.sh b/tool/typedb3/install-server.sh index 7a13e991..e8316f22 100755 --- a/tool/typedb3/install-server.sh +++ b/tool/typedb3/install-server.sh @@ -8,5 +8,5 @@ DISTRIBUTION_TARGZ="$DISTRIBUTION_DIR.tar.gz" DISTRIBUTION_URL_SNAPSHOT="https://repo.typedb.com/public/public-snapshot/raw/names/$DISTRIBUTION/versions/$SERVER_VERSION/$DISTRIBUTION_TARGZ" DISTRIBUTION_URL_RELEASE="https://repo.typedb.com/public/public-release/raw/names/$DISTRIBUTION/versions/$SERVER_VERSION/$DISTRIBUTION_TARGZ" -(curl -o "$DISTRIBUTION_TARGZ" "$DISTRIBUTION_URL_SNAPSHOT" && tar -xf "$DISTRIBUTION_TARGZ") || +(curl -o "$DISTRIBUTION_TARGZ" "$DISTRIBUTION_URL_SNAPSHOT" && tar -xf "$DISTRIBUTION_TARGZ" 2> /dev/null) || (curl -o "$DISTRIBUTION_TARGZ" "$DISTRIBUTION_URL_RELEASE" && tar -xf "$DISTRIBUTION_TARGZ") diff --git a/tool/typedb3/start-server.sh b/tool/typedb3/start-server.sh index 284e2c85..f23d1eee 100755 --- a/tool/typedb3/start-server.sh +++ b/tool/typedb3/start-server.sh @@ -5,12 +5,13 @@ source tool/typedb3/config.sh # start server DISTRIBUTION="typedb-all-linux-x86_64" DISTRIBUTION_DIR="$DISTRIBUTION-$SERVER_VERSION" -tmux new-session -d -s "typedb" "./$DISTRIBUTION_DIR/typedb server > ./$DISTRIBUTION_DIR/log" +ulimit -n 10240 +tmux new-session -d -s "typedb" "./$DISTRIBUTION_DIR/typedb server --diagnostics.reporting.metrics false >& ./$DISTRIBUTION_DIR/log" # wait until ready set +e -POLL_INTERVAL_SECS=0.5 -RETRY_NUM=20 +POLL_INTERVAL_SECS=1 +RETRY_NUM=120 while [[ $RETRY_NUM -gt 0 ]]; do lsof -i :1729 > /dev/null if [ $? -eq 0 ]; then exit 0; fi diff --git a/tpcc/pytpcc/drivers/mongodbdriver.py b/tpcc/pytpcc/drivers/mongodbdriver.py index 2741cd98..074cbb00 100644 --- a/tpcc/pytpcc/drivers/mongodbdriver.py +++ b/tpcc/pytpcc/drivers/mongodbdriver.py @@ -199,7 +199,7 @@ class MongodbDriver(AbstractDriver): "uri": ("The mongodb connection string or URI", "mongodb://localhost:27017"), "name": ("Database name", "tpcc"), "denormalize": ("If true, data will be denormalized using MongoDB schema design best practices", False), - "notransactions": ("If true, transactions will not be used (benchmarking only)", True), + "notransactions": ("If true, transactions will not be used (benchmarking only)", False), "findandmodify": ("If true, all things to update will be fetched via findAndModify", True), "secondary_reads": ("If true, we will allow secondary reads", True), "retry_writes": ("If true, we will enable retryable writes", True), diff --git a/tpcc/pytpcc/drivers/neo4jdriver.py b/tpcc/pytpcc/drivers/neo4jdriver.py index 43d2799b..a95a38c8 100644 --- a/tpcc/pytpcc/drivers/neo4jdriver.py +++ b/tpcc/pytpcc/drivers/neo4jdriver.py @@ -694,7 +694,6 @@ def doPayment(self, params): MATCH (c:CUSTOMER {C_ID: $c_id}) -[:BELONGS_TO]-> (:DISTRICT {D_ID: $c_d_id}) -[:BELONGS_TO]-> (:WAREHOUSE {W_ID: $c_w_id}) - -[:BELONGS_TO]-> (:DISTRICT {D_ID: $c_d_id}) MATCH (d:DISTRICT {D_ID: $d_id}) -[:BELONGS_TO]-> (w:WAREHOUSE {W_ID: $w_id}) CREATE (h:HISTORY {H_C_ID: $c_id, H_C_D_ID: $c_d_id, H_C_W_ID: $c_w_id, H_D_ID: $d_id, H_W_ID: $w_id, H_DATE: $h_date, @@ -784,4 +783,4 @@ def get_counts(self): verification += "}" return verification -## CLASS \ No newline at end of file +## CLASS