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
60 changes: 60 additions & 0 deletions elosdb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# elosdb — ClickBench submission

`elosdb` is a single-node analytical database: a C++ storage and execution engine
with its own column format, behind a server that speaks the PostgreSQL v3 wire
protocol. All 43 ClickBench queries are answered by the engine.

> It is a personal research / hobby / experiments project, published so this
> result can be reproduced — **not for production use**.

Results are in [`results/`](results/), one JSON per machine in ClickBench's own
format: every query's three tries, the load time and the data size. The totals, each
installed by `./install` from the release it pins for each architecture —
[`v0.1.10`](https://github.com/decster/elosdb/releases/tag/v0.1.10), on aarch64 and on x86_64:

| machine | release | load | data size | cold (sum of 43 first tries) | hot (sum of 43 best-of-rest) | concurrent QPS |
|---|---|---:|---:|---:|---:|---:|
| c8g.4xlarge (16 vCPU, 32 GiB) | v0.1.10 aarch64 | 44.94 s | 7,668,470,509 B | 29.66 s | 2.00 s | 12.05 |
| c6a.4xlarge (16 vCPU, 32 GiB) | v0.1.10 x86_64 | 90.22 s | 7,668,470,549 B | 34.66 s | 5.34 s | 4.95 |

Cold is the first try after the server was restarted and the OS page cache dropped;
it varies noticeably between instances of the same machine type, hot much less.

## Running it

From this directory:

./install # downloads one file, verifies its sha256, installs psql
./benchmark.sh # ClickBench's own driver

`install` compiles nothing. It fetches one statically-linked executable from
[github.com/decster/elosdb's releases](https://github.com/decster/elosdb/releases); the URL and
its sha256 are pinned in `install` itself, per architecture, and a mismatch is a refusal. Set
`ELOSDB_URL` (with `ELOSDB_SHA256`) to run a different build.

**One asset per architecture, and each names its core.** The aarch64 asset is built
`-mcpu=neoverse-v2` and refuses to start where SVE2 is absent; the x86_64 asset is built
`-march=x86-64-v3` (AVX2/FMA/BMI2, no AVX-512) and refuses on a CPU without those.
`install` selects by `uname -m`, and an architecture with no pinned asset is refused by
name. Each needs
`glibc >= 2.38` and nothing else — libstdc++ and libgcc are linked in, there is no shared library to place
beside it, and it exports no global dynamic symbols. The other requirement is a
`psql`, which `install` apt-gets.

## The scripts

| | |
|---|---|
| `install` | fetch + verify the binary; make sure there is a working psql |
| `start` | one server on 127.0.0.1:5432 — no tuning flags |
| `load` | `create.sql`, then one `COPY hits FROM 'hits.parquet'` |
| `query` | a statement in on stdin, psql's `\timing` out on stderr |
| `data-size` | `du -bs` of the store directory |
| `stop` | SIGTERM, then wait, so `drop_caches` finds nothing holding the store mapped |

`tuned: no` is a claim `start` has to keep, so its only flags are the port and the
data directory; every other setting is the binary's own default. `create.sql` is
[umbra's](../umbra/create.sql) column
list unchanged — no per-column encoding is declared, the encoder picks every layout
from the data — and `queries.sql` is umbra's unchanged. The store is
built inside the timed load window — nothing is cached or pre-computed.
3 changes: 3 additions & 0 deletions elosdb/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
export BENCH_DOWNLOAD_SCRIPT="download-hits-parquet-single"
exec ../lib/benchmark-common.sh
3 changes: 3 additions & 0 deletions elosdb/check
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
. "$(dirname "$0")/common.sh"
"${PSQL[@]}" -c 'SELECT 1' >/dev/null
15 changes: 15 additions & 0 deletions elosdb/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# common.sh — sourced by every script here. Nothing in it is a knob: these are the
# facts the scripts share about where things are.
set -eu
ELOSDB_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ELOSDB_BIN="${ELOSDB_BIN:-$ELOSDB_HOME/bin/elosdb}" # `install` puts it there
ELOSDB_PORT="${ELOSDB_PORT:-5432}"
ELOSDB_DATA="$ELOSDB_HOME/data" # data/elosdb is the store,
# data/clickbench the parquet
# A psql on PATH whose libpq is not loadable answers `command -v` and then dies on
# every invocation, so the probe RUNS it rather than looking for it.
if ! psql --version >/dev/null 2>&1; then
echo "elosdb: no working psql on PATH — ./install installs postgresql-client" >&2
exit 1
fi
PSQL=(psql -X -h 127.0.0.1 -p "$ELOSDB_PORT" -U elosdb -d elosdb)
119 changes: 119 additions & 0 deletions elosdb/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
-- The hits table as ClickBench declares it: umbra/create.sql's column list, unchanged.
-- elosdb EXECUTES this file as DDL; it is not documentation.
--
-- No column carries an ENCODING clause. The encoder prices every column on that
-- column's own values and cannot see the query set; a load of this file and a load
-- of one that pins five string columns to DICT+BLOCK write byte-identical
-- column files.
--
-- The declared type fixes the logical tag and the physical class; the parquet file
-- fixes the width — `eventdate date` is 32-bit days in PostgreSQL and 16-bit days
-- in hits.parquet, and DATE here is a tag over any integer width.
create table hits (
watchid bigint not null,
javaenable smallint not null,
title text not null,
goodevent smallint not null,
eventtime timestamp not null,
eventdate date not null,
counterid integer not null,
clientip integer not null,
regionid integer not null,
userid bigint not null,
counterclass smallint not null,
os smallint not null,
useragent smallint not null,
url text not null,
referer text not null,
isrefresh smallint not null,
referercategoryid smallint not null,
refererregionid integer not null,
urlcategoryid smallint not null,
urlregionid integer not null,
resolutionwidth smallint not null,
resolutionheight smallint not null,
resolutiondepth smallint not null,
flashmajor smallint not null,
flashminor smallint not null,
flashminor2 text not null,
netmajor smallint not null,
netminor smallint not null,
useragentmajor smallint not null,
useragentminor varchar(255) not null,
cookieenable smallint not null,
javascriptenable smallint not null,
ismobile smallint not null,
mobilephone smallint not null,
mobilephonemodel text not null,
params text not null,
ipnetworkid integer not null,
traficsourceid smallint not null,
searchengineid smallint not null,
searchphrase text not null,
advengineid smallint not null,
isartifical smallint not null,
windowclientwidth smallint not null,
windowclientheight smallint not null,
clienttimezone smallint not null,
clienteventtime timestamp not null,
silverlightversion1 smallint not null,
silverlightversion2 smallint not null,
silverlightversion3 integer not null,
silverlightversion4 smallint not null,
pagecharset text not null,
codeversion integer not null,
islink smallint not null,
isdownload smallint not null,
isnotbounce smallint not null,
funiqid bigint not null,
originalurl text not null,
hid integer not null,
isoldcounter smallint not null,
isevent smallint not null,
isparameter smallint not null,
dontcounthits smallint not null,
withhash smallint not null,
hitcolor char not null,
localeventtime timestamp not null,
age smallint not null,
sex smallint not null,
income smallint not null,
interests smallint not null,
robotness smallint not null,
remoteip integer not null,
windowname integer not null,
openername integer not null,
historylength smallint not null,
browserlanguage text not null,
browsercountry text not null,
socialnetwork text not null,
socialaction text not null,
httperror smallint not null,
sendtiming integer not null,
dnstiming integer not null,
connecttiming integer not null,
responsestarttiming integer not null,
responseendtiming integer not null,
fetchtiming integer not null,
socialsourcenetworkid smallint not null,
socialsourcepage text not null,
paramprice bigint not null,
paramorderid text not null,
paramcurrency text not null,
paramcurrencyid smallint not null,
openstatservicename text not null,
openstatcampaignid text not null,
openstatadid text not null,
openstatsourceid text not null,
utmsource text not null,
utmmedium text not null,
utmcampaign text not null,
utmcontent text not null,
utmterm text not null,
fromtag text not null,
hasgclid smallint not null,
refererhash bigint not null,
urlhash bigint not null,
clid integer not null
);

4 changes: 4 additions & 0 deletions elosdb/data-size
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# data-size — the store on disk, in bytes: one file per column plus its dictionaries.
. "$(dirname "$0")/common.sh"
du -bs "$ELOSDB_DATA/elosdb" | cut -f1
114 changes: 114 additions & 0 deletions elosdb/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/bash
# install — fetch one verified file and make sure there is a psql to talk to it.
# NOTHING IS COMPILED ON THIS BOX.
#
# elosdb ships as a single statically-linked executable: libstdc++ and libgcc are
# inside it, and it imports nothing newer than GLIBC_2.38, so the four things it
# asks the machine for are libc, libm, libgcc_s and the loader. There is no library
# to place beside it, no RUNPATH to get right and no C++ runtime to match.
#
# A BINARY OFF THE NETWORK WITH NOTHING TO CHECK IT AGAINST IS NOT A DEPLOYMENT, so
# the digest below is pinned in this file and compared before the file is ever
# executed. Point ELOSDB_URL somewhere else and you must supply ELOSDB_SHA256 with
# it: a URL without a digest is refused rather than trusted.
set -eu
cd "$(dirname "$0")"

# THE RELEASE THIS SUBMISSION IS, PER ARCHITECTURE: a tag and that tag's asset digest,
# pinned here, and a pair moves together or not at all. The two arches may name
# different tags — each pins the release that carries ITS asset and was measured with
# it (v0.1.10 carries both: the aarch64 asset built on an aarch64 box, the x86_64 asset
# on an x86 box, from the same source). An empty digest means no asset for that arch,
# and install refuses below rather than fetching a file it cannot check.
RELEASE_TAG_aarch64="v0.1.10"
RELEASE_SHA256_aarch64="44d2a66dca85d28d2fffdc439006f1a348461f50450b446b8e7791957741fa70"
RELEASE_TAG_x86_64="v0.1.10"
RELEASE_SHA256_x86_64="ce12bbf75774b4690602ea782aa0961d6f5e4a6d146078d31427bed893b719b5"
release_url() { echo "https://github.com/decster/elosdb/releases/download/$2/elosdb-$2-linux-$1"; }

# THE ARTIFACT NAMES ITS ARCHITECTURE AND ITS CORE. aarch64 is built -mcpu=neoverse-v2
# and refuses to start on a CPU that reports no SVE2; x86_64 is built -march=x86-64-v3
# (AVX2/FMA/BMI2, no AVX-512 — c6a.4xlarge's Zen 3) and refuses on a CPU without
# those. "Built for this core" in a published header has to mean it, so a box this
# release has no asset for fails here, by name, rather than three phases in.
arch="$(uname -m)"
case "$arch" in
aarch64) tag="$RELEASE_TAG_aarch64"; pinned="$RELEASE_SHA256_aarch64" ;;
x86_64) tag="$RELEASE_TAG_x86_64"; pinned="$RELEASE_SHA256_x86_64" ;;
*) echo "install: this release has no asset for $arch (aarch64 and x86_64 only)." >&2
echo "install: the published results are c8g.4xlarge, c8g.metal-48xl and c6a.4xlarge." >&2
exit 1 ;;
esac

