Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ pivot-parquet-partitioned/catalog
pivot-parquet-partitioned/config.yaml
redshift/log-*.txt
redshift-serverless/log-*.txt
chdb/chdb.sock
11 changes: 5 additions & 6 deletions chdb/benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/bin/bash
export BENCH_DOWNLOAD_SCRIPT="download-hits-csv"
export BENCH_RESTARTABLE=no
# Single-process engine: each query forks a fresh full-machine process with no
# shared scheduler across connections, so the concurrent-QPS test only
# oversubscribes RAM rather than measuring throughput. Skip it by default;
# override BENCH_CONCURRENT_DURATION to re-enable. See issue #946.
export BENCH_CONCURRENT_DURATION="${BENCH_CONCURRENT_DURATION:-0}"
# ./start runs one long-lived Python process with a single chDB instance
# (server.py); ./query and the concurrent-QPS workers connect to it, each
# connection with its own session. Restarting it gives a cold run, and the
# QPS test measures the throughput of the shared instance.
export BENCH_CONCURRENT_WORKER=./concurrent-worker
exec ../lib/benchmark-common.sh
4 changes: 1 addition & 3 deletions chdb/check
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
set -e

# shellcheck disable=SC1091
source myenv/bin/activate
python3 -c "import chdb; chdb.query('SELECT 1')" >/dev/null
echo "SELECT 1" | python3 client.py >/dev/null 2>&1
100 changes: 100 additions & 0 deletions chdb/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/usr/bin/env python3
"""Client of server.py. Only the standard library: it doesn't load chDB.

client.py Sends the query on stdin. Stdout: the result.
Stderr: the time measured by the server, in
fractional seconds. Exit code 1 on an error.
client.py --worker DEADLINE
The concurrent QPS test worker: cycles through
the queries on stdin (one per line) on one
connection, so in one server session, until
DEADLINE (Unix seconds), then prints
"<successful> <failed>".

Protocol: the client sends a query as an 8-byte big-endian length and the
UTF-8 text; the server answers with a status byte (0 success, 1 error), the
elapsed time as a big-endian double, an 8-byte length, and the result or the
error message. A connection carries any number of queries, one at a time.
"""

import os
import socket
import struct
import sys
import time

SOCKET = os.environ.get("BENCH_CHDB_SOCKET", "chdb.sock")


def connect():
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect(SOCKET)
return sock


def read_exactly(stream, size):
data = stream.read(size)
if len(data) != size:
raise ConnectionError("the server closed the connection")
return data


def run(stream, sql):
data = sql.encode("utf-8")
stream.write(struct.pack(">Q", len(data)) + data)
stream.flush()
status, elapsed, size = struct.unpack(">BdQ", read_exactly(stream, 17))
return status, elapsed, read_exactly(stream, size).decode("utf-8", "replace")


def query():
sql = sys.stdin.read()
with connect() as sock, sock.makefile("rwb") as stream:
status, elapsed, payload = run(stream, sql)
if status != 0:
print(payload, file=sys.stderr)
sys.exit(1)
if payload:
sys.stdout.write(payload if payload.endswith("\n") else payload + "\n")
sys.stdout.flush()
print(f"{elapsed:.3f}", file=sys.stderr)


def concurrent_worker(deadline):
queries = [q for q in sys.stdin.read().splitlines() if q.strip()]
ok = err = i = 0
sock = stream = None
while time.time() < deadline:
if stream is None:
# The first connection, or the server went down and the driver's
# watchdog is restarting it: wait until it accepts connections.
try:
sock = connect()
except OSError:
time.sleep(1)
continue
stream = sock.makefile("rwb")
try:
status, _, payload = run(stream, queries[i])
except OSError as exc:
status, payload = 1, f"connection lost: {exc}"
stream.close()
sock.close()
sock = stream = None
if status == 0:
ok += 1
else:
err += 1
print(f"concurrent-worker: {payload}", file=sys.stderr)
i = (i + 1) % len(queries)
if stream is not None:
stream.close()
sock.close()
print(ok, err)


if __name__ == "__main__":
if len(sys.argv) == 3 and sys.argv[1] == "--worker":
concurrent_worker(float(sys.argv[2]))
else:
query()
9 changes: 9 additions & 0 deletions chdb/concurrent-worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# One connection of the shared driver's concurrent-QPS test (see
# BENCH_CONCURRENT_WORKER in ../lib/benchmark-common.sh).
# $1: deadline, Unix seconds.
# Stdin: this connection's query order, one query per line.
# Stdout: "<successful> <failed>" query counts.
# Unlike ./query, it keeps one connection to the server, so one session of the
# chDB instance, for the whole test.
exec python3 client.py --worker "$1"
24 changes: 6 additions & 18 deletions chdb/load
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
#!/bin/bash
# Loads through the running server (./start): the server holds the
# .clickbench directory, so no other process can open it.
set -e

