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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ VERIFIER_JWKS_PUBKEY_SHA256=
CLOUDFLARE_ZONE=secure-rads.org
CLOUDFLARE_EMAIL=REPLACE_WITH_CLOUDFLARE_ACCOUNT_EMAIL
CLOUDFLARE_API_TOKEN=REPLACE_WITH_CLOUDFLARE_GLOBAL_API_KEY
CLOUDFLARE_ACCOUNT_ID=REPLACE_WITH_CLOUDFLARE_ACCOUNT_ID
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include mk/env.mk

.PHONY: env up down status secure-rads rads logs csav-key csav-deploy csav-destroy csav-status csav-up csav-down csav-ssh \
benchmark benchmark-report benchmark-seed benchmark-run
benchmark benchmark-report benchmark-seed benchmark-run benchmark-dashboard benchmark-dashboard-down benchmark-site benchmark-site-deploy

env:
scripts/derive-env.sh
Expand Down Expand Up @@ -35,6 +35,18 @@ benchmark-seed:
benchmark-run:
$(MAKE) -C benchmark run

benchmark-dashboard:
$(MAKE) -C benchmark dashboard-up

benchmark-dashboard-down:
$(MAKE) -C benchmark dashboard-down

benchmark-site:
$(MAKE) -C benchmark site

benchmark-site-deploy:
$(MAKE) -C benchmark site-deploy

logs:
@set -u; \
pids=""; \
Expand Down
1 change: 1 addition & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build/
*.egg-info/
dist/
node_modules/
results/site/
45 changes: 36 additions & 9 deletions benchmark/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,30 @@ TREE_FLAGS := --trees $(TREES)
RUN_FLAGS := --reps $(REPS) $(TREE_FLAGS) --skip-generate --skip-seed
SEED_FLAGS := $(TREE_FLAGS) --setup-only

.PHONY: help seed run export plot graph report all
GRAFANA_COMPOSE := grafana/docker-compose.yml

WRANGLER ?= npx --yes wrangler@4

.PHONY: help seed run export report site site-deploy dashboard-up dashboard-load dashboard-down all

help:
@echo "benchmark targets:"
@echo " make seed # generate dataset, upload algorithms, BatchWrite PDM"
@echo " make run # size sweep only (override REPS= TREES=)"
@echo " make export # results/raw/ -> phase-timings.csv"
@echo " make plot # phase-timings.csv -> figures/ (alias: graph)"
@echo " make report # export + plot"
@echo " make report # export + render + deploy the dashboard site"
@echo " make site # render the Grafana dashboard -> results/site/index.html"
@echo " make site-deploy # publish results/site to Cloudflare Workers"
@echo " make dashboard-up # start Grafana + Postgres and load phase-timings.csv"
@echo " make dashboard-load # reload phase-timings.csv into the running stack"
@echo " make dashboard-down # stop and remove the dashboard containers"
@echo " make all # seed + run + report"
@echo ""
@echo "examples:"
@echo " make seed"
@echo " make run REPS=1"
@echo " make run TREES=rads REPS=2"
@echo " make export && make plot"
@echo " make export && make site"
@echo " make all REPS=3"

seed:
Expand All @@ -39,12 +47,31 @@ run:
export:
uv run python -m export

plot:
uv run python -m plot
report: export site-deploy

site: dashboard-up
uv run python -m grafana_site
@echo "site: results/site/index.html"

site-deploy: site
$(call env_require,CLOUDFLARE_ACCOUNT_ID)
@if [ -n "$(CLOUDFLARE_API_KEY)" ]; then \
env -u CLOUDFLARE_API_TOKEN CLOUDFLARE_EMAIL="$(CLOUDFLARE_EMAIL)" CLOUDFLARE_API_KEY="$(CLOUDFLARE_API_KEY)" \
CLOUDFLARE_ACCOUNT_ID="$(CLOUDFLARE_ACCOUNT_ID)" $(WRANGLER) deploy --config wrangler.jsonc; \
else \
env -u CLOUDFLARE_API_TOKEN CLOUDFLARE_EMAIL="$(CLOUDFLARE_EMAIL)" CLOUDFLARE_API_KEY="$(CLOUDFLARE_API_TOKEN)" \
CLOUDFLARE_ACCOUNT_ID="$(CLOUDFLARE_ACCOUNT_ID)" $(WRANGLER) deploy --config wrangler.jsonc; \
fi