url="${ELOSDB_URL:-}"
sha="${ELOSDB_SHA256:-}"
if [ -z "$url" ]; then
if [ -z "$pinned" ]; then
echo "install: release $tag pins no $arch asset yet." >&2
echo "install: to run an unreleased build, set ELOSDB_URL and ELOSDB_SHA256 together." >&2
exit 1
fi
url="$(release_url "$arch" "$tag")"; sha="$pinned"
elif [ -z "$sha" ]; then
echo "install: ELOSDB_URL is set but ELOSDB_SHA256 is not." >&2
echo "install: refusing to run a binary this box cannot verify." >&2
exit 1
fi

mkdir -p bin
tmp="bin/.elosdb.download"
rm -f "$tmp"
echo "install: fetching $url"
case "$url" in
http://*|https://*) curl -fsSL --retry 3 -o "$tmp" "$url" ;;
s3://*) command -v aws >/dev/null 2>&1 || { echo "install: $url needs the aws CLI on PATH" >&2; exit 1; }
aws s3 cp "$url" "$tmp" --only-show-errors ;;
*) [ -f "$url" ] || { echo "install: no such file: $url" >&2; exit 1; }
cp -f "$url" "$tmp" ;;
esac
got="$(sha256sum "$tmp" | cut -d' ' -f1)"
if [ "$got" != "$sha" ]; then
rm -f "$tmp"
echo "install: sha256 mismatch for $url" >&2
echo "install: expected $sha" >&2
echo "install: got $got" >&2
exit 1
fi
chmod +x "$tmp"
# Replaced last, so an interrupted fetch leaves the previous binary in place rather
# than half of the next one.
mv -f "$tmp" bin/elosdb
echo "install: bin/elosdb — $(du -h bin/elosdb | cut -f1), sha256 ok"