# shellcheck disable=SC1091
source myenv/bin/activate

# Idempotent: blow away any prior data dir.
rm -rf .clickbench

python3 - <<'PY'
from chdb import dbapi

con = dbapi.connect(path=".clickbench")
cur = con.cursor()

cur.execute(open("create.sql").read())
cur.execute(open("insert.sql").read())

cur.close()
con.close()
PY
# Idempotent: drop any prior table.
echo "DROP TABLE IF EXISTS clickbench.hits SYNC" | ./query >/dev/null
./query < create.sql >/dev/null
./query < insert.sql >/dev/null

rm -f hits.csv
sync
41 changes: 3 additions & 38 deletions chdb/query
Original file line number Diff line number Diff line change
@@ -1,42 +1,7 @@
#!/bin/bash
# Reads a SQL query from stdin, runs it via chdb against the .clickbench dir.
# Reads a SQL query from stdin and sends it to the running server (./start),
# which runs it in a session of its chDB instance, in the clickbench database.
# Stdout: query result.
# Stderr: query runtime in fractional seconds on the last line.
# Exit non-zero on error.
set -e

# shellcheck disable=SC1091
source myenv/bin/activate

# Stage stdin into a temp file: `python3 - <<'PY'` already consumes stdin to
# read the program, so sys.stdin.read() inside the heredoc returns "".
query_file=$(mktemp)
trap 'rm -f "$query_file"' EXIT
cat > "$query_file"

python3 - "$query_file" <<'PY'
import sys
import timeit
import chdb

with open(sys.argv[1]) as f:
query = f.read()

# The hits table is created inside the `clickbench` database (see
# create.sql + load), but the session defaults to `default`. Prepend
# USE so a bare `SELECT * FROM hits` resolves regardless.
sess = chdb.session.Session(".clickbench")
start = timeit.default_timer()
try:
res = sess.query(f"USE clickbench; {query}", "Pretty")
out = str(res)
end = timeit.default_timer()
if out:
sys.stdout.write(out)
if not out.endswith("\n"):
sys.stdout.write("\n")
finally:
sess.close()

