chadtmiller.com/monolith
An atproto PDS
0
0
Benchmark: tranquil beside the others, on PostgreSQL
bench/impls.json+14−0
| @@ -33,6 +33,15 @@ | ||
"dockerfile": "Dockerfile", | ||
"tag": "monolith-bench-zds:cef2c63" | ||
}, | ||
"tranquil": { | ||
"source": "https://tangled.org/tranquil.farm/tranquil-pds, built from source with its own Dockerfile, for this machine's architecture; on PostgreSQL, its default repository backend", | ||
"repo": "https://tangled.org/tranquil.farm/tranquil-pds", | ||
"release": "v0.8.0", | ||
"commit": "ce17e8a4948aa216c6c1056122966a11b8a693c8", | ||
"dockerfile": "Dockerfile", | ||
"tag": "monolith-bench-tranquil:ce17e8a", | ||
"needs": ["postgres"] | ||
}, | ||
"pds.js": { | ||
"source": "knotless://chadtmiller.com/pds.js, built from source with its own Dockerfile, for this machine's architecture; run by the compatibility check only, as it hosts one account and the benchmark's workload makes 40", | ||
"repo": "knotless://chadtmiller.com/pds.js", | ||
| @@ -47,6 +56,11 @@ | ||
"about": "RustFS, the S3 store vlpds's rounds use; passed vlpds-bucket-probe (bench/README.md)", | ||
"release": "rustfs/rustfs:1.0.4", | ||
"image": "rustfs/rustfs@sha256:ed9210d6411d77ffceb70d94b964a3cb7d225983368bc25bebe01e995293dcc2" | ||
}, | ||
"postgres": { | ||
"about": "PostgreSQL, tranquil's database, as its compose files run it (postgres:18-alpine)", | ||
"release": "postgres:18.7-alpine", | ||
"image": "postgres@sha256:1018733457011bf88d81db98cf43aac6d5150afc18787dbe204771fedf80ff95" | ||
} | ||
} | ||
} | ||
bench/README.md+57−30
| @@ -15,6 +15,8 @@ writes the tables in [`RESULTS.md`](RESULTS.md) (its raw numbers in | ||
| vlpds | its release image `ghcr.io/jazware/vlpds`, v1.3.0 (commit `91fa452`) | image digest in `impls.json` | | ||
| RustFS (vlpds's S3 store) | `rustfs/rustfs` 1.0.4 | image digest in `impls.json` | | ||
| zds | `tangled.org/zat.dev/zds` v0.7.8, built by `--setup` with its own `Dockerfile` for this machine's architecture, tagged `monolith-bench-zds:cef2c63` | repository URL and commit `cef2c63` in `impls.json` | | ||
| tranquil | `tangled.org/tranquil.farm/tranquil-pds` v0.8.0, built by `--setup` with its own `Dockerfile` for this machine's architecture, tagged `monolith-bench-tranquil:ce17e8a` | repository URL and commit `ce17e8a` in `impls.json` | | ||
| PostgreSQL (tranquil's database) | `postgres` 18.7, Alpine, as tranquil's compose files run it | image digest in `impls.json` | | ||
| pds.js | `knotless://chadtmiller.com/pds.js` main at `54f4e3a` (35 commits past v2.5.2), built by `--setup` with its own `Dockerfile`, tagged `monolith-bench-pdsjs:54f4e3a`; run by the compatibility check only (compat/README.md), as it hosts one account and the workload makes 40 | repository URL and commit `54f4e3a` in `impls.json` | | ||
| ||
Monolith and the reference are also built outside Docker by `--setup` | ||
| @@ -26,6 +28,13 @@ predates v0.7.8, so the bench builds its own from the pinned commit. The | ||
Dockerfile fetches Zig 0.17.0 (checked against its SHA-256) and zds's Zig | ||
dependencies (pinned by hash in its `build.zig.zon`) while it builds. | ||
| ||
tranquil's published image (`atcr.io/tranquil.farm/tranquil-pds`) needs a | ||
login to pull, so the bench builds its own from the pinned commit, as its | ||
docs build from source. The Dockerfile fetches its pnpm and crates while it | ||
builds, and UPX (checked against its SHA-256), which compresses the binary | ||
by default. tranquil runs on PostgreSQL, its default repository backend | ||
(`tranquil-store`, its embedded one, is the other). | ||
| ||
vlpds keeps all its data in an S3 bucket and needs strongly consistent | ||
conditional writes (`If-None-Match: *`, `If-Match`) from it. The store is | ||
**RustFS**, chosen by running vlpds's own `vlpds-bucket-probe` (in the vlpds | ||
| @@ -53,14 +62,14 @@ docker run --rm --network probe -e VLPDS_S3_ENDPOINT=http://s3:9000 -e VLPDS_S3_ | ||
| Node | 24 (24.22.1) | the bench client and the PLC directory | | ||
| npm | 11 (11.19.1) | installs the harness's packages from `harness/package-lock.json` | | ||
| rustup | 1.28+ (1.29.1) | builds Monolith outside Docker on `stable`, for the compatibility check (setup installs the toolchain) | | ||
| Docker | 28 (Docker Desktop 28.0.1; its Linux VM 8 CPUs, 7.7 GiB) | runs every server, and builds the images of Monolith, the reference, zds and pds.js; `host.docker.internal` must reach the host | | ||
| git | any recent (2.50.1) | fetches zds and pds.js at their pinned commits, and names the commit Monolith's image is built from | | ||
| Docker | 28 (Docker Desktop 28.0.1; its Linux VM 8 CPUs, 7.7 GiB) | runs every server, and builds the images of Monolith, the reference, zds, tranquil and pds.js; `host.docker.internal` must reach the host | | ||
| git | any recent (2.50.1) | fetches zds, tranquil and pds.js at their pinned commits, and names the commit Monolith's image is built from | | ||
| git-remote-knotless | any | lets git fetch pds.js's `knotless://` repository | | ||
| sccache | optional (0.19.0) | `export RUSTC_WRAPPER=sccache` before setup makes rebuilds outside Docker faster | | ||
| ||
Setup needs the network (crates.io, npm, Docker Hub, ghcr.io, tangled.org, | ||
ziglang.org); the bench itself talks only to loopback and Docker's local | ||
network. | ||
ziglang.org, github.com); the bench itself talks only to loopback and | ||
Docker's local network. | ||
| ||
It runs by hand, on a machine of its own with Docker, not on the runner: a | ||
job there is a container with no Docker of its own (no socket, and no room | ||
| @@ -101,11 +110,13 @@ first, the baseline the others are read against. | ||
4. unless Docker has the image `monolith-bench-zds:cef2c63` already, fetches | ||
**zds** at its pinned commit into `bench/vendor/zds` (gitignored) and | ||
builds that image with zds's own `Dockerfile` (`docker build`, a few | ||
minutes the first time); and **pds.js** the same way, into | ||
minutes the first time); **tranquil** the same way, into | ||
`bench/vendor/tranquil`, as `monolith-bench-tranquil:ce17e8a` (a Rust | ||
workspace: the longest build of them); and **pds.js**, into | ||
`bench/vendor/pds.js`, as `monolith-bench-pdsjs:54f4e3a`, for the | ||
compatibility check; | ||
5. pulls the **vlpds** and **RustFS** images by digest, unless Docker has | ||
them already. | ||
5. pulls the **vlpds**, **RustFS** and **PostgreSQL** images by digest, | ||
unless Docker has them already. | ||
| ||
It is idempotent. A run refuses to start if an image it needs is missing, | ||
or if Monolith's or the reference's image was built from other inputs than | ||
| @@ -126,7 +137,9 @@ Each round is a fresh server on fresh data, registering accounts with a fresh | ||
in-memory PLC directory (`@did-plc/server`) run by the bench. Each server is | ||
a container of its own, made with a fresh volume before the start clock and | ||
removed after the round; for vlpds, a round also makes a fresh Docker | ||
network, RustFS container and volume, and its cache on a volume of its own. | ||
network, RustFS container and volume, and its cache on a volume of its own; | ||
for tranquil, a fresh Docker network and PostgreSQL container and volume, | ||
ready for connections before the start clock. | ||
The server is warmed first, each part and route at a tenth of its size on | ||
accounts of its own; then the parts run in order: | ||
| ||
| @@ -222,8 +235,11 @@ their own. | ||
Per server: start time (`docker start` of its container, made already, to | ||
the first answered `describeServer`), its RSS 2 s after start (idle) and the | ||
most sampled through the round (peak), from `docker top` inside the | ||
container (its own process: `pds`, Node's `MainThread`, `vlpds` or `zds`). vlpds's | ||
store's RSS is sampled the same way and reported in a table of its own. | ||
container (its own process: `pds`, Node's `MainThread`, `vlpds`, `zds` or | ||
`tranquil-pds`). vlpds's store's RSS is sampled the same way, the sum over | ||
its container's processes, and tranquil's database's as the sum of its | ||
processes' PSS, as they share its buffers, which a sum of their RSS would | ||
count in every one that touched them; each in a table of its own. | ||
| ||
Per server, too, what it keeps on disk, from a **storage round** of its own, | ||
run after its speed rounds (`--storage-rounds N`, 1 by default; the median | ||
| @@ -238,17 +254,22 @@ same variable), vlpds's `VLPDS_LOG_RETENTION` (its log segment retention, | ||
which is its firehose backfill window), with `VLPDS_LOG_RETENTION_INTERVAL` | ||
at W / 2 so that a retention pass falls within the quiet. zds has no such | ||
setting (none of the `ZDS_*` variables its binary reads is a window or an | ||
event retention), so its storage round runs on what it keeps by default, | ||
and the table says so. | ||
event retention), and tranquil none that reaches W: its window, | ||
`FIREHOSE_BACKFILL_HOURS`, is in whole hours, and it prunes events once a | ||
minute at most, never more recent than that window. Their storage rounds | ||
run on what they keep by default, and the table says so. | ||
| ||
What a server keeps is the sum of the sizes of the files on its | ||
container's volume (`find -type f` and `stat` inside it): Monolith's `/data`, its data | ||
directory; the reference's `/data`, its `dataDirectory` and | ||
`blobstoreDiskLocation`; zds's `/data`, its database and blobs; vlpds's | ||
`/var/lib/vlpds`, only its SST cache. Each server's log goes to `docker | ||
logs`, not there. vlpds's bucket, the files on its RustFS container's | ||
volume, is measured the same way at the same moments and reported in a | ||
table of its own, as its store's RSS is. | ||
container's volume (`find -type f` and `stat` inside it, or, for tranquil, | ||
whose image has no shell, in a container of PostgreSQL's image given its | ||
volumes): Monolith's `/data`, its data directory; the reference's `/data`, | ||
its `dataDirectory` and `blobstoreDiskLocation`; zds's `/data`, its database | ||
and blobs; vlpds's `/var/lib/vlpds`, only its SST cache; tranquil's | ||
`/var/lib/tranquil-pds/blobs`, only its blobs. Each server's log goes to | ||
`docker logs`, not there. vlpds's bucket, the files on its RustFS | ||
container's volume, and tranquil's database, the files on its PostgreSQL | ||
container's `/var/lib/postgresql`, are measured the same way at the same | ||
moments and reported in a table of their own, as their RSS is. | ||
| ||
- **Under load**: once the parts end, after replay. | ||
- **At rest**, as `spec/STORE.md`, "Bounds", settles it: after the parts, | ||
| @@ -280,9 +301,14 @@ table of its own, as its store's RSS is. | ||
its docs' single-node `tiny` profile; zds as its deployment docs run it | ||
(database and blobs under `/data`), with no general rate limits to turn | ||
off, so its one limit the workload hits, 4 full `getRepo` exports at once, | ||
is raised to the 8 the workload runs. Each adapter's `info()` records its | ||
exact configuration and durability, kept in `results.json`, and | ||
`RESULTS.md` lists them. | ||
is raised to the 8 the workload runs; tranquil as its container docs run | ||
it, on PostgreSQL at its defaults, with the same limit raised the same | ||
way, and two more of its gates off: the one that holds an account's | ||
logins and record writes until it verifies its email (no mail leaves the | ||
machine to verify), and the one that keeps it from fetching private | ||
addresses, where the bench's PLC directory is. Each adapter's `info()` | ||
records its exact configuration and durability, kept in `results.json`, | ||
and `RESULTS.md` lists them. | ||
- The same workload, warm-up and number of rounds (three) for every server. | ||
- A part a server cannot serve is not dropped: its table says why. | ||
- Only the same work is set side by side: a route's rows are that route's | ||
| @@ -301,14 +327,15 @@ table of its own, as its store's RSS is. | ||
uses beside it, each under `images` by digest. | ||
2. **Write its adapter** in `ADAPTERS` in `harness/bench.mjs`: `comm`, the | ||
name of its process in its container; `volume`, the directory in its | ||
container that holds all it keeps; `setup({ port, plcUrl, dataDir, log, | ||
backfillMs })`, which makes its container (and whatever runs beside it) | ||
before the start clock and answers `{ name, teardown }`, with `beside: { | ||
name, rssKiB, diskBytes }` when what runs beside it has memory and data | ||
of its own to report; `window`, how `backfillMs` (given in a storage | ||
round only) sets its backfill window, or `noWindow`, why nothing does; | ||
`start({ port, aux })` answering `{ url, exited, stop }`; `info()` | ||
(version, commit, source, storage, durability, configuration); | ||
container that holds all it keeps; `reader`, if its image has no shell, | ||
an image with one to read that volume from; `setup({ port, plcUrl, | ||
dataDir, log, backfillMs })`, which makes its container (and whatever | ||
runs beside it) before the start clock and answers `{ name, teardown }`, | ||
with `beside: { name, rssKiB, diskBytes }` when what runs beside it has | ||
memory and data of its own to report; `window`, how `backfillMs` (given | ||
in a storage round only) sets its backfill window, or `noWindow`, why | ||
nothing does; `start({ port, aux })` answering `{ url, exited, stop }`; | ||
`info()` (version, commit, source, storage, durability, configuration); | ||
optionally `accountBody(i, tag)` (handles under its domain, invite | ||
codes); and `unsupported`, each part it cannot serve with why. | ||
3. Run `node bench.mjs --setup`, then `node bench.mjs --impls <name> --rounds 1` | ||
bench/results.json+3141−1896
A large diff, not shown.
bench/RESULTS.md+256−183
439 lines changed: not loaded until asked for.
compat/README.md+1−1
| @@ -18,7 +18,7 @@ or by hand: | ||
| ||
```sh | ||
cd harness | ||
node bench.mjs --setup # once: Monolith's binary, and the zds, vlpds and pds.js images (bench/README.md) | ||
node bench.mjs --setup # once: Monolith's binary, and the other implementations' images (bench/README.md) | ||
node compat.mjs --steps 200 --json ../compat/results.json > ../compat/tables.md | ||
node compat.mjs --report ../compat/results.json # the tables again | ||
``` | ||
harness/lib/impls.mjs+71−0
| @@ -53,6 +53,15 @@ export const containerRssKiB = async (name, comm) => { | ||
const rows = (await sh('docker', ['top', name, '-o', 'pid,rss,comm'])).split('\n').slice(1).map((l) => l.trim().split(/\s+/)) | ||
return rows.filter(([, , c]) => !comm || c === comm).reduce((sum, [, rss]) => sum + (Number(rss) || 0), 0) | ||
} | ||
/// The PSS of a container's processes named `comm`, in KiB: each page they | ||
/// share counted once, split among them, where the sum of their RSS counts | ||
/// it in each (PostgreSQL's shared buffers, in every backend that touched | ||
/// them). Read in the container from /proc/<pid>/smaps_rollup as `user`, | ||
/// theirs: root there may not read another user's. | ||
export const containerPssKiB = async (name, user, comm) => { | ||
const out = await sh('docker', ['exec', '-u', user, name, 'sh', '-c', 'for p in /proc/[0-9]*; do [ "$(cat "$p/comm" 2>/dev/null)" = "$1" ] && grep "^Pss:" "$p/smaps_rollup" 2>/dev/null; done; true', 'sh', comm]) | ||
return out.split('\n').reduce((sum, l) => sum + (Number(l.split(/\s+/)[1]) || 0), 0) | ||
} | ||
/// A container's log, appended to the file `log` (a descriptor). | ||
export const containerLogs = (name, log) => new Promise((ok) => execFile('docker', ['logs', name], { maxBuffer: 1 << 30 }, (_, out, err) => { | ||
writeSync(log, `---- docker logs ${name}\n${out ?? ''}${err ?? ''}`) | ||
| @@ -185,6 +194,68 @@ export const zdsCreateArgs = ({ name, port, env, image = pins.implementations.zd | ||
...Object.entries(env).flatMap(([k, v]) => ['-e', `${k}=${v}`]), image, | ||
] | ||
| ||
// ---- tranquil ------------------------------------------------------------ | ||
| ||
// tranquil as its container deployment runs it (docs/2_INSTALL_CONTAINERS.md, | ||
// docker-compose.prod.yaml): on PostgreSQL, its default repository backend, | ||
// as the database `pds` of a postgres:18-alpine beside it; blobs as files | ||
// under /var/lib/tranquil-pds/blobs; its in-process cache (ripple, one | ||
// node). Plus the bench's own: rate limits off and no invite codes, as for | ||
// the others; the gate that holds an account's logins and record writes | ||
// until it verifies an email or other channel off (no mail leaves the | ||
// machine to verify, and the others have no such gate); private addresses | ||
// fetchable, so it reaches the bench's PLC directory through | ||
// host.docker.internal; no relays asked to crawl; and its one limit the | ||
// workload hits lifted, as zds's: full getRepo exports at once, 4 by default | ||
// and refused past that, raised to the 8 getRepo runs at once. No mail is | ||
// sent: with no sender address, its email is off. | ||
export const tranquilEnv = { | ||
PDS_HOSTNAME: 'tranquil.test', | ||
INVITE_CODE_REQUIRED: 'false', | ||
DISABLE_RATE_LIMITING: 'true', | ||
DISABLE_ACCOUNT_VERIFICATION_GATE: 'true', | ||
ALLOW_PRIVATE_FETCH: 'true', | ||
// A list of none: an empty value would be taken as unset, its defaults. | ||
CRAWLERS: ',', | ||
MAX_CONCURRENT_REPO_EXPORTS: '8', | ||
} | ||
| ||
/// A fresh PostgreSQL for tranquil on the Docker network `network`, as | ||
/// `db:5432` there, its data on a fresh volume, ready for connections over | ||
/// TCP (its entrypoint's first server, which makes the database, listens on | ||
/// none): answers its container's name and the URL tranquil reaches it at. | ||
export async function startPostgres(network, name) { | ||
const password = randomBytes(24).toString('hex') | ||
await shOk('docker', ['run', '-d', '--name', name, '--network', network, '--network-alias', 'db', '-v', '/var/lib/postgresql', '-e', 'POSTGRES_USER=tranquil_pds', '-e', `POSTGRES_PASSWORD=${password}`, '-e', 'POSTGRES_DB=pds', pins.images[pins.implementations.tranquil.needs[0]].image]) | ||
for (let t = performance.now(); ; ) { | ||
if ((await sh('docker', ['exec', name, 'sh', '-c', 'pg_isready -q -h 127.0.0.1 -U tranquil_pds -d pds && echo ready'])) === 'ready') break | ||
if (performance.now() - t > 60000) throw new Error(`PostgreSQL ${name}: not ready within 60 s`) | ||
await new Promise((ok) => setTimeout(ok, 200)) | ||
} | ||
return { name, url: `postgres://tranquil_pds:${password}@db:5432/pds` } | ||
} | ||
| ||
/// tranquil's environment besides `tranquilEnv`: its database at `db` | ||
/// (startPostgres), and fresh secrets, each 48 random bytes as base64, as | ||
/// its docs make them. It signs PLC operations with each account's own key, | ||
/// so it needs no rotation key. | ||
export const tranquilOwnEnv = ({ plcUrl, db }) => ({ | ||
DATABASE_URL: db.url, | ||
PLC_DIRECTORY_URL: fromDocker(plcUrl), | ||
JWT_SECRET: randomBytes(48).toString('base64'), | ||
DPOP_SECRET: randomBytes(48).toString('base64'), | ||
MASTER_KEY: randomBytes(48).toString('base64'), | ||
}) | ||
| ||
/// `docker create`'s arguments for tranquil as `name` on `network`, its | ||
/// port 3000 (the image's SERVER_PORT, on SERVER_HOST [::]) on loopback's | ||
/// `port`, its blobs on a fresh volume, with `env`, from `image` (by default | ||
/// its pinned tag). | ||
export const tranquilCreateArgs = ({ name, network, port, env, image = pins.implementations.tranquil.tag }) => [ | ||
'create', '--name', name, '--network', network, '-p', `127.0.0.1:${port}:3000`, '--add-host', 'host.docker.internal:host-gateway', '-v', '/var/lib/tranquil-pds/blobs', | ||
...Object.entries(env).flatMap(([k, v]) => ['-e', `${k}=${v}`]), image, | ||
] | ||
| ||
// ---- pds.js -------------------------------------------------------------- | ||
| ||
// pds.js as its container runs it (docs/deploy-docker.md, its Dockerfile): | ||
harness/bench.mjs+86−12
| @@ -29,7 +29,7 @@ import { existsSync, mkdirSync, mkdtempSync, openSync, readFileSync, rmSync, wri | ||
import { cpus, loadavg, release, totalmem, tmpdir, type } from 'node:os' | ||
import { join } from 'node:path' | ||
import { openPool, timedFetch } from './lib/loadpool.mjs' | ||
import { VLPDS_MEM_MIB, containerLogs, containerRssKiB, dockerPort, fromDocker, imageId, pins, root, sh, shOk, startRustfs, vlpdsArgs, vlpdsCreateArgs, vlpdsEnv, vlpdsOwnEnv, zdsCreateArgs, zdsEnv, zdsOwnEnv } from './lib/impls.mjs' | ||
import { VLPDS_MEM_MIB, containerLogs, containerPssKiB, containerRssKiB, dockerPort, fromDocker, imageId, pins, root, sh, shOk, startPostgres, startRustfs, tranquilCreateArgs, tranquilEnv, tranquilOwnEnv, vlpdsArgs, vlpdsCreateArgs, vlpdsEnv, vlpdsOwnEnv, zdsCreateArgs, zdsEnv, zdsOwnEnv } from './lib/impls.mjs' | ||
| ||
const here = new URL('.', import.meta.url).pathname | ||
// What each implementation runs, pinned: bench/impls.json (lib/impls.mjs). | ||
| @@ -173,9 +173,11 @@ async function main() { | ||
const vlpdsRetention = (ms) => ({ retention: ms % 1000 ? `${ms}ms` : `${ms / 1000}s`, interval: `${Math.min(600, Math.max(1, Math.round(ms / 2000)))}s` }) | ||
/// The sum of the sizes of the files under `dir` in the running container | ||
/// `name` (its volume): find and stat in the container, as root (stat, as | ||
/// BusyBox's find, in RustFS's image, has no -printf). | ||
async function containerBytes(name, dir) { | ||
const out = await shOk('docker', ['exec', '-u', '0', name, 'sh', '-c', 'find "$1" -type f -exec stat -c %s {} + 2>/dev/null; true', 'sh', dir]) | ||
/// BusyBox's find, in RustFS's image, has no -printf); or, where its image | ||
/// has no shell, in a container of the image `reader` given its volumes. | ||
async function containerBytes(name, dir, reader) { | ||
const where = reader ? ['run', '--rm', '-u', '0', '--volumes-from', name, '--entrypoint', 'sh', reader] : ['exec', '-u', '0', name, 'sh'] | ||
const out = await shOk('docker', [...where, '-c', 'find "$1" -type f -exec stat -c %s {} + 2>/dev/null; true', 'sh', dir]) | ||
return out.split('\n').reduce((sum, l) => sum + (Number(l) || 0), 0) | ||
} | ||
| ||
| @@ -187,9 +189,10 @@ async function main() { | ||
// reaches it on a loopback port; each is told its URL is that port. | ||
// `comm` is the server's process in its container, whose RSS and threads | ||
// are the server's; `volume` the directory in it that holds all it keeps | ||
// (its log goes to `docker logs`, not there). `setup` is given | ||
// `backfillMs` in a storage round only; `window` says how it sets the | ||
// server's backfill window, or `noWindow` why nothing does. | ||
// (its log goes to `docker logs`, not there), and `reader`, where its | ||
// image has no shell to read that with, an image that has one. `setup` is | ||
// given `backfillMs` in a storage round only; `window` says how it sets | ||
// the server's backfill window, or `noWindow` why nothing does. | ||
const ADAPTERS = { | ||
// Monolith as its deployment builds and runs it: the repository's | ||
// Dockerfile (docs/guide/deploying.md), its data on the volume /data, | ||
| @@ -408,6 +411,75 @@ async function main() { | ||
firehoseLoaded: 'its live firehose skips commits when writes come at once: of a warm-up of 40 putRecords, 4 at once to 4 accounts, each of 20 subscribers was sent 34 to 37 (its log: `subscribeRepos end start_cursor=466 end_cursor=506 frames=35`), so no lag can be timed for the rest', | ||
}, | ||
}, | ||
// Tranquil, a PDS in Rust, its image built by --setup from its own | ||
// Dockerfile at the pinned commit (bench/impls.json), on PostgreSQL, its | ||
// default repository backend: each round a fresh Docker network, a fresh | ||
// PostgreSQL container on it with its data on a fresh volume, and a | ||
// fresh tranquil container, configured as lib/impls.mjs configures it, | ||
// with fresh secrets; all made in `setup`. | ||
tranquil: { | ||
comm: 'tranquil-pds', | ||
// Its blobs alone: everything else is in PostgreSQL, beside it. | ||
volume: '/var/lib/tranquil-pds/blobs', | ||
// Its image is distroless, with no shell: PostgreSQL's has one. | ||
reader: pins.images.postgres.image, | ||
noWindow: 'its backfill window is FIREHOSE_BACKFILL_HOURS, in whole hours (72 by default), and it prunes the events past EVENT_RETENTION_MAX_AGE_SECS (7 days by default, and never less than that window) once a minute at most: nothing sets a window of W with a pass in the quiet, so at rest is measured with what it keeps by default', | ||
async info() { | ||
const pin = pins.implementations.tranquil | ||
const db = pins.images[pin.needs[0]] | ||
return { | ||
version: `${pin.release} (its Cargo.toml's workspace version 0.8.0)`, | ||
commit: pin.commit, | ||
source: `${pin.repo} at ${pin.commit}, image ${await imageAbout(pin.tag)} built with its own ${pin.dockerfile}; database ${db.image} (${db.release}); ${await dockerAbout()}`, | ||
storage: 'PostgreSQL (its default repository backend), one database on a Docker volume, through a pool of 10 to 100 connections: accounts, records, repository blocks and the event sequence in its tables; blobs as files under /var/lib/tranquil-pds/blobs, on a Docker volume of its own; its cache in its process (ripple, one node)', | ||
durability: 'PostgreSQL at its defaults, which tranquil leaves as they are: fsync on, synchronous_commit on, so a write is answered once its transaction\'s WAL is flushed (fdatasync(2), wal_sync_method\'s Linux default). Blobs written to a temp file, fsynced (sync_all) and renamed into place, the directory not fsynced. On the Docker VM\'s virtual disk', | ||
config: `docker run -v /var/lib/tranquil-pds/blobs on a Docker network of its own; ${Object.entries(tranquilEnv).map(([k, v]) => `${k}=${v}`).join(' ')}; DATABASE_URL the round's PostgreSQL, PLC_DIRECTORY_URL=http://host.docker.internal:<bench PLC port>; fresh random JWT_SECRET, DPOP_SECRET and MASTER_KEY each round; handles under its hostname (user_handle_domains unset); the image's SERVER_HOST=[::], SERVER_PORT=3000; its binary UPX-compressed, as its Dockerfile builds it by default. PostgreSQL: ${db.release} with POSTGRES_USER=tranquil_pds, POSTGRES_DB=pds and a fresh password, its defaults otherwise (max_connections 100, shared_buffers 128 MB), its data on a fresh volume`, | ||
} | ||
}, | ||
async setup({ port, plcUrl, log }) { | ||
const id = `bench-tranquil-${process.pid}-${Date.now()}` | ||
const store = `${id}-db` | ||
const pds = `${id}-pds` | ||
const teardown = async () => { | ||
await containerLogs(pds, log) | ||
await sh('docker', ['rm', '-f', '-v', pds]) | ||
await sh('docker', ['rm', '-f', '-v', store]) | ||
await sh('docker', ['network', 'rm', id]) | ||
} | ||
try { | ||
await shOk('docker', ['network', 'create', id]) | ||
const db = await startPostgres(id, store) | ||
await shOk('docker', tranquilCreateArgs({ name: pds, network: id, port, env: { ...tranquilEnv, ...tranquilOwnEnv({ plcUrl, db }) } })) | ||
} catch (e) { | ||
await teardown() | ||
throw e | ||
} | ||
return { | ||
name: pds, | ||
// PostgreSQL's memory, and its data directory (the files on its | ||
// volume), apart from tranquil's. Its memory is its processes' | ||
// PSS, not their RSS: the sum of their RSS counts the shared | ||
// buffers once in every backend that touched them. | ||
beside: { name: 'PostgreSQL', rssKiB: () => containerPssKiB(store, 'postgres', 'postgres'), diskBytes: () => containerBytes(store, '/var/lib/postgresql') }, | ||
teardown, | ||
} | ||
}, | ||
async start({ port, aux }) { | ||
await shOk('docker', ['start', aux.name]) | ||
return { | ||
url: `http://127.0.0.1:${port}`, | ||
exited: running(aux.name), | ||
async stop() { | ||
// SIGTERM: it shuts down gracefully on it. | ||
await sh('docker', ['stop', aux.name]) | ||
}, | ||
} | ||
}, | ||
// Handles under its one handle domain, its hostname; a password with | ||
// an upper-case letter, as it requires one. | ||
accountBody: (i, tag) => ({ handle: `${tag}${i}.tranquil.test`, email: `${tag}${i}@example.com`, password: `Bench-password-${i}` }), | ||
unsupported: {}, | ||
}, | ||
} | ||
const accountBody = (i, tag) => ({ handle: `${tag}${i}.test`, email: `${tag}${i}@example.com`, password: `bench-password-${i}` }) | ||
| ||
| @@ -863,7 +935,8 @@ async function main() { | ||
const startMs = performance.now() - t0 | ||
await new Promise((ok) => setTimeout(ok, 2000)) | ||
const idleKiB = (await sample()).rssKiB | ||
// Something beside the server with memory of its own (vlpds's store). | ||
// Something beside the server with memory of its own (vlpds's store, | ||
// tranquil's database). | ||
const beside = aux.beside | ||
const besideIdleKiB = beside ? await beside.rssKiB() : undefined | ||
let peakKiB = idleKiB | ||
| @@ -916,9 +989,10 @@ async function main() { | ||
await sampler | ||
await besideSampler | ||
// What it keeps on disk: the files on its container's volume; and | ||
// apart, what it needs beside it (vlpds's bucket). | ||
// apart, what it needs beside it (vlpds's bucket, tranquil's | ||
// database). | ||
const besideDisk = beside?.diskBytes ? beside : null | ||
const sizes = async () => ({ server: await containerBytes(aux.name, adapter.volume), ...(besideDisk && { beside: await besideDisk.diskBytes() }) }) | ||
const sizes = async () => ({ server: await containerBytes(aux.name, adapter.volume, adapter.reader), ...(besideDisk && { beside: await besideDisk.diskBytes() }) }) | ||
step('storage under load') | ||
const underLoad = await sizes() | ||
// At rest: no request for 2 W + 1 s, then a write to each account the | ||
| @@ -1245,7 +1319,7 @@ function markdown(results) { | ||
lines.push('') | ||
const withBeside = names.filter((name) => results.impls[name].rounds.some((x) => x.beside)) | ||
if (withBeside.length) { | ||
lines.push('Not in the table above: what a server needs running beside it, its RSS sampled apart (the sum over its container\'s processes, from `docker top`, as fast as that answers).', '') | ||
lines.push('Not in the table above: what a server needs running beside it, its RSS sampled apart (the sum over its container\'s processes, from `docker top`, as fast as that answers; for PostgreSQL, whose processes share its buffers, the sum of their PSS, which counts each shared page once).', '') | ||
lines.push('| impl | beside it | idle MiB (median) | peak MiB (best) | peak MiB (median) |', '|---|---|--:|--:|--:|') | ||
for (const name of withBeside) { | ||
const xs = results.impls[name].rounds.map((x) => x.beside) | ||
| @@ -1269,7 +1343,7 @@ function markdown(results) { | ||
lines.push('', ...notes.flatMap((n) => [n, ''])) | ||
const withBesideDisk = stored.filter((name) => results.impls[name].storage.rounds.some((d) => d.beside)) | ||
if (withBesideDisk.length) { | ||
lines.push('Not in the table above: what a server keeps in what runs beside it (vlpds: its bucket, the files on RustFS\'s volume), measured the same way at the same moments; the last column counts the server\'s own and this together.', '') | ||
lines.push('Not in the table above: what a server keeps in what runs beside it (vlpds: its bucket, the files on RustFS\'s volume; tranquil: its database, the files on PostgreSQL\'s volume), measured the same way at the same moments; the last column counts the server\'s own and this together.', '') | ||
lines.push('| impl | beside it | under load MiB (median) | at rest MiB (median) | both at rest ÷ live (median) |', '|---|---|--:|--:|--:|') | ||
for (const name of withBesideDisk) { | ||
const ds = results.impls[name].storage.rounds | ||