Skip to content
Draft
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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
target/
__pycache__/
.claude/
# Evaluation results are never committed (docs/design/repo-layout.md).
eval/results/
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ cargo run -p control_plane -- \
cargo run -p data_plane -- --plan plan.json --prometheus-url http://localhost:9090
```

`deployment/Dockerfile` builds both binaries into one image
(`docker build -f deployment/Dockerfile -t asap-backend .` from the
repository root), and `deployment/docker-compose.yml` plans a workload
(`WORKLOAD`, Example 1 by default) and serves the plan on port 8088.

Besides Prometheus Remote Write, the data plane ingests VictoriaMetrics
Remote Write (the same protobuf, zstd-compressed) on `/api/v1/import` and
OTLP/HTTP metrics (protobuf, optionally gzip) on `/v1/metrics`, the routes
Expand Down Expand Up @@ -263,7 +268,7 @@ not stored) with a Prometheus `execution` error (422,
| `crates/adapters/query/prometheus-http/` | package `prometheus_http`: query parameters, response bodies and the fallback client of a Prometheus-compatible server |
| `benchmarks/` | the backend alone: `micro/` benchmarks (examples of `data_plane`) and `scripts/` |
| `eval/` | comparisons with other systems and the live demo; see [eval/README.md](eval/README.md) |
| `deployment/monitoring/` | Prometheus, exporters and Grafana for the demo and the comparisons |
| `deployment/` | the backend's Docker image (`Dockerfile`) and Compose file; `monitoring/`: Prometheus, exporters and Grafana for the demo and the comparisons |
| `docs/` | design documents and `examples/` workloads |
| `scripts/` | CI and the Planner dependency updater |

Expand Down
33 changes: 33 additions & 0 deletions deployment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# syntax=docker/dockerfile:1
# The backend's binaries in one image: control_plane (workload -> plan file)
# and data_plane (serves a plan: ingestion and query routes). Build from the
# repository root:
#
# docker build -f deployment/Dockerfile -t asap-backend .
# docker run --rm asap-backend data_plane --help
#
# deployment/docker-compose.yml plans a workload and serves the plan.
FROM rust:1.99.0-slim-bookworm AS build
# git: Cargo fetches the pinned git dependencies with the git CLI (.cargo/config.toml).
# make: tikv-jemalloc-sys builds jemalloc. cmake, g++, libclang-dev: highs-sys
# (the Planner's MILP solver) builds HiGHS and generates its bindings.
RUN apt-get update \
&& apt-get install -y --no-install-recommends git make cmake g++ libclang-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/src/target \
cargo build --release --locked -p control_plane -p data_plane \
&& install -m 0755 target/release/control_plane target/release/data_plane /usr/local/bin/

FROM debian:bookworm-20261104-slim
RUN useradd --system --uid 10001 --home-dir /data asap \
&& mkdir /data && chown asap /data
COPY --from=build /usr/local/bin/control_plane /usr/local/bin/data_plane /usr/local/bin/
USER asap
# data_plane writes its views (--view-dir, default asap-views) under the working directory.
WORKDIR /data
EXPOSE 8088
CMD ["data_plane", "--help"]
9 changes: 9 additions & 0 deletions deployment/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Build context for deployment/Dockerfile (the repository root): only what
# `cargo build` needs. BuildKit reads this file because it sits next to the
# Dockerfile.
**/target
.git
.worktrees
eval
deployment
docs
37 changes: 37 additions & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Plan a workload once with control_plane, then serve the plan with
# data_plane on port 8088 (Remote Write on /api/v1/write, the Prometheus
# query API on /api/v1/query[_range]). Run from this directory:
#
# docker compose up --build
# WORKLOAD=/path/to/workload.json PROMETHEUS_URL=http://prometheus:9090 docker compose up
# docker compose down -v
#
# WORKLOAD defaults to the planner-layering Example 1 in docs/examples.
# PROMETHEUS_URL answers the queries the plan does not; the default is a
# Prometheus on the Docker host.
services:
plan:
build:
context: ..
dockerfile: deployment/Dockerfile
image: asap-backend
command: ["control_plane", "--workload", "/workload.json", "--out", "/data/plan.json"]
volumes:
- ${WORKLOAD:-../docs/examples/planner-layering-example1.json}:/workload.json:ro
- data:/data

data-plane:
image: asap-backend
depends_on:
plan:
condition: service_completed_successfully
command: ["data_plane", "--plan", "/data/plan.json", "--listen", "0.0.0.0:8088", "--prometheus-url", "${PROMETHEUS_URL:-http://host.docker.internal:9090}"]
ports:
- "${DATA_PLANE_PORT:-8088}:8088"
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- data:/data

volumes:
data:
3 changes: 2 additions & 1 deletion deployment/monitoring/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# What the monitoring stack writes (eval/run_vm_demo.sh, eval/demo/run_live_demo.sh).
# What the monitoring stack writes (eval/scripts/run_vm_demo.sh, eval/demo/run_live_demo.sh).
/textfile/
/data/
/grafana/dashboards/
2 changes: 1 addition & 1 deletion deployment/monitoring/grafana/make_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def matrix_bars(title, grid, expr, column, unit, stacked, description):
target('sum(increase(vm_request_duration_seconds_sum{job="victoriametrics", '
'path="/api/v1/query"}[$__range]))', "D", "wall time in /api/v1/query", instant=True),
], "VictoriaMetrics exports total and GC CPU, and wall time per HTTP path (not CPU). "
"eval/profile/profile_query_phase.sh gives the function-level CPU profile.",
"eval/scripts/profile_query_phase.sh gives the function-level CPU profile.",
fieldConfig={"defaults": {"unit": "s", "min": 0, "color": {"mode": "palette-classic"}}},
options={"orientation": "horizontal", "displayMode": "basic", "showUnfilled": True,
"reduceOptions": {"calcs": ["lastNotNull"]}})
Expand Down
4 changes: 2 additions & 2 deletions deployment/monitoring/run_binaries.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# The monitoring stack of docker-compose.yml without docker: the same
# configs, run from the pinned release binaries in $BIN_DIR (fetched by
# eval/fetch_binaries.sh when missing). State lives in $MON_DATA.
# eval/scripts/fetch_binaries.sh when missing). State lives in $MON_DATA.
#
# deployment/monitoring/run_binaries.sh start|stop|status
#
Expand All @@ -28,7 +28,7 @@ start_one() { # name, command...

case "${1:-start}" in
start)
BIN_DIR=$BIN_DIR "$BASE/fetch_binaries.sh" prometheus node_exporter process_exporter grafana
BIN_DIR=$BIN_DIR "$BASE/scripts/fetch_binaries.sh" prometheus node_exporter process_exporter grafana
start_one prometheus "$BIN_DIR/prometheus-3.5.0" --config.file="$MON/prometheus/prometheus.yml" \
--storage.tsdb.path="$MON_DATA/prometheus" --storage.tsdb.retention.time=30d \
--web.listen-address=127.0.0.1:19090
Expand Down
59 changes: 45 additions & 14 deletions eval/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Evaluation: live demo and comparison tooling

Scripts that run the ASAP data plane next to VictoriaMetrics single-node on
the same Remote Write feed and the same queries, check both against a
reference, and show them on Grafana. Code and configuration only: no run
outputs are kept here (`results/` is git-ignored). Paths below are relative
to this directory, `$ASAPQ_BENCH`.
Scripts that run the ASAP data plane next to other systems (see
[Baselines](#baselines)) on the same Remote Write feed and the same queries,
check them against a reference, and show them on Grafana. Code and
configuration only: run outputs are git-ignored (`.gitignore`). Paths below
are relative to this directory, `$ASAPQ_BENCH`.

| Path | What it holds |
|---|---|
| `demo/run_live_demo.sh` | The live Grafana demo: feeders, the ASAP data plane, VictoriaMetrics, a reference VictoriaMetrics (accuracy), optionally Prometheus (`EXACT=1`), logging proxies, exporters, a watchdog and the query load. |
| `run_vm_demo.sh` | The batch comparison: prepare, run the arms one after another on one feed, report. |
| `fetch_binaries.sh`, `build.sh` | Pinned third-party binaries (sha256-checked); builds of the paced feeder and this repository into `$BIN_DIR`. |
| `scripts/run_vm_demo.sh` | The batch comparison: prepare, run the arms one after another on one feed, report. |
| `scripts/fetch_binaries.sh`, `scripts/build.sh` | Pinned third-party binaries (sha256-checked); builds of the paced feeder and this repository into `$BIN_DIR`. |
| `scripts/profile_query_phase.sh` | CPU profiles of each arm's query phase (`scripts/run_vm_demo.sh` with `PROFILE=1`). |
| `baselines/` | ClickHouse and Elasticsearch, the compared systems that run as their own service (`baselines/<system>/docker-compose.yml`); see [Baselines](#baselines). |
| `harness/` | `prepare.py` (scaled manifest, feeder table, the Planner's plan through `control_plane`), `run.py` (arms), `report.py`, `demo_table.py`, `tables.py`, `tables2.py`, `accuracy_vs_vm.py`, `compression.py`, `merge_plans.py`, `cgroup_limits.sh`. See `harness/README.md`. |
| `demo/live/` | The live demo's helpers: `proxy.py`, `query_load.py`, `accuracy.py`, `compare.py`, `verify.py`, `browse.py`, exporters, and `planner/cost_inputs.json`. |
| `../deployment/monitoring/` | Prometheus and process-exporter configuration, Grafana provisioning, the dashboard generators (`grafana/make_*_dashboard.py`), screenshots, Docker Compose or plain binaries (`run_binaries.sh`). |
| `profile/` | `profile_query_phase.sh` (`run_vm_demo.sh` with `PROFILE=1`). |
| `workloads/` | Workload manifests. |
| `campaign/` | Records of the multi-host campaign: workload generators (`gen_*.py`), job queue, scale sweep, reruns, collection and summaries, and `paced-feeder-realistic.diff` (realistic feeder values; `build.sh` applies it). |
| `campaign/` | Records of the multi-host campaign: workload generators (`gen_*.py`), job queue, scale sweep, reruns, collection and summaries, and `paced-feeder-realistic.diff` (realistic feeder values; `scripts/build.sh` applies it). |

`demo/live/demo_sequence*.sh`, `demo/live/chain_*.sh`, `demo/live/after_sequence_limits.sh`
and most of `campaign/` are records of the sequences that were run: they name
Expand All @@ -34,21 +35,21 @@ export BIN_DIR=/path/to/bin # pinned binaries and the built feeder/da
ln -s .. "$ASAPQ_BENCH/backend" # this repository
git clone https://github.com/ProjectASAP/ASAPQuery "$ASAPQ_BENCH/ASAPQuery" # paced_feeder
cd "$ASAPQ_BENCH"
./fetch_binaries.sh # VictoriaMetrics, Prometheus, exporters, Grafana, FlameGraph
./build.sh # paced_feeder, data_plane, control_plane into $BIN_DIR
scripts/fetch_binaries.sh # VictoriaMetrics, Prometheus, exporters, Grafana, FlameGraph
scripts/build.sh # paced_feeder, data_plane, control_plane into $BIN_DIR
```

