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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
target/
__pycache__/
.claude/
# Evaluation results are never committed (docs/design/repo-layout.md).
eval/results/
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["control_plane", "data_plane"]
members = ["crates/control-plane", "crates/data-plane"]

[workspace.package]
edition = "2021"
Expand Down Expand Up @@ -29,7 +29,7 @@ clap = { version = "4.0", features = ["derive", "env"] }
tokio = { version = "1.0", features = ["full"] }
axum = "0.7"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
control_plane = { path = "control_plane" }
control_plane = { path = "crates/control-plane" }

# asap_sketchlib#271's head, ahead of the Planner's pin (389530c): DDSketch
# view merges in place, with width-specialized loops (a 1 h quantile over
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ name; the view tier and push precompute add `asap_view_cache_*`,
`asap_view_cold_read_bytes_total`, `asap_view_segments_marked_cold_total`,
`phase="view_decode"`, `asap_precompute_state_bytes`,
`asap_precompute_open_instances`, `asap_window_commit_lag_seconds` and
`asap_samples_total{outcome="late_for_views"}`. `scripts/profile.sh` records a flamegraph of a running data plane;
`asap_samples_total{outcome="late_for_views"}`. `benchmarks/scripts/profile.sh` records a flamegraph of a running data plane;
`cargo run --release -p data_plane --example ingest_bench -- 10000 300`
measures ingest throughput in process.
measures ingest throughput in process (the micro benchmarks are in
`benchmarks/micro/`).