print(f"{end - start:.3f}", file=sys.stderr)
PY
exec python3 client.py
60 changes: 60 additions & 0 deletions chdb/results/20261119/c6a.2xlarge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"system": "chDB",
"date": "2026-11-19",
"machine": "c6a.2xlarge",
"cluster_size": 1,
"proprietary": "no",
"hardware": "cpu",
"tuned": "no",
"tags": ["C++","column-oriented","ClickHouse derivative","embedded","stateless"],
"load_time": 586,
"data_size": 25013279052,
"concurrent_qps": 0.297,
"concurrent_error_ratio": 0,
"startup_time": 2.667,
"result": [
[0.022, 0.002, 0.001],
[0.025, 0.002, 0.002],
[0.112, 0.038, 0.039],
[0.238, 0.052, 0.05],
[0.653, 0.444, 0.456],
[0.992, 0.667, 0.664],
[0.063, 0.015, 0.014],
[0.08, 0.016, 0.014],
[0.953, 0.726, 0.73],
[1.118, 0.859, 0.822],
[0.478, 0.161, 0.157],
[0.413, 0.194, 0.189],
[1.042, 0.547, 0.481],
[2.093, 0.808, 0.77],
[1.243, 0.636, 0.588],
[0.547, 0.359, 0.36],
[2.115, 1.52, 1.514],
[0.187, 0.01, 0.008],
[3.915, 2.514, 2.492],
[0.15, 0.003, 0.003],
[11.176, 0.348, 0.356],
[13.033, 0.098, 0.1],
[15.009, 0.648, 0.654],
[1.602, 0.049, 0.039],
[0.898, 0.012, 0.011],
[0.854, 0.222, 0.227],
[0.866, 0.229, 0.01],
[0.353, 0.155, 0.162],
[9.998, 2.319, 2.299],
[0.126, 0.049, 0.05],
[0.516, 0.332, 0.325],
[3.484, 0.516, 0.522],
[6.317, 3.766, 3.787],
[12.087, 7.387, 2.707],
[12.02, 2.598, 8.011],
[0.502, 0.372, 0.363],
[0.182, 0.056, 0.046],
[0.141, 0.033, 0.026],
[0.154, 0.026, 0.027],
[0.276, 0.117, 0.1],
[0.13, 0.016, 0.015],
[0.122, 0.012, 0.013],
[0.115, 0.01, 0.01]
]
}
60 changes: 60 additions & 0 deletions chdb/results/20261119/c6a.4xlarge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"system": "chDB",
"date": "2026-11-19",
"machine": "c6a.4xlarge",
"cluster_size": 1,
"proprietary": "no",
"hardware": "cpu",
"tuned": "no",
"tags": ["C++","column-oriented","ClickHouse derivative","embedded","stateless"],
"load_time": 540,
"data_size": 22447949036,
"concurrent_qps": 0.753,
"concurrent_error_ratio": 0,
"startup_time": 2.617,
"result": [
[0.021, 0.002, 0.002],
[0.026, 0.002, 0.002],
[0.088, 0.022, 0.02],
[0.141, 0.028, 0.026],
[0.333, 0.23, 0.211],
[0.75, 0.353, 0.343],
[0.055, 0.01, 0.011],
[0.084, 0.011, 0.012],
[0.682, 0.5, 0.486],
[0.692, 0.506, 0.538],
[0.275, 0.12, 0.131],
[0.281, 0.137, 0.147],
[0.787, 0.325, 0.335],
[1.737, 0.541, 0.532],
[1.101, 0.373, 0.368],
[0.343, 0.209, 0.209],
[1.887, 1.134, 1.141],
[0.141, 0.01, 0.01],
[3.615, 1.92, 1.937],
[0.125, 0.003, 0.003],
[10.454, 0.177, 0.175],
[12.263, 0.063, 0.059],
[14.385, 0.515, 0.515],
[1.577, 0.044, 0.051],
[0.776, 0.013, 0.011],
[0.694, 0.159, 0.154],
[0.634, 0.22, 0.012],
[0.322, 0.08, 0.078],
[9.365, 1.73, 1.755],
[0.103, 0.032, 0.032],
[0.434, 0.201, 0.201],
[3.584, 0.349, 0.362],
[4.938, 2.546, 2.565],
[10.84, 1.81, 1.54],
[11.14, 1.757, 1.539],
[0.3, 0.188, 0.182],
[0.147, 0.037, 0.035],
[0.124, 0.02, 0.019],
[0.138, 0.018, 0.018],
[0.217, 0.077, 0.076],
[0.125, 0.013, 0.012],
[0.117, 0.012, 0.011],
[0.119, 0.01, 0.01]
]
}
60 changes: 60 additions & 0 deletions chdb/results/20261119/c6a.large.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"system": "chDB",
"date": "2026-11-19",
"machine": "c6a.large",
"cluster_size": 1,
"proprietary": "no",
"hardware": "cpu",
"tuned": "no",
"tags": ["C++","column-oriented","ClickHouse derivative","embedded","stateless"],
"load_time": 995,
"data_size": 15331010724,
"concurrent_qps": 0.157,
"concurrent_error_ratio": 0.161,
"startup_time": 2.785,
"result": [
[0.026, 0.002, 0.004],
[0.033, 0.002, 0.004],
[0.655, 0.434, 0.44],
[1.187, 0.928, 0.909],
[21.451, 20.123, 21.721],
[7.13, 6.218, 6.394],
[0.341, 0.22, 0.163],
[0.252, 0.089, 0.061],
[7.427, 6.86, 7.006],
[8.102, 7.734, 7.812],
[2.752, 2.211, 2.365],
[3.084, 2.631, 2.751],
[8.277, 7.091, 7.362],
[11.539, 11.167, 11.51],
[9.2, 8.445, 8.623],
[4.47, 4.014, 3.869],
[43.028, 42.696, 35.76],
[0.562, 0.026, 0.023],
[54.985, 55.605, 54.819],
[0.534, 0.005, 0.004],
[10.927, 2.504, 2.701],
[13.518, 0.844, 0.848],
[16.701, 6.09, 6.965],
[2.869, 0.197, 0.177],
[1.305, 0.047, 0.046],
[3.26, 2.895, 2.896],
[1.311, 0.323, 0.044],
[1.88, 1.646, 1.643],
[25.229, 24.338, 25.118],
[0.379, 0.274, 0.285],
[3.248, 3.084, 3.078],
[5.657, 4.279, 4.279],
[69.836, 70.407, 68.169],
[48.742, 47.061, 47.502],
[49.113, 47.438, 47.946],
[2.516, 2.37, 2.392],
[0.436, 0.261, 0.263],
[0.279, 0.154, 0.163],
[0.269, 0.114, 0.116],
[0.882, 0.677, 0.661],
[0.202, 0.057, 0.056],
[0.172, 0.043, 0.046],
[0.164, 0.037, 0.041]
]
}
Loading