| Variable | Used by | Meaning |
|---|---|---|
| `ASAPQ_BENCH` | all | the working directory above (required) |
| `BIN_DIR` | all | binaries (required) |
| `BENCH_ENV` | shell scripts | optional file sourced first (toolchain paths) |
| `ASAP_PLANNER_DIR` | `build.sh`, `harness/prepare.py` | an ASAPPlanner checkout (optional for `build.sh`; `prepare.py` checks Planner features by commit) |
| `ASAP_PLANNER_DIR` | `scripts/build.sh`, `harness/prepare.py` | an ASAPPlanner checkout (optional for `scripts/build.sh`; `prepare.py` checks Planner features by commit) |
| `BENCH_ROOT` | `demo/live/` records, `campaign/` | directory holding other builds, checkouts and scratch files |
| `CAMPAIGN_DIR` | `campaign/` | the job queue's directory on each host |
| `BENCH_HOSTS`, `BUILD_HOST`, `REF_HOST`, `ENGINE_SSH`, `ENGINE_ADDR`, `NET_IFACE` | `campaign/` | hosts as `ssh` resolves them (driver hosts, build host, reference replay host, engine host) and the engine link's interface |

The headers of `demo/run_live_demo.sh` and `run_vm_demo.sh` list every other
The headers of `demo/run_live_demo.sh` and `scripts/run_vm_demo.sh` list every other
variable (cpusets, limits, series, workloads, ports) with its default.
`harness/prepare.py` imports ASAPQuery's workload tools, so even `--help`
needs the ASAPQuery checkout.
Expand Down Expand Up @@ -76,7 +77,7 @@ here); without it they stay empty.
## Comparison

