Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 11 additions & 24 deletions gizmosql/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
export HOME=/home/ubuntu

# Install requirements
apt-get update -y
apt install openjdk-17-jre-headless unzip netcat-openbsd -y
sudo apt-get update -y
sudo apt-get install -y unzip netcat-openbsd

# Detect architecture (maps x86_64->amd64, aarch64->arm64)
ARCH=$(uname -m)
Expand All @@ -15,17 +15,12 @@ elif [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
fi

# Server setup Install
# Install the GizmoSQL server and client (gizmosql_client is the CLI shell) into a local directory
mkdir -p ./bin
curl -L -o gizmosql.zip "https://github.com/gizmodata/gizmosql/releases/latest/download/gizmosql_cli_linux_${ARCH}.zip"
unzip gizmosql.zip
mv gizmosql_server gizmosql_client /usr/local/bin/

# Install Java and the GizmoSQLLine CLI client
pushd /tmp
curl -L -o gizmosqlline https://github.com/gizmodata/gizmosqlline/releases/latest/download/gizmosqlline
chmod +x gizmosqlline
mv gizmosqlline /usr/local/bin/
popd
unzip -o gizmosql.zip -d ./bin
chmod +x ./bin/gizmosql_server ./bin/gizmosql_client
export PATH="$PWD/bin:$PATH"

# Source our env vars and utility functions for starting/stopping gizmosql server
. util.sh
Expand All @@ -34,21 +29,13 @@ popd
start_gizmosql

# Create the table
gizmosqlline \
-u ${GIZMOSQL_SERVER_URI} \
-n ${GIZMOSQL_USERNAME} \
-p ${GIZMOSQL_PASSWORD} \
-f create.sql
gizmosql_client --file create.sql

# Load the data
../download-hits-parquet-single

echo -n "Load time: "
time gizmosqlline \
-u ${GIZMOSQL_SERVER_URI} \
-n ${GIZMOSQL_USERNAME} \
-p ${GIZMOSQL_PASSWORD} \
-f load.sql
time gizmosql_client --file load.sql

stop_gizmosql

Expand All @@ -62,8 +49,8 @@ echo -n "Data size: "
wc -c clickbench.db

cat log.txt | \
grep -E 'rows? selected \([0-9.]+ seconds\)|Killed|Segmentation' | \
sed -E 's/.*rows? selected \(([0-9.]+) seconds\).*/\1/; s/.*(Killed|Segmentation).*/null/' | \
grep -E 'Run Time: [0-9.]+s|Killed|Segmentation' | \
sed -E 's/.*Run Time: ([0-9.]+)s.*/\1/; s/.*(Killed|Segmentation).*/null/' | \
awk '{
if (NR % 3 == 1) printf "[";
if ($1 == "null") printf "null";
Expand Down
14 changes: 7 additions & 7 deletions gizmosql/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ for query in "${queries[@]}"; do

# Clear Linux memory caches to ensure fair benchmark comparisons
sync
echo 3 | tee /proc/sys/vm/drop_caches > /dev/null
echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null

# Start the GizmoSQL server
start_gizmosql

# Enable timer and discard result rows (we only care about Run Time)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change l. 22 to

echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null

I got tee: /proc/sys/vm/drop_caches: Permission denied errors locally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - thanks!

echo ".timer on" >> "${TEMP_SQL_FILE}"
echo ".mode trash" >> "${TEMP_SQL_FILE}"

# Add a comment to identify the query in the output
echo "-- Query: ${query}" >> "${TEMP_SQL_FILE}"

Expand All @@ -32,12 +36,8 @@ for query in "${queries[@]}"; do
echo "${query}" >> "${TEMP_SQL_FILE}"
done

# Execute the query script
gizmosqlline \
-u ${GIZMOSQL_SERVER_URI} \
-n ${GIZMOSQL_USERNAME} \
-p ${GIZMOSQL_PASSWORD} \
-f "${TEMP_SQL_FILE}"
# Execute the query script (timer output goes to stderr; merge to stdout)
gizmosql_client --file "${TEMP_SQL_FILE}" 2>&1

# Stop the server before next query
stop_gizmosql
Expand Down
15 changes: 7 additions & 8 deletions gizmosql/util.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
#!/bin/bash

# Variables
GIZMOSQL_SERVER_URI="jdbc:arrow-flight-sql://localhost:31337?useEncryption=false"
GIZMOSQL_USERNAME=clickbench
GIZMOSQL_PASSWORD=clickbench
# Variables (env var names match what gizmosql_client recognizes natively)
export GIZMOSQL_HOST=localhost
export GIZMOSQL_PORT=31337
export GIZMOSQL_USER=clickbench
export GIZMOSQL_PASSWORD=clickbench
PID_FILE="/tmp/gizmosql_server_$$.pid"

# Function to start the GizmoSQL server
start_gizmosql() {
export GIZMOSQL_PASSWORD="${GIZMOSQL_PASSWORD}"

nohup gizmosql_server \
--username ${GIZMOSQL_USERNAME} \
--username ${GIZMOSQL_USER} \
--database-filename clickbench.db \
--print-queries >> gizmosql_server.log 2>&1 &

echo $! > "${PID_FILE}"

# Wait for server to be ready
echo "Waiting for gizmosql_server to start..."
while ! nc -z localhost 31337 2>/dev/null; do
while ! nc -z ${GIZMOSQL_HOST} ${GIZMOSQL_PORT} 2>/dev/null; do
sleep 1
done
echo "gizmosql_server is ready (PID: $(cat ${PID_FILE}))"
Expand Down