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/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/typedb3/config.sh b/tool/typedb3/config.sh index c98f5118..ce9d188b 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=3.2.0 +DRIVER_VERSION=3.2.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/start-server.sh b/tool/typedb3/start-server.sh index 284e2c85..75fb0915 100755 --- a/tool/typedb3/start-server.sh +++ b/tool/typedb3/start-server.sh @@ -5,7 +5,7 @@ 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" +tmux new-session -d -s "typedb" "./$DISTRIBUTION_DIR/typedb server --diagnostics.reporting.metrics false > ./$DISTRIBUTION_DIR/log" # wait until ready set +e diff --git a/tpcc/pytpcc/drivers/mongodbdriver.py b/tpcc/pytpcc/drivers/mongodbdriver.py index 2741cd98..597aa001 100644 --- a/tpcc/pytpcc/drivers/mongodbdriver.py +++ b/tpcc/pytpcc/drivers/mongodbdriver.py @@ -198,8 +198,8 @@ class MongodbDriver(AbstractDriver): DEFAULT_CONFIG = { "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), + "denormalize": ("If true, data will be denormalized using MongoDB schema design best practices", 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), @@ -231,7 +231,7 @@ def __init__(self, ddl, shared_event=None, worker_id=0): self.retry_writes = True self.read_concern = "majority" self.write_concern = pymongo.write_concern.WriteConcern(w=1) - self.denormalize = False + self.denormalize = True self.output = open('results.json','a') self.result_doc = {} self.warehouses = 0