dashboard-up:
docker compose -f $(GRAFANA_COMPOSE) up -d --wait
$(MAKE) dashboard-load

graph: plot
dashboard-load:
uv run python -m grafana_load
@echo "Grafana: http://127.0.0.1:3001/d/bench/sce-benchmark"

report: export plot
@echo "wrote results/phase-timings.csv and results/figures/"
dashboard-down:
docker compose -f $(GRAFANA_COMPOSE) down

all: seed run report
44 changes: 34 additions & 10 deletions benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ From `benchmark/`:
make seed # generate + upload + BatchWrite PDM
make run # size sweep only (needs a prior seed, or existing PDM rows)
make export # results/raw/ -> phase-timings.csv
make plot # phase-timings.csv -> figures/ (alias: make graph)
make report # export + plot
make report # export + render + deploy the dashboard site
make all # seed + run + report
```

Expand Down Expand Up @@ -83,7 +82,7 @@ export PYTHONPATH=src
uv run python -m execute --setup-only
uv run python -m execute --skip-generate --skip-seed --reps 1
uv run python -m export
uv run python -m plot
uv run python -m grafana_site
```

| Flag | Meaning |
Expand All @@ -98,18 +97,44 @@ Setup resolves the service catalog once (API Gateway URLs; CSAV registry via liv

Each sweep writes `results/raw/sweep-<unix>.json`. Stop with Ctrl-C and terminate leftover `*-execution-service-run` EC2 instances if needed.

## Export and figures
## Export and report

```sh
make export # every results/raw/sweep-*.json + telemetry-service + cost-service -> phase-timings.csv
make plot # -> results/figures/sweep-phases.png, sweep-scaling.png, sweep-cost.png, sweep-cost-services.png
make report # both
make report # export, then render and deploy the static dashboard site
```

`export` also reads `GET /cost/{algorithmId}?runId=` and adds per-service (`ec2_cost_usd`, `dynamodb_cost_usd`, `s3_cost_usd`, `sqs_cost_usd`, `lambda_cost_usd`, `apigateway_cost_usd`) and `total_cost_usd` columns. `plot` writes `sweep-cost.png` (total cost vs size) and `sweep-cost-services.png` (cost by AWS service). These are list-price estimates, not the bill - see [`../docs/cost-service.md`](../docs/cost-service.md). Cost rows land asynchronously via SQS, so run `export` after the sweep has settled.
`export` also reads `GET /cost/{algorithmId}?runId=` and adds per-service (`ec2_cost_usd`, `dynamodb_cost_usd`, `s3_cost_usd`, `sqs_cost_usd`, `lambda_cost_usd`, `apigateway_cost_usd`) and `total_cost_usd` columns. These are list-price estimates, not the bill - see [`../docs/cost-service.md`](../docs/cost-service.md). Cost rows land asynchronously via SQS, so run `export` after the sweep has settled.

To export one sweep only, move other `results/raw/sweep-*.json` files aside first. Drop or re-run failed reps (`error` in raw JSON, or PDM 500s) before treating the CSV as final.

### Dashboard (Grafana)

`make dashboard-up` starts a local Grafana + Postgres stack with Docker Compose, loads `results/phase-timings.csv`, and provisions the "SCE Benchmark" dashboard at <http://127.0.0.1:3001/d/bench/sce-benchmark>. The panels cover scaling (total time vs size), total cost vs size, the per-tree phase breakdown, the selected-size (10K/80K/150K) phase breakdown, cost by AWS service, and a runs table.

```sh
make report # refresh phase-timings.csv first
make dashboard-up
make dashboard-load # after another sweep, reload the rows
make dashboard-down # stop and remove the containers
```

The stack binds Grafana to loopback and uses anonymous-admin for local use; do not expose it publicly without authentication in front. It reads only timings and list-price cost estimates, not records or PII. To deploy it, point Grafana at a Postgres populated by `src/grafana_load.py` (or a CloudWatch datasource) and put it behind the usual ALB/CloudFront.

![SCE benchmark dashboard](../docs/images/benchmark-grafana.png)

### Static site (Cloudflare Workers)

`make site` starts the local Grafana stack, renders the whole dashboard to one PNG through the bundled `grafana-image-renderer` (pinned to 3.12.9; v4/v5 crash on this setup), and writes a single self-contained `results/site/index.html` with no server or external assets. `make site-deploy` publishes that directory as a Cloudflare Worker with static assets.

```sh
make report
make site # render the Grafana dashboard -> results/site/index.html
make site-deploy # npx wrangler deploy
```

`make report` (and so `make all`) runs `site-deploy` after `export`, so every benchmark run republishes the page. Deploy requires `CLOUDFLARE_ACCOUNT_ID` in the root `.env`; the existing `CLOUDFLARE_API_TOKEN` (global key) is used for auth, or set `CLOUDFLARE_API_KEY`. The Worker name and asset directory live in `wrangler.jsonc`. It is published at <https://benchmark.secure-rads.org> (Worker custom domain, set in `wrangler.jsonc`). Grafana stays local; the static page is the deployed artifact.

### Event boundaries

The event contract follows [RADS](../docs/e2e-rads.txt) and [Secure-RADS](../docs/e2e-secure-rads.txt).
Expand All @@ -136,16 +161,15 @@ Existing committed results use the earlier event contract (`data-decrypted` afte

| Path | Role |
| --- | --- |
| `Makefile` | `seed` / `run` / `export` / `plot` / `report` / `all` |
| `Makefile` | `seed` / `run` / `export` / `report` / `site` / `site-deploy` / `all` |
| `src/execute.py` | Setup and size sweep (`--setup-only`, `--skip-*`) |
| `src/export.py` | Raw JSON + telemetry-service → `phase-timings.csv` |
| `src/plot.py` | CSV → phase / scaling figures |
| `src/lib/catalog.py` | `ApiGatewayService` / `Ec2HttpService` catalog |
| `src/lib/config.py` | Trial constants + `resolve()` |
| `src/lib/tree.py` | `Tree` StrEnum |
| `src/lib/trees/` | `TreeHarness` ABC + rads / secure-rads |
| `src/lib/http.py` | httpx helpers (sync + async) |
| `src/lib/log.py` | loguru + richuru |
| `src/paths.py` | Package / results / repo roots |
| `results/` | Raw JSON, `phase-timings.csv`, figures (tracked) |
| `results/` | Raw JSON, `phase-timings.csv` (tracked) |
| `../seeding/` | Shared generate + BatchWrite seeders |
197 changes: 197 additions & 0 deletions benchmark/grafana/dashboards/bench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
{
"uid": "bench",
"title": "SCE Benchmark",
"tags": ["benchmark", "sce"],
"timezone": "browser",
"schemaVersion": 39,
"version": 1,
"refresh": "",
"time": { "from": "now-24h", "to": "now" },
"panels": [
{
"id": 1,
"type": "barchart",
"title": "Scaling: avg total time by size (s)",
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 0 },
"datasource": { "type": "postgres", "uid": "bench-pg" },
"targets": [
{
"refId": "A",
"datasource": { "type": "postgres", "uid": "bench-pg" },
"format": "table",
"rawQuery": true,
"rawSql": "SELECT 'size ' || dataset_size::text AS \"Size\", round(avg(total_s) FILTER (WHERE tree='rads')::numeric, 1) AS \"CE (baseline)\", round(avg(total_s) FILTER (WHERE tree='secure-rads')::numeric, 1) AS \"SCE (enclave)\" FROM runs GROUP BY dataset_size ORDER BY dataset_size"
}
],
"options": {
"orientation": "vertical",
"xField": "Size",
"stacking": "none",
"legend": { "showLegend": true, "placement": "bottom" },
"tooltip": { "mode": "multi" },
"xTickLabelRotation": -45
},
"fieldConfig": {
"defaults": { "unit": "s", "custom": { "fillOpacity": 85, "lineWidth": 1 } },
"overrides": []
}
},
{
"id": 2,
"type": "barchart",
"title": "Cost: avg total cost by size (USD)",
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 0 },
"datasource": { "type": "postgres", "uid": "bench-pg" },
"targets": [
{
"refId": "A",
"datasource": { "type": "postgres", "uid": "bench-pg" },
"format": "table",
"rawQuery": true,
"rawSql": "SELECT 'size ' || dataset_size::text AS \"Size\", avg(total_cost_usd) FILTER (WHERE tree='rads') AS \"CE (baseline)\", avg(total_cost_usd) FILTER (WHERE tree='secure-rads') AS \"SCE (enclave)\" FROM runs GROUP BY dataset_size ORDER BY dataset_size"
}
],
"options": {
"orientation": "vertical",
"xField": "Size",
"stacking": "none",
"legend": { "showLegend": true, "placement": "bottom" },
"tooltip": { "mode": "multi" },
"xTickLabelRotation": -45
},
"fieldConfig": {
"defaults": { "unit": "currencyUSD", "decimals": 5, "custom": { "fillOpacity": 85, "lineWidth": 1 } },
"overrides": []
}
},
{
"id": 3,
"type": "barchart",
"title": "CE (baseline) phase breakdown (avg s)",
"gridPos": { "h": 9, "w": 12, "x": 0, "y": 8 },
"datasource": { "type": "postgres", "uid": "bench-pg" },
"targets": [
{
"refId": "A",
"datasource": { "type": "postgres", "uid": "bench-pg" },
"format": "table",
"rawQuery": true,
"rawSql": "SELECT 'size ' || dataset_size::text AS \"Size\", round(avg(host_provisioning_s)::numeric, 1) AS \"host provisioning\", round(avg(algorithm_retrieval_s)::numeric, 1) AS \"algorithm retrieval\", round(avg(data_retrieval_s)::numeric, 1) AS \"data retrieval\", round(avg(algorithm_processing_s)::numeric, 1) AS \"algorithm processing\", round(avg(result_delivery_s)::numeric, 1) AS \"result delivery\" FROM runs WHERE tree='rads' GROUP BY dataset_size ORDER BY dataset_size"
}
],
"options": {
"orientation": "vertical",
"xField": "Size",
"stacking": "normal",
"legend": { "showLegend": true, "placement": "bottom" },
"tooltip": { "mode": "multi" },
"xTickLabelRotation": -45
},
"fieldConfig": {
"defaults": { "unit": "s", "custom": { "fillOpacity": 85, "lineWidth": 1 } },
"overrides": []
}
},
{
"id": 4,
"type": "barchart",
"title": "SCE (enclave) phase breakdown (avg s)",
"gridPos": { "h": 9, "w": 12, "x": 12, "y": 8 },
"datasource": { "type": "postgres", "uid": "bench-pg" },
"targets": [
{
"refId": "A",
"datasource": { "type": "postgres", "uid": "bench-pg" },
"format": "table",
"rawQuery": true,
"rawSql": "SELECT 'size ' || dataset_size::text AS \"Size\", round(avg(host_provisioning_s)::numeric, 1) AS \"host provisioning\", round(avg(algorithm_retrieval_s)::numeric, 1) AS \"algorithm retrieval\", round(avg(enclave_boot_s)::numeric, 1) AS \"enclave boot\", round(avg(sce_unit_s)::numeric, 1) AS \"sce unit\", round(avg(attestation_s)::numeric, 1) AS \"attestation\", round(avg(data_retrieval_s)::numeric, 1) AS \"data retrieval\", round(avg(algorithm_processing_s)::numeric, 1) AS \"algorithm processing\", round(avg(result_delivery_s)::numeric, 1) AS \"result delivery\" FROM runs WHERE tree='secure-rads' GROUP BY dataset_size ORDER BY dataset_size"
}
],
"options": {
"orientation": "vertical",
"xField": "Size",
"stacking": "normal",
"legend": { "showLegend": true, "placement": "bottom" },
"tooltip": { "mode": "multi" },
"xTickLabelRotation": -45
},
"fieldConfig": {
"defaults": { "unit": "s", "custom": { "fillOpacity": 85, "lineWidth": 1 } },
"overrides": []
}
},
{
"id": 5,
"type": "barchart",
"title": "Selected sizes phase breakdown (10K/80K/150K, avg s)",
"gridPos": { "h": 9, "w": 12, "x": 0, "y": 17 },
"datasource": { "type": "postgres", "uid": "bench-pg" },
"targets": [
{
"refId": "A",
"datasource": { "type": "postgres", "uid": "bench-pg" },
"format": "table",
"rawQuery": true,
"rawSql": "SELECT (CASE WHEN tree='rads' THEN 'CE' ELSE 'SCE' END) || ' ' || dataset_size::text AS \"Run\", round(avg(host_provisioning_s)::numeric, 1) AS \"host provisioning\", round(avg(algorithm_retrieval_s)::numeric, 1) AS \"algorithm retrieval\", round(avg(COALESCE(enclave_boot_s,0))::numeric, 1) AS \"enclave boot\", round(avg(COALESCE(sce_unit_s,0))::numeric, 1) AS \"sce unit\", round(avg(COALESCE(attestation_s,0))::numeric, 1) AS \"attestation\", round(avg(data_retrieval_s)::numeric, 1) AS \"data retrieval\", round(avg(algorithm_processing_s)::numeric, 1) AS \"algorithm processing\", round(avg(result_delivery_s)::numeric, 1) AS \"result delivery\" FROM runs WHERE dataset_size IN (10000, 80000, 150000) GROUP BY tree, dataset_size ORDER BY dataset_size, tree"
}
],
"options": {
"orientation": "vertical",
"xField": "Run",
"stacking": "normal",
"legend": { "showLegend": true, "placement": "bottom" },
"tooltip": { "mode": "multi" },
"xTickLabelRotation": -45
},
"fieldConfig": {
"defaults": { "unit": "s", "custom": { "fillOpacity": 85, "lineWidth": 1 } },
"overrides": []
}
},
{
"id": 6,
"type": "barchart",
"title": "Cost by AWS service (mean USD)",
"gridPos": { "h": 9, "w": 12, "x": 12, "y": 17 },
"datasource": { "type": "postgres", "uid": "bench-pg" },
"targets": [
{
"refId": "A",
"datasource": { "type": "postgres", "uid": "bench-pg" },
"format": "table",
"rawQuery": true,
"rawSql": "SELECT CASE WHEN tree='rads' THEN 'CE (baseline)' ELSE 'SCE (enclave)' END AS \"Tree\", avg(ec2_cost_usd) AS \"ec2\", avg(dynamodb_cost_usd) AS \"dynamodb\", avg(s3_cost_usd) AS \"s3\", avg(sqs_cost_usd) AS \"sqs\", avg(lambda_cost_usd) AS \"lambda\", avg(apigateway_cost_usd) AS \"apigateway\" FROM runs GROUP BY tree ORDER BY tree"
}
],
"options": {
"orientation": "horizontal",
"xField": "Tree",
"stacking": "normal",
"legend": { "showLegend": true, "placement": "bottom" },
"tooltip": { "mode": "multi" }
},
"fieldConfig": {
"defaults": { "unit": "currencyUSD", "decimals": 8, "custom": { "fillOpacity": 85, "lineWidth": 1 } },
"overrides": []
}
},
{
"id": 7,
"type": "table",
"title": "Runs",
"gridPos": { "h": 10, "w": 24, "x": 0, "y": 26 },
"datasource": { "type": "postgres", "uid": "bench-pg" },
"targets": [
{
"refId": "A",
"datasource": { "type": "postgres", "uid": "bench-pg" },
"format": "table",
"rawQuery": true,
"rawSql": "SELECT dataset_size AS \"size\", tree, run, round(total_s::numeric, 2) AS \"total_s\", round(host_provisioning_s::numeric, 2) AS \"host_s\", round(data_retrieval_s::numeric, 2) AS \"data_s\", round(algorithm_processing_s::numeric, 2) AS \"compute_s\", round(total_cost_usd::numeric, 6) AS \"cost_usd\", status FROM runs ORDER BY dataset_size, tree, run"
}
],
"options": { "showHeader": true, "cellHeight": "sm" },
"fieldConfig": { "defaults": {}, "overrides": [] }
}
]
}
Loading
Loading