```sh
SERIES=1000 QUERY_PHASE_S=600 WORKLOADS="demo/dashboard-heavy" ./run_vm_demo.sh
SERIES=1000 QUERY_PHASE_S=600 WORKLOADS="demo/dashboard-heavy" scripts/run_vm_demo.sh
```

For each workload this prepares the plan (timed as a one-time offline
Expand All @@ -86,3 +87,33 @@ on the same feed and query schedule, each on its own cpuset, and writes
memory, disk, latency and accuracy; Grafana's `asap-vs-vm` dashboard
(`../deployment/monitoring/grafana/make_dashboard.py`) shows the runs.
`harness/README.md` describes the arms, flags and outputs.

## Baselines

The systems the backend is compared with. "Harness arm" means
`harness/run.py --arms` starts, feeds and queries it; the other systems run
as their own service and are, for now, only what the backend's routes forward
to. No results are kept here.

| System | Version pinned in | How it runs | Harness arm |
|---|---|---|---|
| Prometheus | `scripts/fetch_binaries.sh`, `harness/common.py` | binary from `scripts/fetch_binaries.sh`, flags in `harness/run.py` | `prometheus` (the exact reference), and beside `backend`, `backend_alone` and `asapquery` |
| VictoriaMetrics single-node | `scripts/fetch_binaries.sh`, `harness/common.py` | binary from `scripts/fetch_binaries.sh`, flags in `harness/run.py` (`VM_SEARCH_FLAGS`) | `victoriametrics`; the raw store of `asap_forward`; the reference of `demo/run_live_demo.sh` |
| VictoriaMetrics cluster | `harness/common.py` (the single-node release) | `vmstorage`, `vmselect`, `vminsert` installed by hand as `$BIN_DIR/<component>-<version>` (not fetched) | `vmcluster` |
| ASAPQuery query engine | the ASAPQuery checkout | `ASAPQUERY_ENGINE=1 scripts/build.sh` | `asapquery` |
| ClickHouse | `baselines/clickhouse/docker-compose.yml` | `docker compose -f baselines/clickhouse/docker-compose.yml up -d`, then `data_plane --clickhouse-url http://localhost:8123` | none yet |
| Elasticsearch | `baselines/elasticsearch/docker-compose.yml` | `docker compose -f baselines/elasticsearch/docker-compose.yml up -d`, then `data_plane --elastic-url http://localhost:9200` | none yet |

Not ported yet:

- ClickHouse and Elasticsearch arms in `harness/run.py`: loading the same
data into their tables or indexes, and SQL or Query DSL workloads. The
backend forwards every SQL and Query DSL query today (no planned SQL
answers), so such an arm would measure the forward path only.
- ASAPQuery's ClickHouse experiment runner and data loaders
(`asap-tools/experiments/experiment_run_clickhouse.py`, ClickBench and H2O
loads) and its Elasticsearch benchmarking scripts
(`asap-tools/execution-utilities/elastic-asap-benchmarking/`): they are
tied to ASAPQuery's experiment framework and query engine.
- PilotDB-style sampling baselines: ASAPQuery has no infrastructure for them
to port.
26 changes: 26 additions & 0 deletions eval/baselines/clickhouse/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ClickHouse single server, the system the backend's ClickHouse route
# (`data_plane --clickhouse-url http://localhost:8123`) forwards to and is
# compared with. Ported from ASAPQuery's experiment service template, with the
# image pinned. It listens on localhost only and keeps its data in a named
# volume (`down -v` removes it).
#
# docker compose -f eval/baselines/clickhouse/docker-compose.yml up -d
# curl 'http://localhost:8123/?query=SELECT%20version()'
# docker compose -f eval/baselines/clickhouse/docker-compose.yml down -v
services:
clickhouse:
image: clickhouse/clickhouse-server:25.8.33.6
ports:
- "127.0.0.1:${CLICKHOUSE_HTTP_PORT:-8123}:8123"
volumes:
- clickhouse-data:/var/lib/clickhouse
environment:
# Naive datetime literals in SQL parse the same here as in the backend.
- TZ=UTC
ulimits:
nofile:
soft: 262144
hard: 262144

volumes:
clickhouse-data:
27 changes: 27 additions & 0 deletions eval/baselines/elasticsearch/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Elasticsearch single node, the system the backend's Elasticsearch routes
# (`data_plane --elastic-url http://localhost:9200`) forward to and are
# compared with. Security is off: it listens on localhost for experiments
# only. Data stays in a named volume (`down -v` removes it); ELASTIC_HEAP
# sets the JVM heap (default 1g).
#
# docker compose -f eval/baselines/elasticsearch/docker-compose.yml up -d
# curl http://localhost:9200
# docker compose -f eval/baselines/elasticsearch/docker-compose.yml down -v
services:
elasticsearch:
image: elasticsearch:9.5.3
ports:
- "127.0.0.1:${ELASTIC_HTTP_PORT:-9200}:9200"
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- ES_JAVA_OPTS=-Xms${ELASTIC_HEAP:-1g} -Xmx${ELASTIC_HEAP:-1g}
ulimits:
nofile:
soft: 65536
hard: 65536

volumes:
elasticsearch-data:
4 changes: 2 additions & 2 deletions eval/campaign/demo_job.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ rm -rf "$B"/runs/$tag.*
meta=$B/runs/$tag.meta
{ echo "tag=$tag driver=$(hostname) engine=$ENGINE_SSH ($ENGINE_ADDR) backend_commit=$(cat $BIN_DIR/BACKEND_COMMIT) start=$(date -u +%FT%TZ)"
env | grep -E '^(SERIES|QUERY_[A-Z_]*|QUERIES_FROM_START|ENGINE_LIMITS|ENGINE_ADDR|ARM_CPUS|ARMS|VM_MAX_QUERY_DURATION|PRECOMPUTE_THREADS|FEEDER_[A-Z_]*|ZIPF_[A-Z]*|ANSWER_RESULTS_EVERY|KEEP_VM_DATA|CONCURRENT|MODES|WORKLOADS|DATA_PLANE_EXTRA_ARGS|NET_IFACE|VICTORIAMETRICS_VERSION)=' | sort
echo "harness_sha256_16=$(cd $B && cat harness/*.py run_vm_demo.sh fetch_binaries.sh | sha256sum | cut -c1-16)"
echo "harness_sha256_16=$(cd $B && cat harness/*.py scripts/run_vm_demo.sh scripts/fetch_binaries.sh | sha256sum | cut -c1-16)"
echo "victoria-metrics: $($BIN_DIR/victoria-metrics-$VICTORIAMETRICS_VERSION -version 2>&1 | head -1)"
sha256sum $BIN_DIR/data_plane $BIN_DIR/control_plane $BIN_DIR/victoria-metrics-$VICTORIAMETRICS_VERSION $FEEDER_BIN
echo "engine host: $(ssh $ENGINE_SSH_OPTS $ENGINE_SSH 'hostname; lscpu | grep "Model name"; lsblk -d -o NAME,ROTA,MODEL | tr "\n" " "; df -h / | tail -1')"
} > "$meta"
(cd $B && ./run_vm_demo.sh) > "$B/runs/$tag.campaign.log" 2>&1
(cd $B && ./scripts/run_vm_demo.sh) > "$B/runs/$tag.campaign.log" 2>&1
rc=$?
echo "end=$(date -u +%FT%TZ) rc=$rc" >> "$meta"
grep -q VM_DEMO_DONE "$B/runs/$tag.campaign.log" || exit 1
Expand Down
4 changes: 2 additions & 2 deletions eval/campaign/diag_job.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ rm -rf "$B"/runs/$RUN_TAG.*
meta=$B/runs/$RUN_TAG.meta
{ echo "diag tag=$tag host=$(hostname) backend_commit=$(cat $BIN_DIR/BACKEND_COMMIT) start=$(date -u +%FT%TZ)"
env | grep -E "^(SERIES|MODES|WORKLOADS|ARMS|CONCURRENT|QUERY_DELAY_S|QUERY_USERS|QUERY_PHASE_S|ENGINE_LIMITS|DATA_PLANE_EXTRA_ARGS|PRECOMPUTE_THREADS|FEEDER_VALUES|ZIPF_S|ZIPF_N|FEEDER_BIN|ARM_CORES|KEEP_VM_DATA)=" | sort
echo "harness_sha256_16=$(cd $B && cat harness/*.py run_vm_demo.sh fetch_binaries.sh | sha256sum | cut -c1-16)"
echo "harness_sha256_16=$(cd $B && cat harness/*.py scripts/run_vm_demo.sh scripts/fetch_binaries.sh | sha256sum | cut -c1-16)"
sha256sum $BIN_DIR/data_plane $BIN_DIR/control_plane $FEEDER_BIN; } > "$meta"
(cd $B && ./run_vm_demo.sh) > "$B/runs/$RUN_TAG.campaign.log" 2>&1
(cd $B && ./scripts/run_vm_demo.sh) > "$B/runs/$RUN_TAG.campaign.log" 2>&1
for d in "$B"/runs/$RUN_TAG.*/; do
[ -d "$d" ] || continue
p=$B/prep/$(basename "$d" | sed "s/^$RUN_TAG\.//")
Expand Down
Loading