From e0472d7a2847bfe711f8005cab9343e5348bbbc0 Mon Sep 17 00:00:00 2001 From: Theo Bulut Date: Thu, 13 Aug 2026 18:09:45 +0200 Subject: [PATCH] feat(scramdb): add ScramDB ClickBench entries (cpu, tuned) --- scramdb-tuned/README.md | 24 ++++++++ scramdb-tuned/benchmark.sh | 12 ++++ scramdb-tuned/check | 3 + scramdb-tuned/create.sql | 109 ++++++++++++++++++++++++++++++++++++ scramdb-tuned/data-size | 3 + scramdb-tuned/install | 100 +++++++++++++++++++++++++++++++++ scramdb-tuned/load | 10 ++++ scramdb-tuned/queries.sql | 43 ++++++++++++++ scramdb-tuned/query | 21 +++++++ scramdb-tuned/start | 19 +++++++ scramdb-tuned/stop | 2 + scramdb-tuned/template.json | 13 +++++ scramdb/README.md | 44 +++++++++++++++ scramdb/benchmark.sh | 12 ++++ scramdb/check | 3 + scramdb/create.sql | 109 ++++++++++++++++++++++++++++++++++++ scramdb/data-size | 3 + scramdb/install | 80 ++++++++++++++++++++++++++ scramdb/load | 10 ++++ scramdb/queries.sql | 43 ++++++++++++++ scramdb/query | 21 +++++++ scramdb/start | 19 +++++++ scramdb/stop | 2 + scramdb/template.json | 13 +++++ 24 files changed, 718 insertions(+) create mode 100644 scramdb-tuned/README.md create mode 100755 scramdb-tuned/benchmark.sh create mode 100755 scramdb-tuned/check create mode 100644 scramdb-tuned/create.sql create mode 100755 scramdb-tuned/data-size create mode 100755 scramdb-tuned/install create mode 100755 scramdb-tuned/load create mode 100644 scramdb-tuned/queries.sql create mode 100755 scramdb-tuned/query create mode 100755 scramdb-tuned/start create mode 100755 scramdb-tuned/stop create mode 100644 scramdb-tuned/template.json create mode 100644 scramdb/README.md create mode 100755 scramdb/benchmark.sh create mode 100755 scramdb/check create mode 100644 scramdb/create.sql create mode 100755 scramdb/data-size create mode 100755 scramdb/install create mode 100755 scramdb/load create mode 100644 scramdb/queries.sql create mode 100755 scramdb/query create mode 100755 scramdb/start create mode 100755 scramdb/stop create mode 100644 scramdb/template.json diff --git a/scramdb-tuned/README.md b/scramdb-tuned/README.md new file mode 100644 index 0000000000..cec1568b8d --- /dev/null +++ b/scramdb-tuned/README.md @@ -0,0 +1,24 @@ +# ScramDB (tuned) + +`tuned: yes` companion to [`scramdb`](../scramdb). Same image and harness, only +the config differs. See that README for the rest. + + bash benchmark.sh + +**None of this has been measured against these 43 queries yet.** It is reasoned +from the engine's defaults, not from a sweep. + +## Tuned + +- `backend = "io_uring"` (base stays on the `auto` default) +- `morsel_size` 8MB, `arena_chunk_size` 8MB +- `copy_batch_rows` 131072, `copy_pipeline_depth` 8 (load path only) +- `spill_agg_partitions` 128 - the high-cardinality GROUP BY and exact + COUNT(DISTINCT) queries all spill +- `prefetch_depth` 32, `prefetch_queue_depth` 256, `bloom_max_bytes` 16KB +- `flush_threshold_rows` 65536 +- background compaction, GC and auto-analyze pushed past the run length; the + driver restarts before all 43 queries, so nothing should wake mid-query + +Memory and segment sizing stay at product defaults; join knobs are untouched +(no joins in the 43 queries). diff --git a/scramdb-tuned/benchmark.sh b/scramdb-tuned/benchmark.sh new file mode 100755 index 0000000000..5104cd3ea9 --- /dev/null +++ b/scramdb-tuned/benchmark.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +export BENCH_DOWNLOAD_SCRIPT="download-hits-csv" + +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGUSER="${PGUSER:-scramdb}" +export PGDATABASE="${PGDATABASE:-scramdb}" +export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-10}" +export SCRAMDB_IMAGE="${SCRAMDB_IMAGE:-scramdb/scramdb:d563548}" + +exec ../lib/benchmark-common.sh diff --git a/scramdb-tuned/check b/scramdb-tuned/check new file mode 100755 index 0000000000..e226837132 --- /dev/null +++ b/scramdb-tuned/check @@ -0,0 +1,3 @@ +#!/bin/bash +set -e +psql -t -c 'SELECT 1' >/dev/null diff --git a/scramdb-tuned/create.sql b/scramdb-tuned/create.sql new file mode 100644 index 0000000000..1850bffedc --- /dev/null +++ b/scramdb-tuned/create.sql @@ -0,0 +1,109 @@ +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, + PRIMARY KEY (CounterID, EventDate, UserID, EventTime, WatchID) +); diff --git a/scramdb-tuned/data-size b/scramdb-tuned/data-size new file mode 100755 index 0000000000..68007d9fe4 --- /dev/null +++ b/scramdb-tuned/data-size @@ -0,0 +1,3 @@ +#!/bin/bash +set -eu +sudo du -sb --exclude=scramvm_cache ./db | cut -f1 diff --git a/scramdb-tuned/install b/scramdb-tuned/install new file mode 100755 index 0000000000..cbce95782d --- /dev/null +++ b/scramdb-tuned/install @@ -0,0 +1,100 @@ +#!/bin/bash +set -eu + +sudo apt-get update -y +sudo apt-get install -y postgresql-client docker.io bc + +./stop || true +sudo docker rm -f scramdb 2>/dev/null || true +sudo rm -rf ./db +mkdir -p ./db +chmod 777 ./db + +ram_kb=$(grep MemTotal /proc/meminfo | tr -dc 0-9) +ram_mb=$(( ram_kb / 1024 )) +ram_gb=$(( ram_mb / 1024 )) + +if [ "$ram_gb" -lt 16 ]; then + echo "WARNING: ScramDB targets machines with at least 16 GB of RAM; this one has ${ram_gb} GB." >&2 + echo "WARNING: proceeding anyway, but this result is not representative of the product." >&2 +fi + +jit_mb=$(( ram_mb * 10 / 100 )) +floor_mb=2048 +if [ "$floor_mb" -gt $(( ram_mb / 4 )) ]; then floor_mb=$(( ram_mb / 4 )); fi +if [ "$jit_mb" -lt "$floor_mb" ]; then jit_mb=$floor_mb; fi +if [ "$jit_mb" -gt 32768 ]; then jit_mb=32768; fi +jit_disk_mb=$(( jit_mb * 4 )) +if [ "$jit_disk_mb" -lt 4096 ]; then jit_disk_mb=4096; fi +if [ "$jit_disk_mb" -gt 65536 ]; then jit_disk_mb=65536; fi +echo "scramdb-tuned: ${ram_gb} GB RAM detected -> compiled-query cache ${jit_mb}MB memory / ${jit_disk_mb}MB disk" + +cat > scramdb-config.toml < 0; +SELECT SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) FROM hits; +SELECT AVG(UserID) FROM hits; +SELECT COUNT(DISTINCT UserID) FROM hits; +SELECT COUNT(DISTINCT SearchPhrase) FROM hits; +SELECT MIN(EventDate), MAX(EventDate) FROM hits; +SELECT AdvEngineID, COUNT(*) FROM hits WHERE AdvEngineID <> 0 GROUP BY AdvEngineID ORDER BY COUNT(*) DESC; +SELECT RegionID, COUNT(DISTINCT UserID) AS u FROM hits GROUP BY RegionID ORDER BY u DESC LIMIT 10; +SELECT RegionID, SUM(AdvEngineID), COUNT(*) AS c, AVG(ResolutionWidth), COUNT(DISTINCT UserID) FROM hits GROUP BY RegionID ORDER BY c DESC LIMIT 10; +SELECT MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhoneModel ORDER BY u DESC LIMIT 10; +SELECT MobilePhone, MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhone, MobilePhoneModel ORDER BY u DESC LIMIT 10; +SELECT SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10; +SELECT SearchPhrase, COUNT(DISTINCT UserID) AS u FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY u DESC LIMIT 10; +SELECT SearchEngineID, SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, SearchPhrase ORDER BY c DESC LIMIT 10; +SELECT UserID, COUNT(*) FROM hits GROUP BY UserID ORDER BY COUNT(*) DESC LIMIT 10; +SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10; +SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase LIMIT 10; +SELECT UserID, extract(minute FROM EventTime) AS m, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, m, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10; +SELECT UserID FROM hits WHERE UserID = 435090932899640449; +SELECT COUNT(*) FROM hits WHERE URL LIKE '%google%'; +SELECT SearchPhrase, MIN(URL), COUNT(*) AS c FROM hits WHERE URL LIKE '%google%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10; +SELECT SearchPhrase, MIN(URL), MIN(Title), COUNT(*) AS c, COUNT(DISTINCT UserID) FROM hits WHERE Title LIKE '%Google%' AND URL NOT LIKE '%.google.%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10; +SELECT * FROM hits WHERE URL LIKE '%google%' ORDER BY EventTime LIMIT 10; +SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT 10; +SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY SearchPhrase LIMIT 10; +SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime, SearchPhrase LIMIT 10; +SELECT CounterID, AVG(length(URL)) AS l, COUNT(*) AS c FROM hits WHERE URL <> '' GROUP BY CounterID HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25; +SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25; +SELECT SUM(ResolutionWidth), SUM(ResolutionWidth + 1), SUM(ResolutionWidth + 2), SUM(ResolutionWidth + 3), SUM(ResolutionWidth + 4), SUM(ResolutionWidth + 5), SUM(ResolutionWidth + 6), SUM(ResolutionWidth + 7), SUM(ResolutionWidth + 8), SUM(ResolutionWidth + 9), SUM(ResolutionWidth + 10), SUM(ResolutionWidth + 11), SUM(ResolutionWidth + 12), SUM(ResolutionWidth + 13), SUM(ResolutionWidth + 14), SUM(ResolutionWidth + 15), SUM(ResolutionWidth + 16), SUM(ResolutionWidth + 17), SUM(ResolutionWidth + 18), SUM(ResolutionWidth + 19), SUM(ResolutionWidth + 20), SUM(ResolutionWidth + 21), SUM(ResolutionWidth + 22), SUM(ResolutionWidth + 23), SUM(ResolutionWidth + 24), SUM(ResolutionWidth + 25), SUM(ResolutionWidth + 26), SUM(ResolutionWidth + 27), SUM(ResolutionWidth + 28), SUM(ResolutionWidth + 29), SUM(ResolutionWidth + 30), SUM(ResolutionWidth + 31), SUM(ResolutionWidth + 32), SUM(ResolutionWidth + 33), SUM(ResolutionWidth + 34), SUM(ResolutionWidth + 35), SUM(ResolutionWidth + 36), SUM(ResolutionWidth + 37), SUM(ResolutionWidth + 38), SUM(ResolutionWidth + 39), SUM(ResolutionWidth + 40), SUM(ResolutionWidth + 41), SUM(ResolutionWidth + 42), SUM(ResolutionWidth + 43), SUM(ResolutionWidth + 44), SUM(ResolutionWidth + 45), SUM(ResolutionWidth + 46), SUM(ResolutionWidth + 47), SUM(ResolutionWidth + 48), SUM(ResolutionWidth + 49), SUM(ResolutionWidth + 50), SUM(ResolutionWidth + 51), SUM(ResolutionWidth + 52), SUM(ResolutionWidth + 53), SUM(ResolutionWidth + 54), SUM(ResolutionWidth + 55), SUM(ResolutionWidth + 56), SUM(ResolutionWidth + 57), SUM(ResolutionWidth + 58), SUM(ResolutionWidth + 59), SUM(ResolutionWidth + 60), SUM(ResolutionWidth + 61), SUM(ResolutionWidth + 62), SUM(ResolutionWidth + 63), SUM(ResolutionWidth + 64), SUM(ResolutionWidth + 65), SUM(ResolutionWidth + 66), SUM(ResolutionWidth + 67), SUM(ResolutionWidth + 68), SUM(ResolutionWidth + 69), SUM(ResolutionWidth + 70), SUM(ResolutionWidth + 71), SUM(ResolutionWidth + 72), SUM(ResolutionWidth + 73), SUM(ResolutionWidth + 74), SUM(ResolutionWidth + 75), SUM(ResolutionWidth + 76), SUM(ResolutionWidth + 77), SUM(ResolutionWidth + 78), SUM(ResolutionWidth + 79), SUM(ResolutionWidth + 80), SUM(ResolutionWidth + 81), SUM(ResolutionWidth + 82), SUM(ResolutionWidth + 83), SUM(ResolutionWidth + 84), SUM(ResolutionWidth + 85), SUM(ResolutionWidth + 86), SUM(ResolutionWidth + 87), SUM(ResolutionWidth + 88), SUM(ResolutionWidth + 89) FROM hits; +SELECT SearchEngineID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, ClientIP ORDER BY c DESC LIMIT 10; +SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10; +SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10; +SELECT URL, COUNT(*) AS c FROM hits GROUP BY URL ORDER BY c DESC LIMIT 10; +SELECT 1, URL, COUNT(*) AS c FROM hits GROUP BY 1, URL ORDER BY c DESC LIMIT 10; +SELECT ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3, COUNT(*) AS c FROM hits GROUP BY ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3 ORDER BY c DESC LIMIT 10; +SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND DontCountHits = 0 AND IsRefresh = 0 AND URL <> '' GROUP BY URL ORDER BY PageViews DESC LIMIT 10; +SELECT Title, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND DontCountHits = 0 AND IsRefresh = 0 AND Title <> '' GROUP BY Title ORDER BY PageViews DESC LIMIT 10; +SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND IsLink <> 0 AND IsDownload = 0 GROUP BY URL ORDER BY PageViews DESC LIMIT 10 OFFSET 1000; +SELECT TraficSourceID, SearchEngineID, AdvEngineID, CASE WHEN (SearchEngineID = 0 AND AdvEngineID = 0) THEN Referer ELSE '' END AS Src, URL AS Dst, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 GROUP BY TraficSourceID, SearchEngineID, AdvEngineID, Src, Dst ORDER BY PageViews DESC LIMIT 10 OFFSET 1000; +SELECT URLHash, EventDate, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND TraficSourceID IN (-1, 6) AND RefererHash = 3594120000172545465 GROUP BY URLHash, EventDate ORDER BY PageViews DESC LIMIT 10 OFFSET 100; +SELECT WindowClientWidth, WindowClientHeight, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND DontCountHits = 0 AND URLHash = 2868770270353813622 GROUP BY WindowClientWidth, WindowClientHeight ORDER BY PageViews DESC LIMIT 10 OFFSET 10000; +SELECT DATE_TRUNC('minute', EventTime) AS M, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-14' AND EventDate <= '2013-07-15' AND IsRefresh = 0 AND DontCountHits = 0 GROUP BY DATE_TRUNC('minute', EventTime) ORDER BY DATE_TRUNC('minute', EventTime) LIMIT 10 OFFSET 1000; diff --git a/scramdb-tuned/query b/scramdb-tuned/query new file mode 100755 index 0000000000..25f5fc45c0 --- /dev/null +++ b/scramdb-tuned/query @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +query=$(cat) + +raw=$(psql -t -c '\timing' -c "$query" 2>&1) && exit_code=0 || exit_code=$? + +if [ "$exit_code" -ne 0 ] || printf '%s\n' "$raw" | grep -qE '^ERROR|psql: error'; then + printf '%s\n' "$raw" >&2 + exit 1 +fi + +printf '%s\n' "$raw" | grep -v '^Time:' || true + +ms=$(printf '%s\n' "$raw" | grep -oP 'Time:\s*\K[0-9.]+' | tail -n1) +if [ -z "$ms" ]; then + echo "no Time: in psql output" >&2 + exit 1 +fi + +LC_ALL=C printf '%.3f\n' "$(echo "$ms / 1000" | bc -l)" >&2 diff --git a/scramdb-tuned/start b/scramdb-tuned/start new file mode 100755 index 0000000000..4973c69866 --- /dev/null +++ b/scramdb-tuned/start @@ -0,0 +1,19 @@ +#!/bin/bash +set -eu + +IMAGE="${SCRAMDB_IMAGE:-scramdb/scramdb:d563548}" +PORT="${PGPORT:-5432}" + +if sudo docker inspect scramdb >/dev/null 2>&1; then + sudo docker start scramdb +else + sudo docker run -d --name scramdb \ + --privileged \ + --cap-add=IPC_LOCK \ + --ulimit memlock=-1:-1 \ + -p "${PORT}:5432" \ + -v "$PWD:/bench:ro" \ + -v "$PWD/db:/var/lib/scramdb" \ + -v "$PWD/scramdb-config.toml:/etc/scramdb/config.toml:ro" \ + "$IMAGE" +fi diff --git a/scramdb-tuned/stop b/scramdb-tuned/stop new file mode 100755 index 0000000000..480bdc9bcf --- /dev/null +++ b/scramdb-tuned/stop @@ -0,0 +1,2 @@ +#!/bin/bash +sudo docker stop scramdb 2>/dev/null || true diff --git a/scramdb-tuned/template.json b/scramdb-tuned/template.json new file mode 100644 index 0000000000..9a3bbdae8b --- /dev/null +++ b/scramdb-tuned/template.json @@ -0,0 +1,13 @@ +{ + "system": "ScramDB", + "proprietary": "yes", + "hardware": "cpu", + "tuned": "yes", + "tags": [ + "Rust", + "column-oriented", + "PostgreSQL compatible", + "UTAP", + "JIT" + ] +} diff --git a/scramdb/README.md b/scramdb/README.md new file mode 100644 index 0000000000..0a58bc64c9 --- /dev/null +++ b/scramdb/README.md @@ -0,0 +1,44 @@ +# ScramDB + +PostgreSQL-wire-compatible UTAP database, run from its official Docker image, +pinned to the immutable tag `scramdb/scramdb:d563548` so the benchmarked +artifact stays reproducible. + + bash benchmark.sh + +Targets machines with >= 16 GB RAM; `install` warns and continues below that. + +## Entries + +- `scramdb` - CPU, product defaults (`tuned: no`) +- `scramdb-tuned` - CPU, io_uring plus execution knobs (`tuned: yes`) + +## Config + +`install` writes `scramdb-config.toml`, mounted over `/etc/scramdb/config.toml`. +Mounting replaces the image's own config, so the shipped values are restated. +Memory is sized by the engine from detected RAM. + +Deviations: compiled-query cache enlarged (sized from RAM, so nothing evicts), +WAL archiving off, UDF off, explicit `ANALYZE` in `./load` instead of the +background one, shorter shutdown drain. + +`--privileged --ulimit memlock=-1:-1` are for io_uring. + +## Load + +`COPY`, `CHECKPOINT`, `ANALYZE`, all inside the timed window, so `load_time` +includes them. + +The schema declares the same primary key the other entries order on; row order +is the input file's. + +## data_size + +`sudo du -sb --exclude=scramvm_cache ./db`. The compiled-query cache is derived +from the queries, not the data. + +## Known + +Try 1 is not compile-cold: the compiled-query cache survives restarts. No +NUMA-aware scheduling, no huge pages. diff --git a/scramdb/benchmark.sh b/scramdb/benchmark.sh new file mode 100755 index 0000000000..5104cd3ea9 --- /dev/null +++ b/scramdb/benchmark.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +export BENCH_DOWNLOAD_SCRIPT="download-hits-csv" + +export PGHOST="${PGHOST:-localhost}" +export PGPORT="${PGPORT:-5432}" +export PGUSER="${PGUSER:-scramdb}" +export PGDATABASE="${PGDATABASE:-scramdb}" +export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-10}" +export SCRAMDB_IMAGE="${SCRAMDB_IMAGE:-scramdb/scramdb:d563548}" + +exec ../lib/benchmark-common.sh diff --git a/scramdb/check b/scramdb/check new file mode 100755 index 0000000000..e226837132 --- /dev/null +++ b/scramdb/check @@ -0,0 +1,3 @@ +#!/bin/bash +set -e +psql -t -c 'SELECT 1' >/dev/null diff --git a/scramdb/create.sql b/scramdb/create.sql new file mode 100644 index 0000000000..1850bffedc --- /dev/null +++ b/scramdb/create.sql @@ -0,0 +1,109 @@ +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, + PRIMARY KEY (CounterID, EventDate, UserID, EventTime, WatchID) +); diff --git a/scramdb/data-size b/scramdb/data-size new file mode 100755 index 0000000000..68007d9fe4 --- /dev/null +++ b/scramdb/data-size @@ -0,0 +1,3 @@ +#!/bin/bash +set -eu +sudo du -sb --exclude=scramvm_cache ./db | cut -f1 diff --git a/scramdb/install b/scramdb/install new file mode 100755 index 0000000000..ca267f342a --- /dev/null +++ b/scramdb/install @@ -0,0 +1,80 @@ +#!/bin/bash +set -eu + +sudo apt-get update -y +sudo apt-get install -y postgresql-client docker.io bc + +./stop || true +sudo docker rm -f scramdb 2>/dev/null || true +sudo rm -rf ./db +mkdir -p ./db +chmod 777 ./db + +ram_kb=$(grep MemTotal /proc/meminfo | tr -dc 0-9) +ram_mb=$(( ram_kb / 1024 )) +ram_gb=$(( ram_mb / 1024 )) + +if [ "$ram_gb" -lt 16 ]; then + echo "WARNING: ScramDB targets machines with at least 16 GB of RAM; this one has ${ram_gb} GB." >&2 + echo "WARNING: proceeding anyway, but this result is not representative of the product." >&2 +fi + +jit_mb=$(( ram_mb * 10 / 100 )) +floor_mb=2048 +if [ "$floor_mb" -gt $(( ram_mb / 4 )) ]; then floor_mb=$(( ram_mb / 4 )); fi +if [ "$jit_mb" -lt "$floor_mb" ]; then jit_mb=$floor_mb; fi +if [ "$jit_mb" -gt 32768 ]; then jit_mb=32768; fi +jit_disk_mb=$(( jit_mb * 4 )) +if [ "$jit_disk_mb" -lt 4096 ]; then jit_disk_mb=4096; fi +if [ "$jit_disk_mb" -gt 65536 ]; then jit_disk_mb=65536; fi +echo "scramdb: ${ram_gb} GB RAM detected -> compiled-query cache ${jit_mb}MB memory / ${jit_disk_mb}MB disk" + +cat > scramdb-config.toml < 0; +SELECT SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) FROM hits; +SELECT AVG(UserID) FROM hits; +SELECT COUNT(DISTINCT UserID) FROM hits; +SELECT COUNT(DISTINCT SearchPhrase) FROM hits; +SELECT MIN(EventDate), MAX(EventDate) FROM hits; +SELECT AdvEngineID, COUNT(*) FROM hits WHERE AdvEngineID <> 0 GROUP BY AdvEngineID ORDER BY COUNT(*) DESC; +SELECT RegionID, COUNT(DISTINCT UserID) AS u FROM hits GROUP BY RegionID ORDER BY u DESC LIMIT 10; +SELECT RegionID, SUM(AdvEngineID), COUNT(*) AS c, AVG(ResolutionWidth), COUNT(DISTINCT UserID) FROM hits GROUP BY RegionID ORDER BY c DESC LIMIT 10; +SELECT MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhoneModel ORDER BY u DESC LIMIT 10; +SELECT MobilePhone, MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhone, MobilePhoneModel ORDER BY u DESC LIMIT 10; +SELECT SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10; +SELECT SearchPhrase, COUNT(DISTINCT UserID) AS u FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY u DESC LIMIT 10; +SELECT SearchEngineID, SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, SearchPhrase ORDER BY c DESC LIMIT 10; +SELECT UserID, COUNT(*) FROM hits GROUP BY UserID ORDER BY COUNT(*) DESC LIMIT 10; +SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10; +SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase LIMIT 10; +SELECT UserID, extract(minute FROM EventTime) AS m, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, m, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10; +SELECT UserID FROM hits WHERE UserID = 435090932899640449; +SELECT COUNT(*) FROM hits WHERE URL LIKE '%google%'; +SELECT SearchPhrase, MIN(URL), COUNT(*) AS c FROM hits WHERE URL LIKE '%google%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10; +SELECT SearchPhrase, MIN(URL), MIN(Title), COUNT(*) AS c, COUNT(DISTINCT UserID) FROM hits WHERE Title LIKE '%Google%' AND URL NOT LIKE '%.google.%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10; +SELECT * FROM hits WHERE URL LIKE '%google%' ORDER BY EventTime LIMIT 10; +SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT 10; +SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY SearchPhrase LIMIT 10; +SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime, SearchPhrase LIMIT 10; +SELECT CounterID, AVG(length(URL)) AS l, COUNT(*) AS c FROM hits WHERE URL <> '' GROUP BY CounterID HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25; +SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25; +SELECT SUM(ResolutionWidth), SUM(ResolutionWidth + 1), SUM(ResolutionWidth + 2), SUM(ResolutionWidth + 3), SUM(ResolutionWidth + 4), SUM(ResolutionWidth + 5), SUM(ResolutionWidth + 6), SUM(ResolutionWidth + 7), SUM(ResolutionWidth + 8), SUM(ResolutionWidth + 9), SUM(ResolutionWidth + 10), SUM(ResolutionWidth + 11), SUM(ResolutionWidth + 12), SUM(ResolutionWidth + 13), SUM(ResolutionWidth + 14), SUM(ResolutionWidth + 15), SUM(ResolutionWidth + 16), SUM(ResolutionWidth + 17), SUM(ResolutionWidth + 18), SUM(ResolutionWidth + 19), SUM(ResolutionWidth + 20), SUM(ResolutionWidth + 21), SUM(ResolutionWidth + 22), SUM(ResolutionWidth + 23), SUM(ResolutionWidth + 24), SUM(ResolutionWidth + 25), SUM(ResolutionWidth + 26), SUM(ResolutionWidth + 27), SUM(ResolutionWidth + 28), SUM(ResolutionWidth + 29), SUM(ResolutionWidth + 30), SUM(ResolutionWidth + 31), SUM(ResolutionWidth + 32), SUM(ResolutionWidth + 33), SUM(ResolutionWidth + 34), SUM(ResolutionWidth + 35), SUM(ResolutionWidth + 36), SUM(ResolutionWidth + 37), SUM(ResolutionWidth + 38), SUM(ResolutionWidth + 39), SUM(ResolutionWidth + 40), SUM(ResolutionWidth + 41), SUM(ResolutionWidth + 42), SUM(ResolutionWidth + 43), SUM(ResolutionWidth + 44), SUM(ResolutionWidth + 45), SUM(ResolutionWidth + 46), SUM(ResolutionWidth + 47), SUM(ResolutionWidth + 48), SUM(ResolutionWidth + 49), SUM(ResolutionWidth + 50), SUM(ResolutionWidth + 51), SUM(ResolutionWidth + 52), SUM(ResolutionWidth + 53), SUM(ResolutionWidth + 54), SUM(ResolutionWidth + 55), SUM(ResolutionWidth + 56), SUM(ResolutionWidth + 57), SUM(ResolutionWidth + 58), SUM(ResolutionWidth + 59), SUM(ResolutionWidth + 60), SUM(ResolutionWidth + 61), SUM(ResolutionWidth + 62), SUM(ResolutionWidth + 63), SUM(ResolutionWidth + 64), SUM(ResolutionWidth + 65), SUM(ResolutionWidth + 66), SUM(ResolutionWidth + 67), SUM(ResolutionWidth + 68), SUM(ResolutionWidth + 69), SUM(ResolutionWidth + 70), SUM(ResolutionWidth + 71), SUM(ResolutionWidth + 72), SUM(ResolutionWidth + 73), SUM(ResolutionWidth + 74), SUM(ResolutionWidth + 75), SUM(ResolutionWidth + 76), SUM(ResolutionWidth + 77), SUM(ResolutionWidth + 78), SUM(ResolutionWidth + 79), SUM(ResolutionWidth + 80), SUM(ResolutionWidth + 81), SUM(ResolutionWidth + 82), SUM(ResolutionWidth + 83), SUM(ResolutionWidth + 84), SUM(ResolutionWidth + 85), SUM(ResolutionWidth + 86), SUM(ResolutionWidth + 87), SUM(ResolutionWidth + 88), SUM(ResolutionWidth + 89) FROM hits; +SELECT SearchEngineID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, ClientIP ORDER BY c DESC LIMIT 10; +SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10; +SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10; +SELECT URL, COUNT(*) AS c FROM hits GROUP BY URL ORDER BY c DESC LIMIT 10; +SELECT 1, URL, COUNT(*) AS c FROM hits GROUP BY 1, URL ORDER BY c DESC LIMIT 10; +SELECT ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3, COUNT(*) AS c FROM hits GROUP BY ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3 ORDER BY c DESC LIMIT 10; +SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND DontCountHits = 0 AND IsRefresh = 0 AND URL <> '' GROUP BY URL ORDER BY PageViews DESC LIMIT 10; +SELECT Title, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND DontCountHits = 0 AND IsRefresh = 0 AND Title <> '' GROUP BY Title ORDER BY PageViews DESC LIMIT 10; +SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND IsLink <> 0 AND IsDownload = 0 GROUP BY URL ORDER BY PageViews DESC LIMIT 10 OFFSET 1000; +SELECT TraficSourceID, SearchEngineID, AdvEngineID, CASE WHEN (SearchEngineID = 0 AND AdvEngineID = 0) THEN Referer ELSE '' END AS Src, URL AS Dst, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 GROUP BY TraficSourceID, SearchEngineID, AdvEngineID, Src, Dst ORDER BY PageViews DESC LIMIT 10 OFFSET 1000; +SELECT URLHash, EventDate, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND TraficSourceID IN (-1, 6) AND RefererHash = 3594120000172545465 GROUP BY URLHash, EventDate ORDER BY PageViews DESC LIMIT 10 OFFSET 100; +SELECT WindowClientWidth, WindowClientHeight, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND IsRefresh = 0 AND DontCountHits = 0 AND URLHash = 2868770270353813622 GROUP BY WindowClientWidth, WindowClientHeight ORDER BY PageViews DESC LIMIT 10 OFFSET 10000; +SELECT DATE_TRUNC('minute', EventTime) AS M, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= '2013-07-14' AND EventDate <= '2013-07-15' AND IsRefresh = 0 AND DontCountHits = 0 GROUP BY DATE_TRUNC('minute', EventTime) ORDER BY DATE_TRUNC('minute', EventTime) LIMIT 10 OFFSET 1000; diff --git a/scramdb/query b/scramdb/query new file mode 100755 index 0000000000..25f5fc45c0 --- /dev/null +++ b/scramdb/query @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +query=$(cat) + +raw=$(psql -t -c '\timing' -c "$query" 2>&1) && exit_code=0 || exit_code=$? + +if [ "$exit_code" -ne 0 ] || printf '%s\n' "$raw" | grep -qE '^ERROR|psql: error'; then + printf '%s\n' "$raw" >&2 + exit 1 +fi + +printf '%s\n' "$raw" | grep -v '^Time:' || true + +ms=$(printf '%s\n' "$raw" | grep -oP 'Time:\s*\K[0-9.]+' | tail -n1) +if [ -z "$ms" ]; then + echo "no Time: in psql output" >&2 + exit 1 +fi + +LC_ALL=C printf '%.3f\n' "$(echo "$ms / 1000" | bc -l)" >&2 diff --git a/scramdb/start b/scramdb/start new file mode 100755 index 0000000000..4973c69866 --- /dev/null +++ b/scramdb/start @@ -0,0 +1,19 @@ +#!/bin/bash +set -eu + +IMAGE="${SCRAMDB_IMAGE:-scramdb/scramdb:d563548}" +PORT="${PGPORT:-5432}" + +if sudo docker inspect scramdb >/dev/null 2>&1; then + sudo docker start scramdb +else + sudo docker run -d --name scramdb \ + --privileged \ + --cap-add=IPC_LOCK \ + --ulimit memlock=-1:-1 \ + -p "${PORT}:5432" \ + -v "$PWD:/bench:ro" \ + -v "$PWD/db:/var/lib/scramdb" \ + -v "$PWD/scramdb-config.toml:/etc/scramdb/config.toml:ro" \ + "$IMAGE" +fi diff --git a/scramdb/stop b/scramdb/stop new file mode 100755 index 0000000000..480bdc9bcf --- /dev/null +++ b/scramdb/stop @@ -0,0 +1,2 @@ +#!/bin/bash +sudo docker stop scramdb 2>/dev/null || true diff --git a/scramdb/template.json b/scramdb/template.json new file mode 100644 index 0000000000..6da71701f2 --- /dev/null +++ b/scramdb/template.json @@ -0,0 +1,13 @@ +{ + "system": "ScramDB", + "proprietary": "yes", + "hardware": "cpu", + "tuned": "no", + "tags": [ + "Rust", + "column-oriented", + "PostgreSQL compatible", + "UTAP", + "JIT" + ] +}