# psql is the only other thing this deployment needs: `load`, `query` and `check`
# all go through it. RUN it rather than look for it — a psql on PATH whose libpq is
# not loadable answers `command -v` and dies on every invocation.
if ! psql --version >/dev/null 2>&1; then
if command -v sudo >/dev/null 2>&1 && sudo -n true 2>/dev/null; then
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update -y >/dev/null
sudo apt-get install -y postgresql-client
else
echo "install: no psql and no sudo to install one" >&2
exit 1
fi
fi

# NEEDED entries, printed rather than assumed: this is the one place a reader can
# see that the file this box is about to run asks for nothing but libc, libm,
# libgcc_s and the loader.
command -v readelf >/dev/null 2>&1 && \
echo "install: needs $(readelf -d bin/elosdb | sed -n 's/.*Shared library: \[\(.*\)\]/\1/p' | paste -sd' ')"
# The smoke test, and the build stamp: a truncated download or a binary for another
# machine fails here and not in `start`.
./bin/elosdb --version

# THE PATH THIS WROTE AND THE PATH `start` LAUNCHES ARE ONE FACT, so it is asserted
# rather than assumed — common.sh is sourced only here, at the end, because it needs
# the psql that the block above may have just installed.
. ./common.sh
[ "$ELOSDB_BIN" -ef bin/elosdb ] || {
echo "install: common.sh points \$ELOSDB_BIN at $ELOSDB_BIN, not at the binary this installed" >&2
exit 1
}
echo "install: elosdb ready — nothing was compiled on this box"
36 changes: 36 additions & 0 deletions elosdb/load
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
# load — hits.parquet (downloaded into this directory by ClickBench's driver) into
# elosdb's own column store, then the row count through the running server.
. "$(dirname "$0")/common.sh"
cd "$ELOSDB_HOME"

