Skip to content

Latest commit

 

History

History
163 lines (113 loc) · 9.69 KB

README.md

File metadata and controls

163 lines (113 loc) · 9.69 KB

ASAPBench

A benchmark to tell how approximation is helping. Current status: a benchmark over sketch instance and over (selected) data processing system.

Quickstart

The benchmark has two levels:

  • Sketch benchmark: one sketch instance on data the benchmark generates. It compares sketches, libraries and configurations on throughput, latency, memory and accuracy.
  • System benchmark: the same queries on real data processing systems, exact and approximate. It compares answers, time, CPU and memory.

Compile

cargo build --release

The binary is target/release/approxbench.

Sketch benchmark: HyperLogLog

Compares: how fast a HyperLogLog from asap_sketchlib takes 1M Zipf keys, and how far its distinct count is from the exact count.

./target/release/approxbench sketchbench \
    --variant hyperloglog --library asap_sketchlib --config 'lg_k=14' \
    --dataset zipf --size 1000000 --zipf-s 1.1 --cardinality 100000 --dtype i64 \
    --runs 10 --warmup-runs 3 \
    --operations insert --metrics throughput,memory --flat --pretty-print

./target/release/approxbench sketchbench \
    --variant hyperloglog --library asap_sketchlib --config 'lg_k=14' \
    --dataset zipf --size 1000000 --zipf-s 1.1 --cardinality 100000 --dtype i64 \
    --operations query --metrics accuracy --flat --pretty-print

What to expect: one JSON record per command. The first has insert_throughput_items_per_sec (about 3×10^8 items/s on our machine) and memory_bytes (16400). The second has query_accuracy with estimate, truth and relative_error (about 0.006).

Flag Meaning
--variant, --library which sketch, from which library; --list-impls lists every pair
--config the sketch's parameters; hyperloglog takes lg_k, log2 of the register count
--dataset, --size, --zipf-s, --cardinality the generated data: distribution, row count, skew, key space
--dtype item type: i64, u64, f64 or string
--runs, --warmup-runs measured runs, and runs discarded before them
--operations × --metrics crossed: every operation is measured on every metric; a pair that means nothing (accuracy of insert) is refused
--flat, --pretty-print one flat JSON record, printed on several lines

Sketch benchmark: Hydra over UnivMon

Compares: the cost of Hydra with UnivMon cells, which keeps one UnivMon for every subset of a record's labels, on insert and on merging 8 shards.

./target/release/approxbench sketchbench \
    --variant hydra-univmon-cardinality --library asap_sketchlib \
    --spec configs/datagen/hydra_univmon_columns.yaml --dtype i64 \
    --config "rows=2 cols=8 cell_heap_size=1000 cell_sketch_row=5 cell_sketch_col=2048 cell_layer_size=8" \
    --operations insert,merge --metrics throughput \
    --merge-shards 8 --runs 5 --warmup-runs 2 --flat --pretty-print

What to expect: insert_throughput_items_per_sec (about 2.3×10^5 records/s), merge_wall_time_ms and merge_folds_per_sec for folding 8 shards into one. Use --operations query --metrics accuracy for the per-group error, and --library polars for the exact answer to the same question.

Flag Meaning
--spec a YAML table description instead of --dataset: label columns, then the value column
--config rows, cols: the Hydra grid; cell_*: each UnivMon cell
--merge-shards, --merge-split how many shards merge folds, and how the stream is cut (contiguous or interleaved)
--group-columns which label columns a group is taken over; default 0

System benchmark: ClickBench on DuckDB, ClickHouse, TimescaleDB, Druid and PilotDB