A range query (`/api/v1/query_range`) whose text is one of the plan's
queries is answered with one evaluation per step, at most one step per
Expand Down Expand Up @@ -190,7 +191,7 @@ Not supported yet: views refreshed on first read (so the backend declares
```sh
# Plan the planner-layering Example 1 with this backend's capabilities.
cargo run -p control_plane -- \
--workload examples/planner-layering-example1.json --out plan.json --report report.json
--workload docs/examples/planner-layering-example1.json --out plan.json --report report.json

# Serve Remote Write on /api/v1/write and the query API on /api/v1/query[_range].
cargo run -p data_plane -- --plan plan.json --prometheus-url http://localhost:9090
Expand Down Expand Up @@ -224,6 +225,21 @@ not stored) with a Prometheus `execution` error (422,
`x-asap-execution: refused`) whose `error` is the reason a forwarded query's
`x-asap-forward-reason` would give.

## Repository layout

| Path | Holds |
|---|---|
| `crates/control-plane/` | package `control_plane`: workload → `asap-planner` → plan file |
| `crates/data-plane/` | package `data_plane`: the data plane and its binary |
| `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 |
| `docs/` | design documents and `examples/` workloads |
| `scripts/` | CI and the Planner dependency updater |

The layout, its boundaries and its migration steps are in `docs/design/repo-layout.md`
(#874).

## Development

```sh
Expand Down
26 changes: 0 additions & 26 deletions bench/demo/.gitignore

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Ingest throughput of the data plane, in process: plans a mixed workload
//! (`tests/workloads/random-mixed-seed-862-01.json`) for `SERIES` series of
//! (`crates/data-plane/tests/workloads/random-mixed-seed-862-01.json`) for `SERIES` series of
//! its `data` metric, scraped every second, then sends `SECONDS` seconds of
//! samples by Remote Write (`REQUESTS` requests per scrape, each with a
//! slice of the series; 1 by default) as fast as the data
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//!
//! `offset_bench [SERIES] [RUNS]`

#[path = "../tests/common/mod.rs"]
#[path = "../../crates/data-plane/tests/common/mod.rs"]
#[allow(dead_code)]
mod common;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Range-query cost of a dashboard refresh, in process: plans the demo's
//! dashboard workload (`tests/workloads/dashboard.json`) for `SERIES`
//! dashboard workload (`crates/data-plane/tests/workloads/dashboard.json`) for `SERIES`
//! series of each metric, every query also requested as a range of 1 h at
//! 15 s steps, sends 2 h 5 min of samples (one per series every `SCRAPE`
//! seconds) and closes the windows with an event-time barrier at the last
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Tiered view storage at scale, in process (docs/design/tiered-view-storage.md,
//! B1, B2 and the V15 run): plans the dashboard workload
//! (`tests/workloads/dashboard.json`) without raw samples kept, for
//! (`crates/data-plane/tests/workloads/dashboard.json`) without raw samples kept, for
//! `SERIES` series per metric at 1 sample/s; sends `MINUTES` of samples as
//! fast as they are accepted, with the views persisted in `DIR`; then
//! answers the plan's instant queries at the last window end for `ROUNDS`
Expand All @@ -13,7 +13,7 @@
//! no idle eviction).
//! - `VIEW_READ=pread` reads cold windows with `pread`.
//! - `WORKLOAD=path` plans another workload file (a planning workload,
//! as in `tests/workloads/`) instead, at 1 sample/s.
//! as in `crates/data-plane/tests/workloads/`) instead, at 1 sample/s.
//! - `RESULT_CACHE=0` turns the result cache off, so every round reads
//! its views.
//! - `SCRAPE_MS=n`: one sample per series every `n` ms (default 1,000).
Expand All @@ -24,7 +24,7 @@
//! (`POSIX_FADV_DONTNEED`) before each round (B2).
//!
//! `cargo run --release -p data_plane --example tier_bench -- SERIES MINUTES DIR [ROUNDS]`
//! Under a memory limit: `scripts/tiered_views_cgroup.sh`.
//! Under a memory limit: `benchmarks/scripts/tiered_views_cgroup.sh`.

#[global_allocator]
static ALLOCATOR: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
Expand Down
2 changes: 1 addition & 1 deletion scripts/profile.sh → benchmarks/scripts/profile.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Records a CPU profile of a running data_plane and writes a flamegraph.
#
# scripts/profile.sh [SECONDS] [OUTPUT.svg]
# benchmarks/scripts/profile.sh [SECONDS] [OUTPUT.svg]
#
# Build with symbols first, so frames have names and stacks are whole:
# CARGO_PROFILE_RELEASE_DEBUG=true cargo build --release -p data_plane
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# tiered the default window cache budget (derived from memory.max)
# Expected: the control is OOM-killed (memory.events oom_kill > 0) and the tiered
# run answers every query with oom_kill 0. Needs sudo -n to create the cgroup.
# WORKLOAD, COLD and VIEW_READ are passed to the bench (see examples/tier_bench.rs).
# WORKLOAD, COLD and VIEW_READ are passed to the bench (see benchmarks/micro/tier_bench.rs).
#
# scripts/tiered_views_cgroup.sh [MEMORY_MAX_BYTES] [SERIES] [MINUTES] [WORK_DIR]
# benchmarks/scripts/tiered_views_cgroup.sh [MEMORY_MAX_BYTES] [SERIES] [MINUTES] [WORK_DIR]
set -uo pipefail
MEM=${1:-1610612736}
SERIES=${2:-10000}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
anyhow.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
clap.workspace = true
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use control_plane::{load_plan, plan_workload, save_plan, DeploymentInputs, PlanE

fn example(name: &str) -> PlanningWorkload {
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join(format!("../examples/planner-layering-{name}.json"));
.join(format!("../../docs/examples/planner-layering-{name}.json"));
serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
}

Expand Down
34 changes: 34 additions & 0 deletions data_plane/Cargo.toml → crates/data-plane/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,37 @@ form_urlencoded = "1"
control_plane.workspace = true
tower = { version = "0.5", features = ["util"] }
http-body-util = "0.1"

# The micro benchmarks live in benchmarks/micro/ and build as examples of this
# crate (`cargo run --release -p data_plane --example <name>`).
[[example]]
name = "decode_bench"
path = "../../benchmarks/micro/decode_bench.rs"

[[example]]
name = "ingest_bench"
path = "../../benchmarks/micro/ingest_bench.rs"

[[example]]
name = "matrix_bench"
path = "../../benchmarks/micro/matrix_bench.rs"

[[example]]
name = "offset_bench"
path = "../../benchmarks/micro/offset_bench.rs"

[[example]]
name = "range_bench"
path = "../../benchmarks/micro/range_bench.rs"

[[example]]
name = "rw_corpus_bench"
path = "../../benchmarks/micro/rw_corpus_bench.rs"

[[example]]
name = "tier_bench"
path = "../../benchmarks/micro/tier_bench.rs"

[[example]]
name = "view_read_bench"
path = "../../benchmarks/micro/view_read_bench.rs"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ pub fn inputs_without_levels(raw_data_retained: bool) -> DeploymentInputs {
inputs
}

/// A #509 example workload in `examples/`.
/// A #509 example workload in `docs/examples/`.
#[allow(dead_code)]
pub fn workload(example: &str) -> PlanningWorkload {
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join(format!("../examples/planner-layering-{example}.json"));
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join(format!(
"../../docs/examples/planner-layering-{example}.json"
));
serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap()
}

Expand Down Expand Up @@ -160,12 +161,12 @@ pub fn per_job(body: &Value) -> Vec<(String, f64)> {
rows
}

/// Every workload file in `examples/` and `tests/workloads/` whose name
/// Every workload file in `docs/examples/` and `tests/workloads/` whose name
/// contains `only` (every one for `""`), by name, sorted.
#[allow(dead_code)]
pub fn workloads(only: &str) -> Vec<(String, PlanningWorkload)> {
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
let mut files: Vec<_> = ["../examples", "tests/workloads"]
let mut files: Vec<_> = ["../../docs/examples", "tests/workloads"]
.iter()
.flat_map(|dir| std::fs::read_dir(root.join(dir)).unwrap())
.map(|entry| entry.unwrap().path())
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The data plane answers exactly what the Planner's executor answers for
//! the same installed plan and the same raw samples, on public PromQL
//! workloads: the #509 examples (`examples/`) and ASAPPlanner's mixed and
//! workloads: the #509 examples (`docs/examples/`) and ASAPPlanner's mixed and
//! sketch-plan workloads (`tests/workloads/`, copied unchanged from
//! ASAPPlanner's `tools/dag-viewer/workloads/random-mixed-seed-862/`,
//! `crates/devtools/tests/sketch_plan_snapshots/workloads/` (as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ fn combine_rules_follow_the_table_and_refuse_unknown_breakers() {

let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
let mut seen: Vec<CombineRule> = Vec::new();
for dir in ["../examples", "tests/workloads"] {
for dir in ["../../docs/examples", "tests/workloads"] {
let mut paths: Vec<_> = std::fs::read_dir(root.join(dir))
.unwrap()
.map(|e| e.unwrap().path())
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions deployment/monitoring/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# What the monitoring stack writes (eval/run_vm_demo.sh, eval/demo/run_live_demo.sh).
/textfile/
/grafana/dashboards/
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
# default 13000, dashboard "asap-vs-vm"). Host networking, so every scrape
# target is on the run host's loopback.
#
# ASAPQ_BENCH=$ASAPQ_BENCH sudo -n -E docker compose -f monitoring/docker-compose.yml up -d
# ASAPQ_BENCH is this repository's eval/ directory (see eval/README.md).
# ASAPQ_BENCH=$ASAPQ_BENCH sudo -n -E docker compose -f deployment/monitoring/docker-compose.yml up -d
#
# Without docker: monitoring/run_binaries.sh starts the same stack from the
# Without docker: deployment/monitoring/run_binaries.sh starts the same stack from the
# pinned release binaries in $BIN_DIR.
name: asap-vs-vm-monitoring
services:
Expand All @@ -20,7 +21,7 @@ services:
- --storage.tsdb.retention.time=30d
- --web.listen-address=127.0.0.1:19090
volumes:
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/../deployment/monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- monitoring-prometheus:/prometheus
node-exporter:
image: prom/node-exporter:v1.12.1@sha256:1b4e4438faca4dd7e001dd445d161a4a2091b0fededa84093b3a8dfeae1f1be0
Expand All @@ -33,7 +34,7 @@ services:
- --collector.textfile.directory=/textfile
volumes:
- /:/host:ro,rslave
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/monitoring/textfile:/textfile:ro
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/../deployment/monitoring/textfile:/textfile:ro
process-exporter:
image: ncabatoff/process-exporter:0.8.7@sha256:bc2363ff7e05ada1b2a694f06c43dc824dc26cd6e487b5d36b66b1a40df4e842
network_mode: host
Expand All @@ -47,7 +48,7 @@ services:
- --threads=false
volumes:
- /proc:/host/proc:ro
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/monitoring/process-exporter:/config:ro
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/../deployment/monitoring/process-exporter:/config:ro
grafana:
image: grafana/grafana:12.4.14@sha256:ae509d9ae8c1021ca32ec370a9ca975d40165eda9fccd1e1102d317ff8787cd7
network_mode: host
Expand All @@ -60,8 +61,8 @@ services:
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/asap-vs-vm.json
ASAP_DASHBOARDS_DIR: /var/lib/grafana/dashboards
volumes:
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/../deployment/monitoring/grafana/provisioning:/etc/grafana/provisioning:ro
- ${ASAPQ_BENCH:?set ASAPQ_BENCH}/../deployment/monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro
- monitoring-grafana:/var/lib/grafana
volumes:
monitoring-prometheus:
Expand Down
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). "
"profile/profile_query_phase.sh gives the function-level CPU profile.",
"eval/profile/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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Write dashboards/asap-demo.json, the presentation dashboard: ASAP vs
VictoriaMetrics only (no Prometheus), resource usage only (no prices).

make_demo_dashboard.py --prep live/prep-asap-demo-s10000
make_demo_dashboard.py --prep eval/demo/live/prep-asap-demo-s10000

Layout (docs/design/demo-plan.md sections 8-9 of the backend): the time range starts
at the run's start (--run-start-ms), so every total counts from second 0.
Expand Down Expand Up @@ -89,7 +89,7 @@ def main():
ap.add_argument("--disk-bytes", type=int, help="the size of each engine's own data filesystem")
ap.add_argument("--vm-version", default="v1.156.0")
ap.add_argument("--run-start-ms", type=int, help="the dashboard's time range starts here (cumulative totals)")
ap.add_argument("--planner-dir", type=Path, help="live/planner: report.json, cost_inputs.json, planning.json")
ap.add_argument("--planner-dir", type=Path, help="eval/demo/live/planner: report.json, cost_inputs.json, planning.json")
ap.add_argument("--out", default=str(Path(__file__).parent / "dashboards" / "asap-demo.json"))
args = ap.parse_args()
queries = json.loads((args.prep / "queries.json").read_text())["queries"]
Expand Down Expand Up @@ -280,7 +280,7 @@ def cell(promql, limit=110): # long matchers (e.g. host lists) cut, so the tabl
# ---- 2 Per query
row("2 · Per query: latency (p50, p99) and error")
for q in queries:
sel = f'query="{q["id"]}"' # live/query_load.py labels by query id
sel = f'query="{q["id"]}"' # eval/demo/live/query_load.py labels by query id
hq = lambda phi, eng: (f'histogram_quantile({phi}, sum by (le) (rate(live_load_latency_seconds_bucket'
f'{{engine="{eng}", {sel}}}[5m])))')
name = short(q)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/api/v1/query_range; then request latency per data source over time, and
CPU/RSS of the engines as bars.

make_live_dashboard.py --queries live/prep-.../queries.json
make_live_dashboard.py --queries eval/demo/live/prep-.../queries.json

Every query panel requests the plan's grid: the time range is the plan's
span (relative time), the step is the plan's step (the query's min interval;
Expand Down Expand Up @@ -82,7 +82,7 @@ def row(title):
width = 24 // len(arms)
if not q.get("range"):
# ASAP answers an instant query only at a time on the query's evaluation grid, and Grafana's
# instant time is not aligned: show the answers the accuracy check (live/accuracy.py) records
# instant time is not aligned: show the answers the accuracy check (eval/demo/live/accuracy.py) records
# at each grid time instead (asap_demo_answer; the reference's largest series past 20 outputs).
mon_ds = DS["mon"]
for i, arm in enumerate(a for a in arms if a != "exact"):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Live demo data sources (run_live_demo.sh). Each goes through the logging
# proxy (live/proxy.py) in front of its engine. timeInterval is the panels'
# proxy (eval/demo/live/proxy.py) in front of its engine. timeInterval is the panels'
# minimum step: the plan's 15 s grid. timeout 120 s (Grafana's default is 30 s) so a slow
# answer is measured rather than cut off.
apiVersion: 1
Expand Down
Loading