mkdir -p data/clickbench
[ -f hits.parquet ] && mv hits.parquet data/clickbench/hits.parquet
[ -f data/clickbench/hits.parquet ] || { echo "load: no hits.parquet here or under data/clickbench" >&2; exit 1; }

# THE LOAD IS TWO SQL STATEMENTS, through the server ClickBench already started.
# create.sql declares the 105 columns, their types and their nullability; the COPY
# reads the whole dataset in one statement, which is what lets the string
# dictionaries be global and every column's encoding be priced on that column's
# own values. Nothing is pre-built: the store is written inside the timed window.
rm -rf data/elosdb
"${PSQL[@]}" -tA -v ON_ERROR_STOP=1 -f "$ELOSDB_HOME/create.sql"
# An absolute path: the statement is resolved by the SERVER, whose working
# directory is not this script's.
copied=$("${PSQL[@]}" -tA -c "COPY hits FROM '$ELOSDB_HOME/data/clickbench/hits.parquet'")
echo "load: $copied"
case "$copied" in
"COPY "*) ;;
*) echo "load: the COPY did not report a row count: '$copied'" >&2; exit 1 ;;
esac

# ClickBench's hits is exactly 99,997,497 rows; anything else is a partial load.
expected=99997497
got=$("${PSQL[@]}" -tAq -c 'SELECT count(*) FROM hits')
if [ "$got" != "$expected" ]; then
echo "load: hits has '$got' rows, expected $expected" >&2
exit 1
fi

rm -f data/clickbench/hits.parquet
sync
Loading
Loading