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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Compares: how fast a HyperLogLog from `asap_sketchlib` takes 1M Zipf keys, and h

```sh
./target/release/approxbench sketchbench \
--variant hll --library lib --config 'lg_k=14' \
--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 hll --library lib --config 'lg_k=14' \
--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
```
Expand All @@ -39,8 +39,8 @@ What to expect: one JSON record per command. The first has `insert_throughput_it

| Flag | Meaning |
|---|---|
| `--variant`, `--library` | which sketch, from which library (`lib` = `asap_sketchlib`); `--list-impls` lists every pair |
| `--config` | the sketch's parameters; `hll` takes `lg_k`, log2 of the register count |
| `--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 |
Expand All @@ -53,7 +53,7 @@ Compares: the cost of Hydra with UnivMon cells, which keeps one UnivMon for ever

```sh
./target/release/approxbench sketchbench \
--variant hydra-univmon-cardinality --library lib \
--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 \
Expand Down
26 changes: 13 additions & 13 deletions aqpbm-cli/src/atomic_costs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,14 @@ mod tests {
fn full_record() -> MergedRecord {
MergedRecord {
schema_version: SCHEMA_VERSION,
sketch: "cms".into(),
library: "lib".into(),
sketch: "count-min-sketch".into(),
library: "asap_sketchlib".into(),
language: Language::Rust,
mode: Mode::Bench,
runs: 5,
source: Source::Cli,
sketch_config: Some(
serde_json::json!({"algorithm": "cms", "params": {"rows": 3, "cols": 1024}}),
serde_json::json!({"algorithm": "count-min-sketch", "params": {"rows": 3, "cols": 1024}}),
),
input_dataset: dataset().into(),
trial: None,
Expand Down Expand Up @@ -575,7 +575,7 @@ mod tests {
/// migrated.
#[test]
fn a_row_without_accuracy_metric_is_rejected() {
let json = r#"{"sketch":"cms","sketch_config":null,"mem_bytes_per_instance":1.0,"insert_cpu_secs":1.0,"merge_cpu_secs":1.0,"query_cpu_secs":1.0,"query_accuracy":{}}"#;
let json = r#"{"sketch":"count-min-sketch","sketch_config":null,"mem_bytes_per_instance":1.0,"insert_cpu_secs":1.0,"merge_cpu_secs":1.0,"query_cpu_secs":1.0,"query_accuracy":{}}"#;
let err = serde_json::from_str::<AtomicCostEntry>(json).unwrap_err();
assert!(err.to_string().contains("accuracy_metric"), "{err}");
}
Expand All @@ -591,29 +591,29 @@ mod tests {
/// A misspelled or newer field is an error, not silently dropped data.
#[test]
fn a_row_with_an_unknown_field_is_rejected() {
let json = r#"{"sketch":"cms","sketch_config":null,"mem_bytes_per_instance":1.0,"insert_cpu_secs":1.0,"merge_cpu_secs":1.0,"query_cpu_secs":1.0,"query_accuracy":{},"accuracy_metric":"x","merge_acuracy":{}}"#;
let json = r#"{"sketch":"count-min-sketch","sketch_config":null,"mem_bytes_per_instance":1.0,"insert_cpu_secs":1.0,"merge_cpu_secs":1.0,"query_cpu_secs":1.0,"query_accuracy":{},"accuracy_metric":"x","merge_acuracy":{}}"#;
let err = serde_json::from_str::<AtomicCostEntry>(json).unwrap_err();
assert!(err.to_string().contains("merge_acuracy"), "{err}");
}

#[test]
fn measured_at_with_an_unknown_field_is_rejected() {
let json = r#"{"sketch":"cms","sketch_config":null,"mem_bytes_per_instance":1.0,"insert_cpu_secs":1.0,"merge_cpu_secs":1.0,"query_cpu_secs":1.0,"query_accuracy":{},"accuracy_metric":"x","measured_at":{"items_per_instance":1,"keys_per_instance":null,"value_rnage":null,"merge_operand_items":null,"distribution":null}}"#;
let json = r#"{"sketch":"count-min-sketch","sketch_config":null,"mem_bytes_per_instance":1.0,"insert_cpu_secs":1.0,"merge_cpu_secs":1.0,"query_cpu_secs":1.0,"query_accuracy":{},"accuracy_metric":"x","measured_at":{"items_per_instance":1,"keys_per_instance":null,"value_rnage":null,"merge_operand_items":null,"distribution":null}}"#;
let err = serde_json::from_str::<AtomicCostEntry>(json).unwrap_err();
assert!(err.to_string().contains("value_rnage"), "{err}");
}

#[test]
fn a_distribution_with_an_unknown_field_is_rejected() {
let json = r#"{"sketch":"cms","sketch_config":null,"mem_bytes_per_instance":1.0,"insert_cpu_secs":1.0,"merge_cpu_secs":1.0,"query_cpu_secs":1.0,"query_accuracy":{},"accuracy_metric":"x","measured_at":{"items_per_instance":1,"keys_per_instance":null,"value_range":null,"merge_operand_items":null,"distribution":{"kind":"zipf","skewnes":1.1,"skewness":1.1,"population_size":10,"seed":1}}}"#;
let json = r#"{"sketch":"count-min-sketch","sketch_config":null,"mem_bytes_per_instance":1.0,"insert_cpu_secs":1.0,"merge_cpu_secs":1.0,"query_cpu_secs":1.0,"query_accuracy":{},"accuracy_metric":"x","measured_at":{"items_per_instance":1,"keys_per_instance":null,"value_range":null,"merge_operand_items":null,"distribution":{"kind":"zipf","skewnes":1.1,"skewness":1.1,"population_size":10,"seed":1}}}"#;
let err = serde_json::from_str::<AtomicCostEntry>(json).unwrap_err();
assert!(err.to_string().contains("skewnes"), "{err}");
}

#[test]
fn reduces_a_full_record_to_per_op_seconds() {
let entry = reduce_one(&full_record(), METRIC).expect("fully populated record");
assert_eq!(entry.sketch, "cms");
assert_eq!(entry.sketch, "count-min-sketch");
assert_eq!(entry.mem_bytes_per_instance, 12_288.0);

// insert: work = 1_000_000/sec * 1.0s = 1_000_000 items;
Expand Down Expand Up @@ -715,9 +715,9 @@ mod tests {
bad.memory_bytes = None;

let mut unnamed = full_record();
unnamed.sketch = "hll".into();
unnamed.sketch = "hyperloglog".into();

let metrics = BTreeMap::from([("cms".to_string(), METRIC.to_string())]);
let metrics = BTreeMap::from([("count-min-sketch".to_string(), METRIC.to_string())]);
let (table, skipped) = reduce_all(&[good, bad, unnamed], &metrics);
assert_eq!(table.len(), 1);
assert_eq!(table[0].accuracy(), Some(0.01));
Expand All @@ -735,8 +735,8 @@ mod tests {
// Pinned so a field rename here can't silently break ASAPQuery's
// loader, which deserializes this exact shape.
let entry = AtomicCostEntry {
sketch: "cms".into(),
sketch_config: serde_json::json!({"algorithm": "cms", "params": {"rows": 3, "cols": 1024}}),
sketch: "count-min-sketch".into(),
sketch_config: serde_json::json!({"algorithm": "count-min-sketch", "params": {"rows": 3, "cols": 1024}}),
mem_bytes_per_instance: 12288.0,
insert_cpu_secs: 5e-7,
merge_cpu_secs: 1e-2,
Expand All @@ -756,7 +756,7 @@ mod tests {
let json = serde_json::to_string(&entry).unwrap();
assert_eq!(
json,
r#"{"sketch":"cms","sketch_config":{"algorithm":"cms","params":{"cols":1024,"rows":3}},"mem_bytes_per_instance":12288.0,"insert_cpu_secs":5e-7,"merge_cpu_secs":0.01,"query_cpu_secs":4e-6,"query_accuracy":{"relative_error_mean":0.01},"accuracy_metric":"relative_error_mean","measured_at":{"items_per_instance":1000000,"keys_per_instance":10000,"value_range":null,"merge_operand_items":null,"distribution":null}}"#
r#"{"sketch":"count-min-sketch","sketch_config":{"algorithm":"count-min-sketch","params":{"cols":1024,"rows":3}},"mem_bytes_per_instance":12288.0,"insert_cpu_secs":5e-7,"merge_cpu_secs":0.01,"query_cpu_secs":4e-6,"query_accuracy":{"relative_error_mean":0.01},"accuracy_metric":"relative_error_mean","measured_at":{"items_per_instance":1000000,"keys_per_instance":10000,"value_range":null,"merge_operand_items":null,"distribution":null}}"#
);
// A Hydra row also names its dataset and schema width; other rows
// leave both out, and rows written before them still load.
Expand Down
6 changes: 3 additions & 3 deletions aqpbm-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ pub enum Cmd {
override_usage = "approxbench sketchbench [OPTIONS] --variant <VARIANT> --library <LIBRARY>\n approxbench sketchbench --list-impls"
)]
pub struct SketchbenchArgs {
/// Accumulator variant, structural detail included: `cms` and
/// `cms-fastpath-vector2d` are two of them, because a different hash
/// Accumulator variant, structural detail included: `count-min-sketch` and
/// `count-min-sketch-fastpath-vector2d` are two of them, because a different hash
/// strategy gives different estimates. Matched exactly, since one
/// invocation measures one target. `--list-impls` prints every
/// (variant, library) pair, grouped by the algorithm they share knobs with.
Expand All @@ -59,7 +59,7 @@ pub struct SketchbenchArgs {
help_heading = "Identity"
)]
pub variant: Option<String>,
/// Implementing library, and only that: `oxide`, `datasketches`, `lib` or
/// Implementing library, and only that: `sketch_oxide`, `datasketches`, `asap_sketchlib` or
/// `polars`. `--list-impls` shows which the variant offers. One
/// invocation measures one (library, config) point; to race several, invoke
/// once per library.
Expand Down
2 changes: 1 addition & 1 deletion aqpbm-cli/src/repeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ mod tests {
},
1000,
);
let mut rec = Record::new("cms", "oxide", wd, Mode::Bench, 5);
let mut rec = Record::new("count-min-sketch", "sketch_oxide", wd, Mode::Bench, 5);
rec.bench = Some(BenchSection {
metric: Some("latency".into()),
operation: Some("merge".into()),
Expand Down
28 changes: 20 additions & 8 deletions aqpbm-cli/tests/hydra_grouping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ fn scored(
#[test]
fn any_label_subset_is_asked_where_it_was_inserted() {
let rows = [
("hydra-cms", "rows=3 cols=1024 cell_rows=3 cell_cols=256", "i64"),
("hydra-cs", "rows=3 cols=1024 cell_rows=3 cell_cols=256", "i64"),
("hydra-hll", "rows=3 cols=1024", "i64"),
("hydra-count-min-sketch", "rows=3 cols=1024 cell_rows=3 cell_cols=256", "i64"),
("hydra-count-sketch", "rows=3 cols=1024 cell_rows=3 cell_cols=256", "i64"),
("hydra-hyperloglog", "rows=3 cols=1024", "i64"),
("hydra-kll", "rows=3 cols=1024 cell_k=4096", "f64"),
("hydra-kll-cdf", "rows=3 cols=1024 cell_k=4096", "f64"),
("hydra-kll-cumulative-distribution", "rows=3 cols=1024 cell_k=4096", "f64"),
(
"hydra-univmon-l1-norm",
"rows=3 cols=1024 cell_heap_size=64 cell_sketch_row=3 cell_sketch_col=256 cell_layer_size=4",
Expand All @@ -94,7 +94,7 @@ fn any_label_subset_is_asked_where_it_was_inserted() {
];
for (variant, config, dtype) in rows {
for group_columns in ["1", "0,1"] {
for (library, tolerance) in [("polars", 0.0), ("lib", 0.01)] {
for (library, tolerance) in [("polars", 0.0), ("asap_sketchlib", 0.01)] {
let (acc, csv) = scored(variant, library, config, dtype, group_columns);
let at = format!("{variant}/{library} --group-columns {group_columns}: {acc}");
assert!(acc["err_max"].as_f64().expect(&at) <= tolerance, "{at}");
Expand Down Expand Up @@ -143,7 +143,13 @@ fn any_label_subset_is_asked_where_it_was_inserted() {
fn a_group_column_past_the_labels_is_refused() {
let spec = spec("i64");
let out = Command::new(env!("CARGO_BIN_EXE_approxbench"))
.args(["sketchbench", "--variant", "hydra-cms", "--library", "lib"])
.args([
"sketchbench",
"--variant",
"hydra-count-min-sketch",
"--library",
"asap_sketchlib",
])
.args([
"--spec",
spec.to_str().expect("utf-8 path"),
Expand All @@ -167,7 +173,13 @@ fn per_group_out_without_accuracy_is_refused() {
let spec = spec("i64");
let csv = spec.with_extension("no-accuracy.csv");
let out = Command::new(env!("CARGO_BIN_EXE_approxbench"))
.args(["sketchbench", "--variant", "hydra-cms", "--library", "lib"])
.args([
"sketchbench",
"--variant",
"hydra-count-min-sketch",
"--library",
"asap_sketchlib",
])
.args([
"--spec",
spec.to_str().expect("utf-8 path"),
Expand All @@ -190,7 +202,7 @@ fn per_group_out_without_accuracy_is_refused() {
#[test]
fn a_float_sum_is_refused_by_name() {
let spec = spec("f64");
for library in ["lib", "polars"] {
for library in ["asap_sketchlib", "polars"] {
let out = Command::new(env!("CARGO_BIN_EXE_approxbench"))
.args(["sketchbench", "--variant", "hydra-univmon-sum"])
.args(["--library", library, "--dtype", "f64"])
Expand Down
4 changes: 2 additions & 2 deletions aqpbm-cli/tests/merge_accuracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::process::Command;
/// One `--flat` record measuring both the single sketch's and the merged
/// sketch's accuracy over the same small fixed-seed stream.
fn query_and_merge_accuracy(variant: &str, config: &str, dataset: &[&str]) -> serde_json::Value {
run_merge_accuracy(variant, "lib", &["--config", config], dataset)
run_merge_accuracy(variant, "asap_sketchlib", &["--config", config], dataset)
}

fn run_merge_accuracy(
Expand Down Expand Up @@ -40,7 +40,7 @@ fn run_merge_accuracy(
#[test]
fn merged_cms_scores_exactly_like_one_sketch() {
let r = query_and_merge_accuracy(
"cms-fastpath-vector2d",
"count-min-sketch-fastpath-vector2d",
"rows=3 cols=1024",
&[
"--dataset",
Expand Down
26 changes: 18 additions & 8 deletions aqpbm-cli/tests/trials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ const PARETO_F64: &[&str] = &[

fn approxbench(variant: &str, config: &str, args: &[&str]) -> Output {
Command::new(env!("CARGO_BIN_EXE_approxbench"))
.args(["sketchbench", "--variant", variant, "--library", "lib"])
.args([
"sketchbench",
"--variant",
variant,
"--library",
"asap_sketchlib",
])
.args(["--config", config])
.args(["--operations", "query", "--metrics", "accuracy"])
.args(["--runs", "1", "--warmup-runs", "0"])
Expand Down Expand Up @@ -65,12 +71,12 @@ fn identity(record: &serde_json::Value) -> serde_json::Value {
fn a_later_start_reproduces_the_same_trials() {
let cms = "rows=3 cols=256";
let all = records(
"cms-fastpath-vector2d",
"count-min-sketch-fastpath-vector2d",
cms,
&[ZIPF_I64, &["--trials", "64"]].concat(),
);
let tail = records(
"cms-fastpath-vector2d",
"count-min-sketch-fastpath-vector2d",
cms,
&[ZIPF_I64, &["--trial-start", "32", "--trials", "32"]].concat(),
);
Expand All @@ -83,7 +89,7 @@ fn a_later_start_reproduces_the_same_trials() {
#[test]
fn relabel_keeps_the_stream_and_moves_the_collisions() {
let trials = records(
"cms-fastpath-vector2d",
"count-min-sketch-fastpath-vector2d",
"rows=3 cols=64",
&[ZIPF_I64, &["--trials", "8", "--trial-mode", "relabel"]].concat(),
);
Expand Down Expand Up @@ -136,14 +142,14 @@ fn reseed_varies_the_sketch_and_reruns_the_same() {
#[test]
fn reseed_on_a_row_without_a_seed_names_the_rows_with_one() {
let out = approxbench(
"cms-fastpath-vector2d",
"count-min-sketch-fastpath-vector2d",
"rows=3 cols=256",
&[ZIPF_I64, &["--trials", "2", "--trial-mode", "reseed"]].concat(),
);
assert!(!out.status.success());
let err = String::from_utf8_lossy(&out.stderr);
assert!(
err.contains("kll-percall/lib") && err.contains("coco/lib"),
err.contains("kll-percall/asap_sketchlib") && err.contains("cocosketch/asap_sketchlib"),
"{err}"
);
}
Expand All @@ -153,8 +159,12 @@ fn a_fresh_trial_reruns_from_its_own_descriptor() {
let dir = std::env::temp_dir().join(format!("approxbench-trials-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
for (variant, config, dtype) in [
("cms-fastpath-vector2d", "rows=3 cols=256", "i64"),
("bloom", "rows=3 cols=2048", "string"),
(
"count-min-sketch-fastpath-vector2d",
"rows=3 cols=256",
"i64",
),
("bloom-filter", "rows=3 cols=2048", "string"),
] {
let dataset = [&ZIPF_I64[..8], &["--dtype", dtype]].concat();
let trials = records(
Expand Down
4 changes: 2 additions & 2 deletions aqpbm-core/src/accuracy/subpopulation/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn sums_per_group(
) -> Result<SubpopVectorTruth, DataGenError> {
let labels = group_labels(table, group_columns)?;
let values: Vec<f64> = match table.column(value_column)? {
// The lib row inserts each value as a UnivMon count, which can't be
// The asap_sketchlib row inserts each value as a UnivMon count, which can't be
// negative, so the truth refuses negatives too.
ColumnData::Int64(v) if v.iter().any(|&x| x < 0) => {
return Err(DataGenError::BadParam(
Expand Down Expand Up @@ -135,7 +135,7 @@ mod tests {
}

/// A group whose values sum to zero has no relative error: it is listed
/// Negative values are refused, as the lib row refuses them.
/// Negative values are refused, as the asap_sketchlib row refuses them.
#[test]
fn a_negative_value_is_refused() {
use crate::accuracy::table_of;
Expand Down
2 changes: 1 addition & 1 deletion aqpbm-core/src/benchmark_result/flatten_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ mod tests {
},
1000,
);
let mut rec = Record::new("cms", "oxide", wd, Mode::Bench, 1);
let mut rec = Record::new("count-min-sketch", "sketch_oxide", wd, Mode::Bench, 1);
rec.bench = Some(BenchSection {
operation: Some(operation.into()),
metric: Some(metric.into()),
Expand Down
Loading
Loading