Compares: the 43 queries of ClickBench (each engine's queries.sql, one query per line), exact on DuckDB and ClickHouse, and 7 of them approximate through PilotDB's sampling over DuckDB, against DuckDB's exact answers. With POSTGRESQL_CONNECTION and DRUID_URL set, the same run adds TimescaleDB (exact, and its COUNT(DISTINCT) variant) and Druid (exact, and its approximate defaults).

APPROXBENCH=$PWD/target/release/approxbench \
ENGINE_CPUS=0-15 THREADS=16 PILOTDB_PYTHON=~/pilotdb/venv/bin/python \
    scripts/one-shot-clickbench.sh ~/ClickBench /data/clickbench runs/clickbench

What to expect: runs/clickbench/one-shot-summary.md (and .csv), one row per configuration and query, with its accuracy against duckdb/exact and its speedup over each exact run. On a 64-core machine with the data in memory, this takes about 15 minutes.

Before the run:

  • Get the data: clone ClickBench, and download hits.parquet (about 14 GB) into the data directory.
  • Install DuckDB and PilotDB: scripts/install-duckdb.sh <dir> puts duckdb in <dir>; put it on PATH or set DUCKDB to it. scripts/install-pilotdb.sh <dir> prints the PILOTDB_PYTHON to use. PilotDB also needs libodbc.so.2 (Ubuntu: apt install libodbc2).
  • Start ClickHouse: a ClickHouse server whose user_files_path contains the data directory, since it loads hits.parquet with file(). Set CLICKHOUSE_URL if it does not listen on http://127.0.0.1:8123. (scripts/extbench-up.sh clickhouse up starts one in Docker, but does not mount the data directory, so it cannot read hits.parquet.)
  • Druid and TimescaleDB, if measured: scripts/extbench-up-druid.sh up ... or scripts/extbench-up-timescaledb.sh up ..., with DATA_DIRECTORY set to the data directory so the server can read hits.parquet.
  • Point to approxbench: put it on PATH, or set APPROXBENCH to it, as the command above does.
  • Skip an engine: set its variable empty, such as CLICKHOUSE_URL= or PILOTDB_PYTHON=. Druid and TimescaleDB run only when DRUID_URL or POSTGRESQL_CONNECTION is set.
  • All options: scripts/one-shot-workload.sh --help. That script also runs any other workload file the same way.

System benchmark: a use case on VictoriaMetrics and ASAPQuery-backend

The use-case study has five use cases. In each one, an application makes decisions from query answers. The five are: 1 DDoS detection, 2 resource scaling, 3 video experience, 4 canary release, 5 rate limiting (pages). This example runs use case 5, rate limiting, on VictoriaMetrics and ASAPQuery-backend, and compares their answers and the decisions taken from them. To run another use case, change 5 to its number.

python3 scripts/use_cases/run_use_case_on_systems.py 5 \
    --victoriametrics ~/victoriametrics/victoria-metrics-prod \
    --backend-dir ~/asapquery-backend/target/release

What to expect: one directory per arm under target/grafana-data/phase3/runs/ (use case 5 has 4 arms, one per error target), which the phase 3 Grafana dashboards read (tools/grafana/run.sh --phase 3). It also prints, per arm, how many queries the backend supports and how many failed. Use case 5 takes about 10 minutes.

Before the run:

  • Build planeval: the script uses planeval to compute the exact answers and score both systems. cargo build --release -p system-bench --features planeval.
  • Download VictoriaMetrics v1.154.1: mkdir -p ~/victoriametrics && curl -L https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.154.1/victoria-metrics-linux-amd64-v1.154.1.tar.gz | tar xz -C ~/victoriametrics
  • Build ASAPQuery-backend: scripts/extbench-up-asapquery-backend.sh build ~/asapquery-backend clones it at the pinned commit and builds it.
  • No servers to start: the script starts and stops both systems itself.
  • All options: python3 scripts/use_cases/run_use_case_on_systems.py --help.

How to use

The Quickstart above runs one example of each level. For more:

Want to add more?

Check this developer_guide about how to add a sketch instance, ground truth, data generation, a system or a use case. Terms used across the repository are in terminology.

Reference

Some crate-oriented design thought is as followed, if anyone is interested:

Shared by both levels:

Operator level:

System level:

  • system-bench: adapters for external systems and the registry of systems.
  • planeval: part of system-bench; runs ASAPPlanner's plans in process.
  • Capability files: part of system-bench; what ClickHouse and VictoriaMetrics can run.
  • Harness: part of aqpbm-core; how every system-level measurement is taken.

Use-case study: