diff --git a/aqpbm-cli/src/cli.rs b/aqpbm-cli/src/cli.rs index 743885e2..bd14e42a 100644 --- a/aqpbm-cli/src/cli.rs +++ b/aqpbm-cli/src/cli.rs @@ -228,7 +228,9 @@ pub struct SketchbenchArgs { )] pub operations: Option, /// How many shards the merge operation folds. A knob, never a selector: - /// measuring merge is asked for with `--operations merge`. Linear sketches + /// measuring merge is asked for with `--operations merge`. With + /// `--metrics accuracy` the folded sketch is asked the query's questions and + /// scored against the whole stream, as `merge_accuracy`. Linear sketches /// merge exactly, so a gap is a defect; for KLL it is the result. #[arg(long, default_value_t = 2, help_heading = "Measurement content")] pub merge_shards: usize, diff --git a/aqpbm-cli/src/flatten_record.rs b/aqpbm-cli/src/flatten_record.rs index 124c3a63..c69b1004 100644 --- a/aqpbm-cli/src/flatten_record.rs +++ b/aqpbm-cli/src/flatten_record.rs @@ -113,8 +113,24 @@ pub fn flatten_record(records: &[Record]) -> Result { } }; } - // `throughput_items_per_sec`, `latency_ns`, `accuracy` and the - // `merge_*` fields are each owned by exactly one metric-pass per + // `merge_shards`/`merge_supported` describe the merge setup, which + // every merge square of one invocation stamps — equal values agree, + // different ones mean two setups were folded together. + macro_rules! keep_same { + ($slot:expr, $v:expr, $field:literal) => { + if let Some(v) = $v { + if $slot.is_some_and(|s| s != v) { + return Err(format!( + "flatten_record: {}/{} {operation} has two different values for {}", + record.sketch, record.library, $field + )); + } + $slot = Some(v); + } + }; + } + // `throughput_items_per_sec`, `latency_ns`, `accuracy` and + // `merge_folds_per_sec` are each owned by exactly one metric-pass per // operation — nothing legitimately produces a second value for one // of these within a slot. A second value is a genuine duplicate, so // it is refused by field name rather than silently resolved. @@ -166,12 +182,13 @@ pub fn flatten_record(records: &[Record]) -> Result { *merge_folds_per_sec, "merge_folds_per_sec" ); - keep_owned!(out.merge.merge_shards, *merge_shards, "merge_shards"); - keep_owned!( + keep_same!(out.merge.merge_shards, *merge_shards, "merge_shards"); + keep_same!( out.merge.merge_supported, *merge_supported, "merge_supported" ); + keep_owned!(out.merge.accuracy, accuracy.clone(), "accuracy"); keep_shared!(out.merge.cpu_time_ms, cpu_time_ms); keep_shared!(out.merge.wall_time_ms, wall_time_ms); keep_shared!(out.merge.rss_peak_kb, rss_peak_kb); @@ -382,6 +399,29 @@ mod tests { assert_eq!(out.insert.wall_time_ms.unwrap().mean, 1.0); } + /// A cost pass and an accuracy pass over one merge both stamp the merge + /// setup. The same setup twice is one setup; two different ones are not. + #[test] + fn merge_setup_on_two_squares_must_agree() { + let merge = |metric, shards| { + record( + "merge", + metric, + BenchSection { + merge_shards: Some(shards), + merge_supported: Some(true), + ..Default::default() + }, + ) + }; + let out = flatten_record(&[merge("throughput", 4), merge("accuracy", 4)]) + .expect("the same setup agrees"); + assert_eq!(out.merge.merge_shards, Some(4)); + let err = flatten_record(&[merge("throughput", 4), merge("accuracy", 16)]) + .expect_err("two setups in one row"); + assert!(err.contains("merge_shards"), "{err}"); + } + /// `throughput_items_per_sec` is owned by exactly one metric-pass per /// operation — nothing legitimately produces it twice for `insert`. A /// second value here is a genuine duplicate, refused by field name diff --git a/aqpbm-cli/src/rows/cms.rs b/aqpbm-cli/src/rows/cms.rs index b6cef13f..081f13ae 100644 --- a/aqpbm-cli/src/rows/cms.rs +++ b/aqpbm-cli/src/rows/cms.rs @@ -19,7 +19,11 @@ pub(crate) fn row_cms_oxide( co::insert_cms_oxide::<$t>, co::insert_step_cms_oxide::<$t>, co::query_cms_oxide::<$t>, - Some((co::merge_cms_oxide::<$t>, co::merge_step_cms_oxide)), + Some(( + co::merge_cms_oxide::<$t>, + co::merge_step_cms_oxide, + co::merge_query_cms_oxide::<$t>, + )), None, ) }; @@ -51,6 +55,7 @@ pub(crate) fn row_cms_datasketches( Some(( cd::merge_cms_datasketches::<$t>, cd::merge_step_cms_datasketches, + cd::merge_query_cms_datasketches::<$t>, )), None, ) @@ -112,6 +117,7 @@ pub(crate) fn row_cms_fastpath_vector2d_lib( Some(( cl::merge_cms_lib_vector2d_fast::<$t>, cl::merge_step_cms_lib_vector2d_fast::<$t>, + cl::merge_query_cms_lib_vector2d_fast::<$t>, )), None, ) @@ -144,6 +150,7 @@ pub(crate) fn row_cms_regularpath_vector2d_lib( Some(( cl::merge_cms_lib_vector2d_regular::<$t>, cl::merge_step_cms_lib_vector2d_regular::<$t>, + cl::merge_query_cms_lib_vector2d_regular::<$t>, )), None, ) diff --git a/aqpbm-cli/src/rows/cms_heap.rs b/aqpbm-cli/src/rows/cms_heap.rs index 58862dc0..2e7aab82 100644 --- a/aqpbm-cli/src/rows/cms_heap.rs +++ b/aqpbm-cli/src/rows/cms_heap.rs @@ -23,6 +23,7 @@ pub(crate) fn row_cms_heap_fastpath_vector2d_lib( Some(( chl::merge_cms_heap_lib_vector2d_fast::<$t>, chl::merge_step_cms_heap_lib_vector2d_fast::<$t>, + chl::merge_query_cms_heap_lib_vector2d_fast_estimate::<$t>, )), None, ) @@ -55,6 +56,7 @@ pub(crate) fn row_cms_heap_regularpath_vector2d_lib( Some(( chl::merge_cms_heap_lib_vector2d_regular::<$t>, chl::merge_step_cms_heap_lib_vector2d_regular::<$t>, + chl::merge_query_cms_heap_lib_vector2d_regular_estimate::<$t>, )), None, ) @@ -87,6 +89,7 @@ pub(crate) fn row_cms_heap_topk_fastpath_vector2d_lib( Some(( chl::merge_cms_heap_lib_vector2d_fast::<$t>, chl::merge_step_cms_heap_lib_vector2d_fast::<$t>, + chl::merge_query_cms_heap_lib_vector2d_fast_topk::<$t>, )), ) }; @@ -118,6 +121,7 @@ pub(crate) fn row_cms_heap_topk_regularpath_vector2d_lib( Some(( chl::merge_cms_heap_lib_vector2d_regular::<$t>, chl::merge_step_cms_heap_lib_vector2d_regular::<$t>, + chl::merge_query_cms_heap_lib_vector2d_regular_topk::<$t>, )), ) }; diff --git a/aqpbm-cli/src/rows/cs.rs b/aqpbm-cli/src/rows/cs.rs index ee44b315..8a9b3457 100644 --- a/aqpbm-cli/src/rows/cs.rs +++ b/aqpbm-cli/src/rows/cs.rs @@ -19,7 +19,11 @@ pub(crate) fn row_countsketch_oxide( so::insert_cs_oxide, so::insert_step_cs_oxide, so::query_cs_oxide, - Some((so::merge_cs_oxide, so::merge_step_cs_oxide)), + Some(( + so::merge_cs_oxide, + so::merge_step_cs_oxide, + so::merge_query_cs_oxide, + )), None, ) }; @@ -80,6 +84,7 @@ pub(crate) fn row_countsketch_fastpath_vector2d_lib( Some(( sl::merge_cs_lib_vector2d_fast, sl::merge_step_cs_lib_vector2d_fast, + sl::merge_query_cs_lib_vector2d_fast, )), None, ) @@ -112,6 +117,7 @@ pub(crate) fn row_countsketch_regularpath_vector2d_lib( Some(( sl::merge_cs_lib_vector2d_regular, sl::merge_step_cs_lib_vector2d_regular, + sl::merge_query_cs_lib_vector2d_regular, )), None, ) diff --git a/aqpbm-cli/src/rows/dd.rs b/aqpbm-cli/src/rows/dd.rs index 71fdc826..aa700f2f 100644 --- a/aqpbm-cli/src/rows/dd.rs +++ b/aqpbm-cli/src/rows/dd.rs @@ -19,7 +19,11 @@ pub(crate) fn row_dd_lib( ddl::insert_dd_lib::<$t>, ddl::insert_step_dd_lib::<$t>, ddl::query_dd_lib::<$t>, - Some((ddl::merge_dd_lib::<$t>, ddl::merge_step_dd_lib::<$t>)), + Some(( + ddl::merge_dd_lib::<$t>, + ddl::merge_step_dd_lib::<$t>, + ddl::merge_query_dd_lib::<$t>, + )), None, ) }; @@ -48,7 +52,11 @@ pub(crate) fn row_dd_oxide( ddo::insert_dd_oxide::<$t>, ddo::insert_step_dd_oxide::<$t>, ddo::query_dd_oxide::<$t>, - Some((ddo::merge_dd_oxide::<$t>, ddo::merge_step_dd_oxide::<$t>)), + Some(( + ddo::merge_dd_oxide::<$t>, + ddo::merge_step_dd_oxide::<$t>, + ddo::merge_query_dd_oxide::<$t>, + )), None, ) }; diff --git a/aqpbm-cli/src/rows/fixed_matrix.rs b/aqpbm-cli/src/rows/fixed_matrix.rs index 26ed88fb..fd58a4bd 100644 --- a/aqpbm-cli/src/rows/fixed_matrix.rs +++ b/aqpbm-cli/src/rows/fixed_matrix.rs @@ -7,7 +7,7 @@ use super::*; /// erased list, so nothing in the return type mentions the shape it ran at. macro_rules! fixed_matrix_row { ($fname:ident, $params:ty, $algo:literal, $module:ident, $insert:ident, $insert_step:ident, - $query:ident, $merge:ident, $merge_step:ident) => { + $query:ident, $merge:ident, $merge_step:ident, $merge_query:ident) => { pub(crate) fn $fname( req: &Requirement, description: &TableDescription, @@ -54,7 +54,11 @@ macro_rules! fixed_matrix_row { w::$insert::, w::$insert_step::, w::$query::, - Some((w::$merge::, w::$merge_step::)), + Some(( + w::$merge::, + w::$merge_step::, + w::$merge_query::, + )), None, ) } @@ -95,7 +99,8 @@ fixed_matrix_row!( insert_step_cms_lib_fixedmatrix, query_cms_lib_fixedmatrix, merge_cms_lib_fixedmatrix, - merge_step_cms_lib_fixedmatrix + merge_step_cms_lib_fixedmatrix, + merge_query_cms_lib_fixedmatrix ); fixed_matrix_row!( @@ -107,5 +112,6 @@ fixed_matrix_row!( insert_step_cs_lib_fixedmatrix, query_cs_lib_fixedmatrix, merge_cs_lib_fixedmatrix, - merge_step_cs_lib_fixedmatrix + merge_step_cs_lib_fixedmatrix, + merge_query_cs_lib_fixedmatrix ); diff --git a/aqpbm-cli/src/rows/hll.rs b/aqpbm-cli/src/rows/hll.rs index 3b5aa535..a2bac394 100644 --- a/aqpbm-cli/src/rows/hll.rs +++ b/aqpbm-cli/src/rows/hll.rs @@ -21,7 +21,11 @@ pub(crate) fn row_hll_oxide( ho::insert_hll_oxide::<$t>, ho::insert_step_hll_oxide::<$t>, ho::query_hll_oxide::<$t>, - Some((ho::merge_hll_oxide::<$t>, ho::merge_step_hll_oxide::<$t>)), + Some(( + ho::merge_hll_oxide::<$t>, + ho::merge_step_hll_oxide::<$t>, + ho::merge_query_hll_oxide::<$t>, + )), None, ) }; @@ -53,6 +57,7 @@ pub(crate) fn row_hll_datasketches( Some(( hd::merge_hll_datasketches::<$t>, hd::merge_step_hll_datasketches::<$t>, + hd::merge_query_hll_datasketches::<$t>, )), None, ) @@ -149,6 +154,7 @@ pub(crate) fn row_hll_lib( Some(( hl::merge_hll_lib::<$r, $t>, hl::merge_step_hll_lib::<$r, $t>, + hl::merge_query_hll_lib::<$r, $t>, )), None, ) diff --git a/aqpbm-cli/src/rows/hydra.rs b/aqpbm-cli/src/rows/hydra.rs index 20788e4f..a1a60241 100644 --- a/aqpbm-cli/src/rows/hydra.rs +++ b/aqpbm-cli/src/rows/hydra.rs @@ -22,7 +22,11 @@ pub(crate) fn row_hydra_cms_lib( hs::insert_hydra_cms::<$t>, hs::insert_step_hydra_cms::<$t>, hs::query_hydra_cms::<$t>, - Some((hs::merge_hydra_cms::<$t>, hs::merge_step_hydra_cms::<$t>)), + Some(( + hs::merge_hydra_cms::<$t>, + hs::merge_step_hydra_cms::<$t>, + hs::merge_query_hydra_cms::<$t>, + )), None, ) }; @@ -80,7 +84,11 @@ pub(crate) fn row_hydra_cs_lib( hcs::insert_hydra_cs::<$t>, hcs::insert_step_hydra_cs::<$t>, hcs::query_hydra_cs::<$t>, - Some((hcs::merge_hydra_cs::<$t>, hcs::merge_step_hydra_cs::<$t>)), + Some(( + hcs::merge_hydra_cs::<$t>, + hcs::merge_step_hydra_cs::<$t>, + hcs::merge_query_hydra_cs::<$t>, + )), None, ) }; @@ -138,7 +146,11 @@ pub(crate) fn row_hydra_hll_lib( hhs::insert_hydra_hll::<$t>, hhs::insert_step_hydra_hll::<$t>, hhs::query_hydra_hll::<$t>, - Some((hhs::merge_hydra_hll::<$t>, hhs::merge_step_hydra_hll::<$t>)), + Some(( + hhs::merge_hydra_hll::<$t>, + hhs::merge_step_hydra_hll::<$t>, + hhs::merge_query_hydra_hll::<$t>, + )), None, ) }; @@ -196,7 +208,11 @@ pub(crate) fn row_hydra_kll_lib( hks::insert_hydra_kll::<$t>, hks::insert_step_hydra_kll::<$t>, hks::query_hydra_kll::<$t>, - Some((hks::merge_hydra_kll::<$t>, hks::merge_step_hydra_kll::<$t>)), + Some(( + hks::merge_hydra_kll::<$t>, + hks::merge_step_hydra_kll::<$t>, + hks::merge_query_hydra_kll::<$t>, + )), None, ) }; diff --git a/aqpbm-cli/src/rows/hydra_univmon.rs b/aqpbm-cli/src/rows/hydra_univmon.rs index 0de6be73..eca3acd0 100644 --- a/aqpbm-cli/src/rows/hydra_univmon.rs +++ b/aqpbm-cli/src/rows/hydra_univmon.rs @@ -20,6 +20,7 @@ pub(crate) fn row_hydra_univmon_cardinality_lib( Some(( hus::merge_hydra_univmon::<$t>, hus::merge_step_hydra_univmon::<$t>, + hus::merge_query_hydra_univmon_cardinality::<$t>, )), None, ) @@ -85,6 +86,7 @@ pub(crate) fn row_hydra_univmon_l1_norm_lib( Some(( hus::merge_hydra_univmon::<$t>, hus::merge_step_hydra_univmon::<$t>, + hus::merge_query_hydra_univmon_l1_norm::<$t>, )), None, ) @@ -154,6 +156,7 @@ pub(crate) fn row_hydra_univmon_l2_norm_lib( Some(( hus::merge_hydra_univmon::<$t>, hus::merge_step_hydra_univmon::<$t>, + hus::merge_query_hydra_univmon_l2_norm::<$t>, )), None, ) @@ -223,6 +226,7 @@ pub(crate) fn row_hydra_univmon_entropy_lib( Some(( hus::merge_hydra_univmon::<$t>, hus::merge_step_hydra_univmon::<$t>, + hus::merge_query_hydra_univmon_entropy::<$t>, )), None, ) diff --git a/aqpbm-cli/src/rows/kll.rs b/aqpbm-cli/src/rows/kll.rs index 8a5134e9..0d941a86 100644 --- a/aqpbm-cli/src/rows/kll.rs +++ b/aqpbm-cli/src/rows/kll.rs @@ -27,6 +27,7 @@ pub(crate) fn row_kll_percall_oxide( Some(( ko::merge_kll_oxide_per_call::<$t>, ko::merge_step_kll_oxide_per_call::<$t>, + ko::merge_query_kll_oxide_per_call::<$t>, )), None, ) @@ -59,6 +60,7 @@ pub(crate) fn row_kll_percall_lib( Some(( kl::merge_kll_lib_per_call::<$t>, kl::merge_step_kll_lib_per_call::<$t>, + kl::merge_query_kll_lib_per_call::<$t>, )), None, ) @@ -91,6 +93,7 @@ pub(crate) fn row_kll_cdf_oxide( Some(( ko::merge_kll_oxide_cdf::<$t>, ko::merge_step_kll_oxide_cdf::<$t>, + ko::merge_query_kll_oxide_cdf::<$t>, )), Some(ko::prepare_kll_oxide_cdf::<$t>), ) @@ -123,6 +126,7 @@ pub(crate) fn row_kll_cdf_lib( Some(( kl::merge_kll_lib_cdf::<$t>, kl::merge_step_kll_lib_cdf::<$t>, + kl::merge_query_kll_lib_cdf::<$t>, )), Some(kl::prepare_kll_lib_cdf::<$t>), ) diff --git a/aqpbm-cli/src/rows/statistic.rs b/aqpbm-cli/src/rows/statistic.rs index 7a49cef2..504c583a 100644 --- a/aqpbm-cli/src/rows/statistic.rs +++ b/aqpbm-cli/src/rows/statistic.rs @@ -30,7 +30,7 @@ pub(super) fn frequency_row( insert: InsertBody, insert_step: InsertStepBody, query: QueryBody, - merge: Option>, + merge: Option>, prepare: Option>, ) -> Result { scored_row( @@ -59,7 +59,7 @@ pub(super) fn cardinality_row( insert: InsertBody, insert_step: InsertStepBody, query: QueryBody, - merge: Option>, + merge: Option>, prepare: Option>, ) -> Result { scored_row( @@ -93,7 +93,7 @@ pub(super) fn topk_row( insert: InsertBody, insert_step: InsertStepBody, query: QueryBody>, - merge: Option>, + merge: Option>>, ) -> Result { scored_row( req, @@ -112,7 +112,7 @@ pub(super) fn topk_row( /// A row answering **subpopulation frequency**: how often a value occurs inside /// a group. -#[allow(clippy::too_many_arguments)] +#[allow(clippy::too_many_arguments, clippy::type_complexity)] pub(super) fn subpop_frequency_row( req: &Requirement, description: &TableDescription, @@ -121,7 +121,7 @@ pub(super) fn subpop_frequency_row( insert: InsertBody<(String, V)>, insert_step: InsertStepBody<(String, V)>, query: QueryBody<(String, V), (Vec, V), f64>, - merge: Option>, + merge: Option, V), f64>>, prepare: Option>, ) -> Result { scored_row( @@ -150,7 +150,7 @@ pub(super) fn subpop_cardinality_row( insert: InsertBody<(String, V)>, insert_step: InsertStepBody<(String, V)>, query: QueryBody<(String, V), Vec, f64>, - merge: Option>, + merge: Option, f64>>, prepare: Option>, ) -> Result { scored_row( @@ -183,7 +183,7 @@ pub(super) fn subpop_vector_row( insert: InsertBody<(String, V)>, insert_step: InsertStepBody<(String, V)>, query: QueryBody<(String, V), Vec, f64>, - merge: Option>, + merge: Option, f64>>, prepare: Option>, ) -> Result where @@ -205,7 +205,7 @@ where ) } -#[allow(clippy::too_many_arguments)] +#[allow(clippy::too_many_arguments, clippy::type_complexity)] pub(super) fn subpop_quantile_row( req: &Requirement, description: &TableDescription, @@ -214,7 +214,7 @@ pub(super) fn subpop_quantile_row( insert: InsertBody<(String, V)>, insert_step: InsertStepBody<(String, V)>, query: QueryBody<(String, V), (Vec, f64), f64>, - merge: Option>, + merge: Option, f64), f64>>, prepare: Option>, ) -> Result { scored_row( @@ -245,7 +245,7 @@ pub(super) fn keyed_row( insert: InsertBody<(K, i64)>, insert_step: InsertStepBody<(K, i64)>, query: QueryBody<(K, i64), (), f64>, - merge: Option>, + merge: Option>, prepare: Option>, ) -> Result where @@ -278,7 +278,7 @@ pub(super) fn quantile_row( insert: InsertBody, insert_step: InsertStepBody, query: QueryBody, - merge: Option>, + merge: Option>, prepare: Option>, ) -> Result { scored_row( @@ -309,7 +309,7 @@ pub(super) fn scored_row( insert: InsertBody, insert_step: InsertStepBody, query: QueryBody, - merge: Option>, + merge: Option>, prepare: Option>, ) -> Result where @@ -336,6 +336,20 @@ where score.clone(), metric, ), + // Scored exactly as the query is: same probes, same comparator, and + // the truth is still the whole stream, split across the shards. + (Operation::Merge, Metric::Accuracy) => answered( + merge.expect(SUPPORTED).2( + &req.params, + items.clone(), + probes.clone(), + shards(req), + n, + ) + .map_err(cannot_build)?, + score.clone(), + metric, + ), (Operation::Merge, Metric::Latency) => stepped( merge.expect(SUPPORTED).1(&req.params, items.clone(), shards(req), n) .map_err(cannot_build)?, diff --git a/aqpbm-cli/src/rows/univmon.rs b/aqpbm-cli/src/rows/univmon.rs index 7b8469f3..a1030d9e 100644 --- a/aqpbm-cli/src/rows/univmon.rs +++ b/aqpbm-cli/src/rows/univmon.rs @@ -21,6 +21,7 @@ pub(crate) fn row_univmon_cardinality_lib( Some(( ul::merge_univmon_lib::<$k>, ul::merge_step_univmon_lib::<$k>, + ul::merge_query_univmon_lib_cardinality::<$k>, )), None, ) @@ -54,6 +55,7 @@ pub(crate) fn row_univmon_l1_norm_lib( Some(( ul::merge_univmon_lib::<$k>, ul::merge_step_univmon_lib::<$k>, + ul::merge_query_univmon_lib_l1_norm::<$k>, )), None, ) @@ -87,6 +89,7 @@ pub(crate) fn row_univmon_l1_norm_oxide( Some(( uo::merge_univmon_oxide::<$k>, uo::merge_step_univmon_oxide::<$k>, + uo::merge_query_univmon_oxide_l1_norm::<$k>, )), None, ) @@ -120,6 +123,7 @@ pub(crate) fn row_univmon_l2_norm_lib( Some(( ul::merge_univmon_lib::<$k>, ul::merge_step_univmon_lib::<$k>, + ul::merge_query_univmon_lib_l2_norm::<$k>, )), None, ) @@ -153,6 +157,7 @@ pub(crate) fn row_univmon_l2_norm_oxide( Some(( uo::merge_univmon_oxide::<$k>, uo::merge_step_univmon_oxide::<$k>, + uo::merge_query_univmon_oxide_l2_norm::<$k>, )), None, ) @@ -186,6 +191,7 @@ pub(crate) fn row_univmon_entropy_lib( Some(( ul::merge_univmon_lib::<$k>, ul::merge_step_univmon_lib::<$k>, + ul::merge_query_univmon_lib_entropy::<$k>, )), None, ) @@ -219,6 +225,7 @@ pub(crate) fn row_univmon_entropy_oxide( Some(( uo::merge_univmon_oxide::<$k>, uo::merge_step_univmon_oxide::<$k>, + uo::merge_query_univmon_oxide_entropy::<$k>, )), None, ) diff --git a/aqpbm-cli/tests/merge_accuracy.rs b/aqpbm-cli/tests/merge_accuracy.rs new file mode 100644 index 00000000..08506d00 --- /dev/null +++ b/aqpbm-cli/tests/merge_accuracy.rs @@ -0,0 +1,72 @@ +//! `--operations merge --metrics accuracy`: the sketch folded from shards is +//! scored like the query, against the whole stream. + +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 { + let out = Command::new(env!("CARGO_BIN_EXE_approxbench")) + .args(["sketchbench", "--variant", variant, "--library", "lib"]) + .args(["--config", config]) + .args(["--operations", "query,merge", "--metrics", "accuracy"]) + .args(["--merge-shards", "4", "--runs", "1", "--warmup-runs", "0"]) + .args(["--size", "20000", "--seed", "7", "--flat"]) + .args(dataset) + .env("BENCH_WARMUP_SECS", "0") + .output() + .expect("approxbench runs"); + assert!( + out.status.success(), + "{}", + String::from_utf8_lossy(&out.stderr) + ); + let stdout = String::from_utf8(out.stdout).expect("utf-8"); + let last = stdout.lines().last().expect("one record"); + serde_json::from_str(last).expect("a JSON record") +} + +/// CMS counters add, so four shards folded are the sketch fed the whole +/// stream: every score must match, not just come close. +#[test] +fn merged_cms_scores_exactly_like_one_sketch() { + let r = query_and_merge_accuracy( + "cms-fastpath-vector2d", + "rows=3 cols=1024", + &[ + "--dataset", + "zipf", + "--zipf-s", + "1.0", + "--cardinality", + "1000", + "--dtype", + "i64", + ], + ); + assert!(r["merge_accuracy"].is_object(), "{r}"); + assert_eq!(r["merge_accuracy"], r["query_accuracy"]); +} + +/// KLL merges are lossy, so only a finite score is promised. +#[test] +fn merged_kll_scores_finite() { + let r = query_and_merge_accuracy( + "kll-percall", + "k=200", + &[ + "--dataset", + "pareto", + "--pareto-alpha", + "2", + "--cardinality", + "1", + "--dtype", + "f64", + ], + ); + let err = r["merge_accuracy"]["mean_rank_err"] + .as_f64() + .unwrap_or_else(|| panic!("no merged mean_rank_err in {r}")); + assert!(err.is_finite(), "{err}"); +} diff --git a/aqpbm-core/schema/merged_record.schema.json b/aqpbm-core/schema/merged_record.schema.json index 3fd038c0..0a1f9eb8 100644 --- a/aqpbm-core/schema/merged_record.schema.json +++ b/aqpbm-core/schema/merged_record.schema.json @@ -99,6 +99,9 @@ "format": "uint64", "minimum": 0 }, + "merge_accuracy": { + "description": "The same comparator as `query_accuracy`, against the same whole-stream\ntruth, scoring the sketch left by folding `merge_shards` contiguous\nshards. A linear sketch should match `query_accuracy` exactly." + }, "merge_cpu_time_ms": { "anyOf": [ { @@ -214,7 +217,7 @@ ] }, "query_accuracy": { - "description": "The comparator's scores. Only this operation has them: accuracy is\nwhat an answer can be scored for, and query is what produces one." + "description": "The comparator's scores for the sketch fed the whole stream. Merge\ncarries the same scores for a folded sketch in `merge_accuracy`." }, "query_cpu_time_ms": { "anyOf": [ @@ -314,6 +317,7 @@ "insert_wall_time_ms", "language", "memory_bytes", + "merge_accuracy", "merge_cpu_time_ms", "merge_heap_allocated_kb", "merge_rss_peak_kb", diff --git a/aqpbm-core/src/benchmark_result/schema.rs b/aqpbm-core/src/benchmark_result/schema.rs index 8568e3b9..6b644160 100644 --- a/aqpbm-core/src/benchmark_result/schema.rs +++ b/aqpbm-core/src/benchmark_result/schema.rs @@ -300,8 +300,8 @@ pub struct QueryMetrics { pub throughput_items_per_sec: Option, #[serde(rename = "query_latency_ns")] pub latency_ns: Option, - /// The comparator's scores. Only this operation has them: accuracy is - /// what an answer can be scored for, and query is what produces one. + /// The comparator's scores for the sketch fed the whole stream. Merge + /// carries the same scores for a folded sketch in `merge_accuracy`. #[serde(rename = "query_accuracy")] pub accuracy: Option, #[serde(rename = "query_cpu_time_ms")] @@ -324,6 +324,11 @@ pub struct MergeMetrics { pub merge_folds_per_sec: Option, pub merge_shards: Option, pub merge_supported: Option, + /// The same comparator as `query_accuracy`, against the same whole-stream + /// truth, scoring the sketch left by folding `merge_shards` contiguous + /// shards. A linear sketch should match `query_accuracy` exactly. + #[serde(rename = "merge_accuracy")] + pub accuracy: Option, #[serde(rename = "merge_cpu_time_ms")] pub cpu_time_ms: Option, #[serde(rename = "merge_wall_time_ms")] diff --git a/aqpbm-core/src/metrics/mask.rs b/aqpbm-core/src/metrics/mask.rs index 2b2c6e93..1b4958dc 100644 --- a/aqpbm-core/src/metrics/mask.rs +++ b/aqpbm-core/src/metrics/mask.rs @@ -124,8 +124,8 @@ pub fn is_measurable(operation: Operation, metric: Metric) -> bool { (Insert, Accuracy) => false, (Query, Throughput) | (Query, Accuracy) => true, (Query, Latency) => false, - (Merge, Throughput) | (Merge, Latency) => true, - (Merge, Accuracy) => false, + // Accuracy of the sketch the fold leaves, asked the query's questions. + (Merge, Throughput) | (Merge, Latency) | (Merge, Accuracy) => true, (Prepare, Throughput) => false, (Prepare, Latency) => true, (Prepare, Accuracy) => false, @@ -172,7 +172,7 @@ mod tests { } #[test] - fn five_of_the_twelve_pairs_are_permanently_empty() { + fn four_of_the_twelve_pairs_are_permanently_empty() { // Four operations by three metrics is the whole of what this crate can // be asked for, whatever it happens to implement. let pairs: Vec<_> = Operation::ALL @@ -191,7 +191,6 @@ mod tests { vec![ ("insert", "accuracy"), ("query", "latency"), - ("merge", "accuracy"), ("prepare", "throughput"), ("prepare", "accuracy"), ] diff --git a/docs/figures/saturation/merge/README.md b/docs/figures/saturation/merge/README.md new file mode 100644 index 00000000..df132e2d --- /dev/null +++ b/docs/figures/saturation/merge/README.md @@ -0,0 +1,19 @@ +# Accuracy after merging + +Drawn by `scripts/plot_saturation_merge.py` from `saturation_merge_curve.csv` +(`--merge-shards-list 1,4,16,64`, first config per sketch, N up to 1e7, +3 seeds, theta 0.5/1.0/1.5 x K 1e3/1e5/1e7, Pareto alpha 1.1/2). + +- `merge_error_vs_N__.png`: one panel per distribution; m = 1 (blue, + thick) is one sketch fed all N items, m = 4/16/64 split the same stream into + m contiguous shards, build one sketch per shard and merge them. Bands are + ±2 SE over seeds. +- `merge_ratio_at_nmax.png`: merged / single error at N = 1e7, one dot per + distribution and shard count. 1.0 means merging is exact. + +Reading: CMS, CountSketch, HLL and DDSketch sit exactly on 1.0 (the m lines +overlap). KLL drifts within seed noise up to m = 16 and is 5–16% higher at +m = 64. CMS-heap top-k is unchanged at K = 1e3 but loses 0.03–0.09 precision +at K >= 1e5 with theta >= 1, most visibly once N > 1e5 — a globally heavy key +can fall out of every shard's heap — so for top-k the single-sketch curve is +optimistic for merged windows. diff --git a/docs/figures/saturation/merge/merge_error_vs_N__cms-fastpath-vector2d.png b/docs/figures/saturation/merge/merge_error_vs_N__cms-fastpath-vector2d.png new file mode 100644 index 00000000..6a32ad92 Binary files /dev/null and b/docs/figures/saturation/merge/merge_error_vs_N__cms-fastpath-vector2d.png differ diff --git a/docs/figures/saturation/merge/merge_error_vs_N__cms-heap-topk-fastpath-vector2d.png b/docs/figures/saturation/merge/merge_error_vs_N__cms-heap-topk-fastpath-vector2d.png new file mode 100644 index 00000000..d8856b12 Binary files /dev/null and b/docs/figures/saturation/merge/merge_error_vs_N__cms-heap-topk-fastpath-vector2d.png differ diff --git a/docs/figures/saturation/merge/merge_error_vs_N__countsketch-fastpath-vector2d.png b/docs/figures/saturation/merge/merge_error_vs_N__countsketch-fastpath-vector2d.png new file mode 100644 index 00000000..804652a0 Binary files /dev/null and b/docs/figures/saturation/merge/merge_error_vs_N__countsketch-fastpath-vector2d.png differ diff --git a/docs/figures/saturation/merge/merge_error_vs_N__dd.png b/docs/figures/saturation/merge/merge_error_vs_N__dd.png new file mode 100644 index 00000000..71f05bfc Binary files /dev/null and b/docs/figures/saturation/merge/merge_error_vs_N__dd.png differ diff --git a/docs/figures/saturation/merge/merge_error_vs_N__hll.png b/docs/figures/saturation/merge/merge_error_vs_N__hll.png new file mode 100644 index 00000000..fd63ac3c Binary files /dev/null and b/docs/figures/saturation/merge/merge_error_vs_N__hll.png differ diff --git a/docs/figures/saturation/merge/merge_error_vs_N__kll-percall.png b/docs/figures/saturation/merge/merge_error_vs_N__kll-percall.png new file mode 100644 index 00000000..9b61f97c Binary files /dev/null and b/docs/figures/saturation/merge/merge_error_vs_N__kll-percall.png differ diff --git a/docs/figures/saturation/merge/merge_ratio_at_nmax.png b/docs/figures/saturation/merge/merge_ratio_at_nmax.png new file mode 100644 index 00000000..bc7d6210 Binary files /dev/null and b/docs/figures/saturation/merge/merge_ratio_at_nmax.png differ diff --git a/docs/figures/saturation/merge_grid/README.md b/docs/figures/saturation/merge_grid/README.md new file mode 100644 index 00000000..7606b6a0 --- /dev/null +++ b/docs/figures/saturation/merge_grid/README.md @@ -0,0 +1,30 @@ +# Accuracy after merging: full top-k and KLL/DDSketch grids + +`--phase accuracy --merge-shards-list 1,4,16,64`, N up to 1e7: +- CMS-heap top-k: all 8 configs (cols 256–16384 x rows 3/5) x theta {0 … 2} x K {1e3, 1e5, 1e7}, 3 seeds; +- KLL k {50, 200, 800} and DDSketch alpha_dd {0.005, 0.01, 0.02, 0.05} x Pareto a {1.1, 1.5, 2, 3}, 10 seeds. + +Run on an otherwise idle machine (accuracy only). Plots by +`scripts/plot_saturation_merge.py`: one `merge_error_vs_N____.png` +per config (m = 1 is one sketch over all N items; m = 4/16/64 split the stream +into contiguous shards, sketch each, merge), and `merge_ratio_at_nmax.png` +(merged / single error at N = 1e7; precision for top-k, so < 1 is worse). + +`recommendations_with_merge.csv`: `scripts/recommend_config.py` rerun with these +merge curves (`--merge-curves`), so top-k and KLL recommendations use the error +at the query's shard count m = S / x instead of the single-sketch curve. + +Findings: +- **DDSketch**: merged error equals single-sketch error everywhere (ratio 1.000). +- **Top-k**: median merged/single precision is 1.00 for every config; losses + (down to 0.60) are concentrated at large K and mid-to-high theta, where a + globally heavy key can miss every shard's heap. Wider configs do not remove + them (cols 16384 still has points at 0.60–0.80). +- **KLL**: merged error is higher, and more so for larger k: median ratio at + N = 1e7 is ≈ 1.0–1.1 for k = 50 / 200 but 1.12–1.25 for k = 800 (up to 1.32). + At intermediate N (1e4–1e5) merged KLL error is up to 3–4x the single sketch + for k = 800 with m = 4, converging by 1e6–1e7. +- **Recommendations**: no row is flagged "single-sketch curve optimistic" any + more (43 before). Six changed, e.g. p99 latency over 5m windows now needs + KLL k = 200 instead of k = 50 to meet the 1% target after merging; top-k on + the near-uniform baselines (per-node / per-machine) meets no target. diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=1024.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=1024.png new file mode 100644 index 00000000..749a0a1e Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=1024.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=16384.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=16384.png new file mode 100644 index 00000000..9143537c Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=16384.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=256.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=256.png new file mode 100644 index 00000000..3baaca54 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=256.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=4096.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=4096.png new file mode 100644 index 00000000..4334b2aa Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=3_cols=4096.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=1024.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=1024.png new file mode 100644 index 00000000..c4018897 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=1024.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=16384.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=16384.png new file mode 100644 index 00000000..014a4433 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=16384.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=256.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=256.png new file mode 100644 index 00000000..e5f1ede0 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=256.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=4096.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=4096.png new file mode 100644 index 00000000..e867bdd6 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__cms-heap-topk-fastpath-vector2d__rows=5_cols=4096.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.005.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.005.png new file mode 100644 index 00000000..588b5d5b Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.005.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.01.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.01.png new file mode 100644 index 00000000..c43ab9b3 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.01.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.02.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.02.png new file mode 100644 index 00000000..eb62e49e Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.02.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.05.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.05.png new file mode 100644 index 00000000..455d3d21 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__dd__alpha=0.05.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=200.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=200.png new file mode 100644 index 00000000..c20a56ef Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=200.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=50.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=50.png new file mode 100644 index 00000000..cd05c299 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=50.png differ diff --git a/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=800.png b/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=800.png new file mode 100644 index 00000000..049f5bb6 Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_error_vs_N__kll-percall__k=800.png differ diff --git a/docs/figures/saturation/merge_grid/merge_ratio_at_nmax.png b/docs/figures/saturation/merge_grid/merge_ratio_at_nmax.png new file mode 100644 index 00000000..94583abb Binary files /dev/null and b/docs/figures/saturation/merge_grid/merge_ratio_at_nmax.png differ diff --git a/docs/figures/saturation/merge_grid/recommendations_with_merge.csv b/docs/figures/saturation/merge_grid/recommendations_with_merge.csv new file mode 100644 index 00000000..04c04034 --- /dev/null +++ b/docs/figures/saturation/merge_grid/recommendations_with_merge.csv @@ -0,0 +1,217 @@ +dataset,query_id,range,family,config,est_error,target,meets_target,n_sat,flags,memory_bytes,insert_ns_per_item,merge_us_per_fold,query_phase_us,grid_param,grid_K,N,shards +alibaba_v2022,mcr_by_msname,instant,cms,rows=3 cols=16384,0.020760829338153652,0.05,True,316228,,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,521344,1 +alibaba_v2022,mcr_by_msname,instant,countsketch,rows=3 cols=4096,0.04153682919157856,0.05,True,562341,not saturated at min_N,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,521344,1 +alibaba_v2022,mcr_by_msname,instant,topk,rows=5 cols=1024,0.9895833333333334,0.95,True,5623,cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,521344,1 +alibaba_v2022,mcr_by_msname,5m,cms,rows=3 cols=4096,0.044913144197755384,0.05,True,177828,extrapolated beyond N=1e+07,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,20040209,5 +alibaba_v2022,mcr_by_msname,5m,countsketch,rows=3 cols=4096,0.018155593895840188,0.05,True,316228,extrapolated beyond N=1e+07,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,20040209,5 +alibaba_v2022,mcr_by_msname,5m,topk,rows=3 cols=1024,0.96875,0.95,True,1778,merged curve at m=4; extrapolated beyond N=1e+07,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,20040209,5 +alibaba_v2022,mcr_by_msname,1h,cms,rows=3 cols=4096,0.044913144197755384,0.05,True,177828,extrapolated beyond N=1e+07,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,166100193,60 +alibaba_v2022,mcr_by_msname,1h,countsketch,rows=3 cols=4096,0.018155593895840188,0.05,True,316228,extrapolated beyond N=1e+07,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,166100193,60 +alibaba_v2022,mcr_by_msname,1h,topk,rows=3 cols=1024,0.96875,0.95,True,1778,merged curve at m=64; extrapolated beyond N=1e+07,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,166100193,60 +alibaba_v2022,mcr_by_nodeid,instant,cms,rows=5 cols=16384,1.1753430524102333,0.05,False,56234133,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,38.0,53.370370370370374,4237.222222222223,0.0,100000,521344,1 +alibaba_v2022,mcr_by_nodeid,instant,countsketch,rows=5 cols=16384,0.40686253508409664,0.05,False,1778279,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,44.283333333333324,48.85185185185186,8852.77777777778,0.0,100000,521344,1 +alibaba_v2022,mcr_by_nodeid,instant,topk,rows=3 cols=16384,0.01809371296620448,0.95,False,316228,target not met,196608.0,95.22756666666666,103.06666666666668,5.666666666666666,0.0,100000,521344,1 +alibaba_v2022,mcr_by_nodeid,5m,cms,rows=5 cols=16384,0.11674291755274485,0.05,False,316228,target not met; extrapolated beyond N=1e+07; cost scaled from rows=3,327680.0,37.69855555555556,52.296296296296305,4072.2222222222226,0.5,100000,20040209,5 +alibaba_v2022,mcr_by_nodeid,5m,countsketch,rows=5 cols=16384,0.048418503893649385,0.05,True,562341,extrapolated beyond N=1e+07; cost scaled from rows=3,327680.0,44.27855555555554,49.55555555555556,9004.444444444445,0.5,100000,20040209,5 +alibaba_v2022,mcr_by_nodeid,5m,topk,rows=3 cols=16384,0.9895833333333334,0.95,True,56234,merged curve at m=4; extrapolated beyond N=1e+07,196608.0,109.67483333333332,117.08888888888889,6.0,0.5,100000,20040209,5 +alibaba_v2022,mcr_by_nodeid,1h,cms,rows=5 cols=16384,0.11674291755274485,0.05,False,316228,target not met; extrapolated beyond N=1e+07; cost scaled from rows=3,327680.0,37.69855555555556,52.296296296296305,4072.2222222222226,0.5,100000,166100193,60 +alibaba_v2022,mcr_by_nodeid,1h,countsketch,rows=5 cols=16384,0.048418503893649385,0.05,True,562341,extrapolated beyond N=1e+07; cost scaled from rows=3,327680.0,44.27855555555554,49.55555555555556,9004.444444444445,0.5,100000,166100193,60 +alibaba_v2022,mcr_by_nodeid,1h,topk,rows=3 cols=16384,0.9895833333333334,0.95,True,56234,merged curve at m=64; extrapolated beyond N=1e+07,196608.0,109.67483333333332,117.08888888888889,6.0,0.5,100000,166100193,60 +alibaba_v2022,rt_p99_by_msname,instant,cms,rows=3 cols=16384,0.020760829338153652,0.05,True,316228,,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,521344,1 +alibaba_v2022,rt_p99_by_msname,instant,countsketch,rows=3 cols=4096,0.04153682919157856,0.05,True,562341,not saturated at min_N,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,521344,1 +alibaba_v2022,rt_p99_by_msname,instant,topk,rows=5 cols=1024,0.9895833333333334,0.95,True,5623,cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,521344,1 +alibaba_v2022,rt_p99_by_msname,5m,cms,rows=3 cols=4096,0.014887852077571267,0.05,True,316228,extrapolated beyond N=1e+07,49152.0,22.375566666666668,5.933333333333334,2157.9999999999995,1.2,100000,20040209,5 +alibaba_v2022,rt_p99_by_msname,5m,countsketch,rows=3 cols=1024,0.04947613038114032,0.05,True,100000,,12288.0,26.281399999999998,1.9555555555555557,4933.333333333334,1.2,100000,20040209,5 +alibaba_v2022,rt_p99_by_msname,5m,topk,rows=3 cols=1024,0.96875,0.95,True,1000,merged curve at m=4; extrapolated beyond N=1e+07,12288.0,1117.1077666666665,93.28888888888889,5.0,1.2,100000,20040209,5 +alibaba_v2022,rt_p99_by_msname,1h,cms,rows=3 cols=4096,0.014887852077571267,0.05,True,316228,extrapolated beyond N=1e+07,49152.0,22.375566666666668,5.933333333333334,2157.9999999999995,1.2,100000,166100193,60 +alibaba_v2022,rt_p99_by_msname,1h,countsketch,rows=3 cols=1024,0.0497436737693786,0.05,True,100000,,12288.0,26.281399999999998,1.9555555555555557,4933.333333333334,1.2,100000,166100193,60 +alibaba_v2022,rt_p99_by_msname,1h,topk,rows=3 cols=1024,0.96875,0.95,True,1000,merged curve at m=64; extrapolated beyond N=1e+07,12288.0,1117.1077666666665,93.28888888888889,5.0,1.2,100000,166100193,60 +alibaba_v2022,rt_p99_by_msname,instant,kll,k=200,0.002470041815777119,0.01,True,not_saturated,not saturated,6400.0,25.645400000000002,5.177777777777778,3240.9999999999995,3.0,,401372,1 +alibaba_v2022,rt_p99_by_msname,instant,dd,alpha=0.01,0.007332698267151987,0.01,True,1000,,3464.0,15.694700000000001,1.1333333333333333,2008.3333333333333,3.0,,401372,1 +alibaba_v2022,rt_p99_by_msname,5m,kll,k=200,0.0026306807920792085,0.01,True,not_saturated,"alpha 12.6717 beyond grid, used 3; merged curve at m=4; extrapolated beyond N=1e+07; not saturated",6400.0,25.645400000000002,5.177777777777778,3240.9999999999995,3.0,,18912878,5 +alibaba_v2022,rt_p99_by_msname,5m,dd,alpha=0.01,0.007349054272741779,0.01,True,1000,"alpha 12.6717 beyond grid, used 3",3464.0,15.694700000000001,1.1333333333333333,2008.3333333333333,3.0,,18912878,5 +alibaba_v2022,rt_p99_by_msname,1h,kll,k=200,0.0027761531683168313,0.01,True,not_saturated,"alpha 9.27532 beyond grid, used 3; merged curve at m=64; extrapolated beyond N=1e+07; not saturated",6400.0,25.645400000000002,5.177777777777778,3240.9999999999995,3.0,,152748684,60 +alibaba_v2022,rt_p99_by_msname,1h,dd,alpha=0.01,0.007350253064515069,0.01,True,1000,"alpha 9.27532 beyond grid, used 3",3464.0,15.694700000000001,1.1333333333333333,2008.3333333333333,3.0,,152748684,60 +alibaba_v2022,calls_by_rpctype,1m,cms,rows=3 cols=1024,0.012068843865983931,0.05,True,5623,not saturated at min_N,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,5401423,1 +alibaba_v2022,calls_by_rpctype,1m,countsketch,rows=3 cols=1024,0.040474453524032145,0.05,True,1000,not saturated at min_N,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,5401423,1 +alibaba_v2022,calls_by_rpctype,1m,topk,rows=5 cols=256,0.96875,0.95,True,1000,not saturated at min_N; cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,5401423,1 +alibaba_v2022,calls_by_rpctype,5m,cms,rows=3 cols=1024,0.012062400730156707,0.05,True,5623,,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,26594881,5 +alibaba_v2022,calls_by_rpctype,5m,countsketch,rows=3 cols=1024,0.040519028976739355,0.05,True,1000,,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,26594881,5 +alibaba_v2022,calls_by_rpctype,5m,topk,rows=5 cols=256,0.96875,0.95,True,1000,merged curve at m=4; extrapolated beyond N=1e+07; cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,26594881,5 +alibaba_v2022,calls_by_rpctype,1h,cms,rows=3 cols=1024,0.012054748429688853,0.05,True,5623,,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,260437245,60 +alibaba_v2022,calls_by_rpctype,1h,countsketch,rows=3 cols=1024,0.04039436310787848,0.05,True,1000,,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,260437245,60 +alibaba_v2022,calls_by_rpctype,1h,topk,rows=5 cols=256,0.96875,0.95,True,1000,merged curve at m=64; extrapolated beyond N=1e+07; cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,260437245,60 +alibaba_v2022,calls_by_service,1m,cms,rows=3 cols=16384,0.02129176204509065,0.05,True,316228,not saturated at min_N,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,5401423,1 +alibaba_v2022,calls_by_service,1m,countsketch,rows=3 cols=4096,0.03928169571169596,0.05,True,562341,not saturated at min_N,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,5401423,1 +alibaba_v2022,calls_by_service,1m,topk,rows=5 cols=1024,0.9895833333333334,0.95,True,5623,not saturated at min_N; cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,5401423,1 +alibaba_v2022,calls_by_service,5m,cms,rows=3 cols=16384,0.019873590686755222,0.05,True,562341,extrapolated beyond N=1e+07,196608.0,22.537133333333333,30.955555555555556,56817.33333333332,1.0,10000000,26594881,5 +alibaba_v2022,calls_by_service,5m,countsketch,rows=3 cols=4096,0.01832341853528574,0.05,True,1000000,extrapolated beyond N=1e+07,49152.0,26.381099999999996,6.355555555555556,111033.66666666667,1.0,10000000,26594881,5 +alibaba_v2022,calls_by_service,5m,topk,rows=5 cols=1024,1.0,0.95,True,1778,merged curve at m=4; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,796.0973888888889,137.33333333333331,929.9999999999999,1.0,10000000,26594881,5 +alibaba_v2022,calls_by_service,1h,cms,rows=3 cols=16384,0.019873590686755222,0.05,True,562341,extrapolated beyond N=1e+07,196608.0,22.537133333333333,30.955555555555556,56817.33333333332,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_service,1h,countsketch,rows=3 cols=4096,0.01832341853528574,0.05,True,1000000,extrapolated beyond N=1e+07,49152.0,26.381099999999996,6.355555555555556,111033.66666666667,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_service,1h,topk,rows=5 cols=1024,1.0,0.95,True,1778,merged curve at m=64; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,796.0973888888889,137.33333333333331,929.9999999999999,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_um,1m,cms,rows=3 cols=4096,0.04470475707962842,0.05,True,177828,not saturated at min_N,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,5401423,1 +alibaba_v2022,calls_by_um,1m,countsketch,rows=3 cols=4096,0.0182543247070165,0.05,True,316228,not saturated at min_N,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,5401423,1 +alibaba_v2022,calls_by_um,1m,topk,rows=3 cols=1024,0.96875,0.95,True,1778,not saturated at min_N,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,5401423,1 +alibaba_v2022,calls_by_um,5m,cms,rows=3 cols=4096,0.044913144197755384,0.05,True,177828,extrapolated beyond N=1e+07,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,26594881,5 +alibaba_v2022,calls_by_um,5m,countsketch,rows=3 cols=4096,0.018155593895840188,0.05,True,316228,extrapolated beyond N=1e+07,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,26594881,5 +alibaba_v2022,calls_by_um,5m,topk,rows=3 cols=1024,0.96875,0.95,True,1778,merged curve at m=4; extrapolated beyond N=1e+07,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,26594881,5 +alibaba_v2022,calls_by_um,1h,cms,rows=3 cols=4096,0.044913144197755384,0.05,True,177828,extrapolated beyond N=1e+07,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,260437245,60 +alibaba_v2022,calls_by_um,1h,countsketch,rows=3 cols=4096,0.018155593895840188,0.05,True,316228,extrapolated beyond N=1e+07,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,260437245,60 +alibaba_v2022,calls_by_um,1h,topk,rows=3 cols=1024,0.96875,0.95,True,1778,merged curve at m=64; extrapolated beyond N=1e+07,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,260437245,60 +alibaba_v2022,calls_by_dm,1m,cms,rows=3 cols=4096,0.04470475707962842,0.05,True,177828,not saturated at min_N,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,5401423,1 +alibaba_v2022,calls_by_dm,1m,countsketch,rows=3 cols=4096,0.0182543247070165,0.05,True,316228,not saturated at min_N,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,5401423,1 +alibaba_v2022,calls_by_dm,1m,topk,rows=3 cols=1024,0.96875,0.95,True,1778,not saturated at min_N,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,5401423,1 +alibaba_v2022,calls_by_dm,5m,cms,rows=3 cols=4096,0.044913144197755384,0.05,True,177828,extrapolated beyond N=1e+07,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,26594881,5 +alibaba_v2022,calls_by_dm,5m,countsketch,rows=3 cols=4096,0.018155593895840188,0.05,True,316228,extrapolated beyond N=1e+07,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,26594881,5 +alibaba_v2022,calls_by_dm,5m,topk,rows=3 cols=1024,0.96875,0.95,True,1778,merged curve at m=4; extrapolated beyond N=1e+07,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,26594881,5 +alibaba_v2022,calls_by_dm,1h,cms,rows=3 cols=4096,0.044913144197755384,0.05,True,177828,extrapolated beyond N=1e+07,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,260437245,60 +alibaba_v2022,calls_by_dm,1h,countsketch,rows=3 cols=4096,0.018155593895840188,0.05,True,316228,extrapolated beyond N=1e+07,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,260437245,60 +alibaba_v2022,calls_by_dm,1h,topk,rows=3 cols=1024,0.96875,0.95,True,1778,merged curve at m=64; extrapolated beyond N=1e+07,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,260437245,60 +alibaba_v2022,calls_by_interface,1m,cms,rows=5 cols=16384,0.11852205026294958,0.05,False,1000000,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,37.68633333333333,51.18518518518519,187872.7777777778,0.8,10000000,5401423,1 +alibaba_v2022,calls_by_interface,1m,countsketch,rows=3 cols=4096,0.042239557359247955,0.05,True,5623413,not saturated at min_N,49152.0,26.516266666666667,6.133333333333334,220461.0,0.8,10000000,5401423,1 +alibaba_v2022,calls_by_interface,1m,topk,rows=5 cols=1024,0.9873968588599285,0.95,True,31623,not saturated at min_N; cost scaled from rows=3,20480.0,263.90122222222226,133.85185185185185,2103.888888888889,0.8,10000000,5401423,1 +alibaba_v2022,calls_by_interface,5m,cms,rows=3 cols=16384,0.019873590686755222,0.05,True,562341,extrapolated beyond N=1e+07,196608.0,22.537133333333333,30.955555555555556,56817.33333333332,1.0,10000000,26594881,5 +alibaba_v2022,calls_by_interface,5m,countsketch,rows=3 cols=4096,0.01832341853528574,0.05,True,1000000,extrapolated beyond N=1e+07,49152.0,26.381099999999996,6.355555555555556,111033.66666666667,1.0,10000000,26594881,5 +alibaba_v2022,calls_by_interface,5m,topk,rows=5 cols=1024,1.0,0.95,True,1778,merged curve at m=4; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,796.0973888888889,137.33333333333331,929.9999999999999,1.0,10000000,26594881,5 +alibaba_v2022,calls_by_interface,1h,cms,rows=3 cols=16384,0.019873590686755222,0.05,True,562341,extrapolated beyond N=1e+07,196608.0,22.537133333333333,30.955555555555556,56817.33333333332,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_interface,1h,countsketch,rows=3 cols=4096,0.01832341853528574,0.05,True,1000000,extrapolated beyond N=1e+07,49152.0,26.381099999999996,6.355555555555556,111033.66666666667,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_interface,1h,topk,rows=5 cols=1024,1.0,0.95,True,1778,merged curve at m=64; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,796.0973888888889,137.33333333333331,929.9999999999999,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_um_dm,1m,cms,rows=3 cols=16384,0.02129176204509065,0.05,True,316228,not saturated at min_N,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,5401423,1 +alibaba_v2022,calls_by_um_dm,1m,countsketch,rows=3 cols=4096,0.03928169571169596,0.05,True,562341,not saturated at min_N,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,5401423,1 +alibaba_v2022,calls_by_um_dm,1m,topk,rows=5 cols=1024,0.9895833333333334,0.95,True,5623,not saturated at min_N; cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,5401423,1 +alibaba_v2022,calls_by_um_dm,5m,cms,rows=3 cols=16384,0.0213003939726821,0.05,True,316228,extrapolated beyond N=1e+07,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,26594881,5 +alibaba_v2022,calls_by_um_dm,5m,countsketch,rows=3 cols=4096,0.03841192871816221,0.05,True,562341,extrapolated beyond N=1e+07,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,26594881,5 +alibaba_v2022,calls_by_um_dm,5m,topk,rows=5 cols=1024,1.0,0.95,True,5623,merged curve at m=4; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,26594881,5 +alibaba_v2022,calls_by_um_dm,1h,cms,rows=3 cols=16384,0.019873590686755222,0.05,True,562341,extrapolated beyond N=1e+07,196608.0,22.537133333333333,30.955555555555556,56817.33333333332,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_um_dm,1h,countsketch,rows=3 cols=4096,0.01832341853528574,0.05,True,1000000,extrapolated beyond N=1e+07,49152.0,26.381099999999996,6.355555555555556,111033.66666666667,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_um_dm,1h,topk,rows=5 cols=1024,1.0,0.95,True,1778,merged curve at m=64; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,796.0973888888889,137.33333333333331,929.9999999999999,1.0,10000000,260437245,60 +alibaba_v2022,calls_by_service_um_dm,1m,cms,rows=5 cols=16384,0.11852205026294958,0.05,False,1000000,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,37.68633333333333,51.18518518518519,187872.7777777778,0.8,10000000,5401423,1 +alibaba_v2022,calls_by_service_um_dm,1m,countsketch,rows=3 cols=4096,0.042239557359247955,0.05,True,5623413,not saturated at min_N,49152.0,26.516266666666667,6.133333333333334,220461.0,0.8,10000000,5401423,1 +alibaba_v2022,calls_by_service_um_dm,1m,topk,rows=5 cols=1024,0.9873968588599285,0.95,True,31623,not saturated at min_N; cost scaled from rows=3,20480.0,263.90122222222226,133.85185185185185,2103.888888888889,0.8,10000000,5401423,1 +alibaba_v2022,calls_by_service_um_dm,5m,cms,rows=5 cols=16384,0.11895150520544058,0.05,False,1000000,target not met; extrapolated beyond N=1e+07; cost scaled from rows=3,327680.0,37.68633333333333,51.18518518518519,187872.7777777778,0.8,10000000,26594881,5 +alibaba_v2022,calls_by_service_um_dm,5m,countsketch,rows=3 cols=4096,0.03865929186904125,0.05,True,5623413,,49152.0,26.516266666666667,6.133333333333334,220461.0,0.8,10000000,26594881,5 +alibaba_v2022,calls_by_service_um_dm,5m,topk,rows=5 cols=1024,0.9791666666666666,0.95,True,31623,merged curve at m=4; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,263.90122222222226,133.85185185185185,2103.888888888889,0.8,10000000,26594881,5 +alibaba_v2022,calls_by_service_um_dm,1h,cms,rows=5 cols=16384,0.11895150520544058,0.05,False,1000000,target not met; extrapolated beyond N=1e+07; cost scaled from rows=3,327680.0,37.68633333333333,51.18518518518519,187872.7777777778,0.8,10000000,260437245,60 +alibaba_v2022,calls_by_service_um_dm,1h,countsketch,rows=3 cols=4096,0.03830386459325624,0.05,True,5623413,,49152.0,26.516266666666667,6.133333333333334,220461.0,0.8,10000000,260437245,60 +alibaba_v2022,calls_by_service_um_dm,1h,topk,rows=5 cols=1024,0.9791666666666666,0.95,True,31623,merged curve at m=64; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,263.90122222222226,133.85185185185185,2103.888888888889,0.8,10000000,260437245,60 +alibaba_v2022,rt_p99_by_service,1m,cms,rows=3 cols=16384,0.02129176204509065,0.05,True,316228,not saturated at min_N,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,5401423,1 +alibaba_v2022,rt_p99_by_service,1m,countsketch,rows=3 cols=4096,0.03928169571169596,0.05,True,562341,not saturated at min_N,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,5401423,1 +alibaba_v2022,rt_p99_by_service,1m,topk,rows=5 cols=1024,0.9895833333333334,0.95,True,5623,not saturated at min_N; cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,5401423,1 +alibaba_v2022,rt_p99_by_service,5m,cms,rows=3 cols=16384,0.019873590686755222,0.05,True,562341,extrapolated beyond N=1e+07,196608.0,22.537133333333333,30.955555555555556,56817.33333333332,1.0,10000000,26594881,5 +alibaba_v2022,rt_p99_by_service,5m,countsketch,rows=3 cols=4096,0.01832341853528574,0.05,True,1000000,extrapolated beyond N=1e+07,49152.0,26.381099999999996,6.355555555555556,111033.66666666667,1.0,10000000,26594881,5 +alibaba_v2022,rt_p99_by_service,5m,topk,rows=5 cols=1024,1.0,0.95,True,1778,merged curve at m=4; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,796.0973888888889,137.33333333333331,929.9999999999999,1.0,10000000,26594881,5 +alibaba_v2022,rt_p99_by_service,1h,cms,rows=3 cols=16384,0.019873590686755222,0.05,True,562341,extrapolated beyond N=1e+07,196608.0,22.537133333333333,30.955555555555556,56817.33333333332,1.0,10000000,260437245,60 +alibaba_v2022,rt_p99_by_service,1h,countsketch,rows=3 cols=4096,0.01832341853528574,0.05,True,1000000,extrapolated beyond N=1e+07,49152.0,26.381099999999996,6.355555555555556,111033.66666666667,1.0,10000000,260437245,60 +alibaba_v2022,rt_p99_by_service,1h,topk,rows=5 cols=1024,1.0,0.95,True,1778,merged curve at m=64; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,796.0973888888889,137.33333333333331,929.9999999999999,1.0,10000000,260437245,60 +alibaba_v2022,rt_p99_by_service,1m,kll,k=200,0.0023037840370404346,0.01,True,not_saturated,not saturated,6400.0,25.268599999999996,5.3999999999999995,2951.9999999999995,3.0,,3311360,1 +alibaba_v2022,rt_p99_by_service,1m,dd,alpha=0.01,0.007346637486156435,0.01,True,1000,not saturated at min_N,4616.0,15.611766666666668,1.266666666666667,1987.333333333333,3.0,,3311360,1 +alibaba_v2022,rt_p99_by_service,5m,kll,k=200,0.0026306807920792085,0.01,True,not_saturated,merged curve at m=4; extrapolated beyond N=1e+07; not saturated,6400.0,25.268599999999996,5.3999999999999995,2951.9999999999995,3.0,,16264263,5 +alibaba_v2022,rt_p99_by_service,5m,dd,alpha=0.01,0.007349125190843246,0.01,True,1000,,4616.0,15.611766666666668,1.266666666666667,1987.333333333333,3.0,,16264263,5 +alibaba_v2022,rt_p99_by_service,1h,kll,k=200,0.0027761531683168313,0.01,True,not_saturated,merged curve at m=64; extrapolated beyond N=1e+07; not saturated,6400.0,25.645400000000002,5.177777777777778,3240.9999999999995,3.0,,157226182,60 +alibaba_v2022,rt_p99_by_service,1h,dd,alpha=0.01,0.00735024368490511,0.01,True,1000,,3464.0,15.694700000000001,1.1333333333333333,2008.3333333333333,3.0,,157226182,60 +alibaba_v2022,ms_cpu_by_msname,instant,cms,rows=3 cols=16384,0.020573849606818375,0.05,True,316228,,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,471603,1 +alibaba_v2022,ms_cpu_by_msname,instant,countsketch,rows=3 cols=4096,0.04190031679674842,0.05,True,562341,not saturated at min_N,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,471603,1 +alibaba_v2022,ms_cpu_by_msname,instant,topk,rows=5 cols=1024,0.9895833333333334,0.95,True,5623,cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,471603,1 +alibaba_v2022,ms_cpu_by_msname,5m,cms,rows=3 cols=16384,0.021473512975033845,0.05,True,316228,,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,2355461,5 +alibaba_v2022,ms_cpu_by_msname,5m,countsketch,rows=3 cols=4096,0.0398659549922401,0.05,True,562341,,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,2355461,5 +alibaba_v2022,ms_cpu_by_msname,5m,topk,rows=5 cols=1024,0.9895833333333334,0.95,True,5623,merged curve at m=4; cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,2355461,5 +alibaba_v2022,ms_cpu_by_msname,1h,cms,rows=3 cols=16384,0.0213003939726821,0.05,True,316228,extrapolated beyond N=1e+07,196608.0,22.54083333333333,28.933333333333334,2420.0,0.8,100000,28254558,60 +alibaba_v2022,ms_cpu_by_msname,1h,countsketch,rows=3 cols=4096,0.03841192871816221,0.05,True,562341,extrapolated beyond N=1e+07,49152.0,26.3713,5.977777777777778,5111.666666666666,0.8,100000,28254558,60 +alibaba_v2022,ms_cpu_by_msname,1h,topk,rows=5 cols=1024,1.0,0.95,True,5623,merged curve at m=64; extrapolated beyond N=1e+07; cost scaled from rows=3,20480.0,482.89444444444445,152.5555555555556,8.333333333333334,0.8,100000,28254558,60 +alibaba_v2022,ms_cpu_p99,instant,kll,k=200,0.0026133499468463093,0.01,True,not_saturated,"alpha 10.154 beyond grid, used 3; light tail; not saturated",6400.0,25.402400000000004,5.2,2999.3333333333335,3.0,,471589,1 +alibaba_v2022,ms_cpu_p99,instant,dd,alpha=0.01,0.007332013494612215,0.01,True,1000,"alpha 10.154 beyond grid, used 3; light tail",2312.0,15.584666666666665,0.8222222222222221,1965.3333333333333,3.0,,471589,1 +alibaba_v2022,ms_cpu_p99,5m,kll,k=200,0.0024900391828192926,0.01,True,not_saturated,"alpha 10.0475 beyond grid, used 3; light tail; merged curve at m=4; not saturated",6400.0,25.402400000000004,5.2,2999.3333333333335,3.0,,2355395,5 +alibaba_v2022,ms_cpu_p99,5m,dd,alpha=0.01,0.007347637516570892,0.01,True,1000,"alpha 10.0475 beyond grid, used 3; light tail",2312.0,15.584666666666665,0.8222222222222221,1965.3333333333333,3.0,,2355395,5 +alibaba_v2022,ms_cpu_p99,1h,kll,k=200,0.0027761531683168313,0.01,True,not_saturated,"alpha 7.05221 beyond grid, used 3; light tail; merged curve at m=64; extrapolated beyond N=1e+07; not saturated",6400.0,25.402400000000004,5.2,2999.3333333333335,3.0,,28253774,60 +alibaba_v2022,ms_cpu_p99,1h,dd,alpha=0.01,0.0073488612347692535,0.01,True,1000,"alpha 7.05221 beyond grid, used 3; light tail",2312.0,15.584666666666665,0.8222222222222221,1965.3333333333333,3.0,,28253774,60 +alibaba_v2022,node_cpu_by_nodeid,instant,cms,rows=5 cols=16384,0.19044825832269802,0.05,False,56234133,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,38.0,53.370370370370374,4237.222222222223,0.0,100000,42957,1 +alibaba_v2022,node_cpu_by_nodeid,instant,countsketch,rows=5 cols=16384,0.16009119472655217,0.05,False,1778279,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,44.283333333333324,48.85185185185186,8852.77777777778,0.0,100000,42957,1 +alibaba_v2022,node_cpu_by_nodeid,instant,topk,rows=5 cols=16384,0.33705578919226736,0.95,False,316228,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,158.7126111111111,171.7777777777778,9.444444444444445,0.0,100000,42957,1 +alibaba_v2022,node_cpu_by_nodeid,5m,cms,rows=5 cols=16384,0.7626094093044472,0.05,False,56234133,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,38.0,53.370370370370374,4237.222222222223,0.0,100000,214454,5 +alibaba_v2022,node_cpu_by_nodeid,5m,countsketch,rows=5 cols=16384,0.3023531933877328,0.05,False,1778279,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,44.283333333333324,48.85185185185186,8852.77777777778,0.0,100000,214454,5 +alibaba_v2022,node_cpu_by_nodeid,5m,topk,rows=5 cols=16384,0.08722209388155265,0.95,False,316228,target not met; merged curve at m=4; not saturated at min_N; cost scaled from rows=3,327680.0,158.7126111111111,171.7777777777778,9.444444444444445,0.0,100000,214454,5 +alibaba_v2022,node_cpu_by_nodeid,1h,cms,rows=5 cols=16384,1.9636232471285444,0.05,False,56234133,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,38.0,53.370370370370374,4237.222222222223,0.0,100000,2570715,60 +alibaba_v2022,node_cpu_by_nodeid,1h,countsketch,rows=5 cols=16384,0.5820675430071887,0.05,False,1778279,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,44.283333333333324,48.85185185185186,8852.77777777778,0.0,100000,2570715,60 +alibaba_v2022,node_cpu_by_nodeid,1h,topk,rows=5 cols=16384,0.01791217185042459,0.95,False,316228,target not met; merged curve at m=64; not saturated at min_N; cost scaled from rows=3,327680.0,158.7126111111111,171.7777777777778,9.444444444444445,0.0,100000,2570715,60 +alibaba_v2022,node_cpu_p99,instant,kll,k=50,0.009710050811872485,0.01,True,not_saturated,"alpha 6.44342 beyond grid, used 3; not saturated",1600.0,25.304666666666662,2.3111111111111113,2280.6666666666665,3.0,,42955,1 +alibaba_v2022,node_cpu_p99,instant,dd,alpha=0.01,0.0073115486162062615,0.01,True,1000,"alpha 6.44342 beyond grid, used 3",2312.0,15.584666666666665,0.8222222222222221,1965.3333333333333,3.0,,42955,1 +alibaba_v2022,node_cpu_p99,5m,kll,k=200,0.0025997407106098246,0.01,True,not_saturated,"alpha 6.36875 beyond grid, used 3; merged curve at m=4; not saturated",6400.0,25.402400000000004,5.2,2999.3333333333335,3.0,,214444,5 +alibaba_v2022,node_cpu_p99,5m,dd,alpha=0.01,0.007342681163634055,0.01,True,1000,"alpha 6.36875 beyond grid, used 3",2312.0,15.584666666666665,0.8222222222222221,1965.3333333333333,3.0,,214444,5 +alibaba_v2022,node_cpu_p99,1h,kll,k=200,0.0028767816662831065,0.01,True,not_saturated,"alpha 6.24654 beyond grid, used 3; merged curve at m=64; not saturated",6400.0,25.402400000000004,5.2,2999.3333333333335,3.0,,2570595,60 +alibaba_v2022,node_cpu_p99,1h,dd,alpha=0.01,0.0073472721923670626,0.01,True,1000,"alpha 6.24654 beyond grid, used 3",2312.0,15.584666666666665,0.8222222222222221,1965.3333333333333,3.0,,2570595,60 +google_2011,cpu_by_user,instant,cms,rows=3 cols=1024,0.02010047453674985,0.05,True,17783,,12288.0,22.3986,1.9333333333333336,28.333333333333336,1.0,1000,212533,1 +google_2011,cpu_by_user,instant,countsketch,rows=5 cols=1024,0.03100871637085652,0.05,True,17783,cost scaled from rows=3,20480.0,43.67538888888889,3.111111111111111,93.88888888888889,1.0,1000,212533,1 +google_2011,cpu_by_user,instant,topk,rows=5 cols=256,0.9719760905645167,0.95,True,1000,cost scaled from rows=3,5120.0,1692.064388888889,153.33333333333337,8.888888888888888,1.0,1000,212533,1 +google_2011,cpu_by_user,5m,cms,rows=3 cols=1024,0.020121154813470713,0.05,True,17783,,12288.0,22.3986,1.9333333333333336,28.333333333333336,1.0,1000,379702,1 +google_2011,cpu_by_user,5m,countsketch,rows=5 cols=1024,0.031219370129271302,0.05,True,17783,cost scaled from rows=3,20480.0,43.67538888888889,3.111111111111111,93.88888888888889,1.0,1000,379702,1 +google_2011,cpu_by_user,5m,topk,rows=5 cols=256,0.9758565522801315,0.95,True,1000,cost scaled from rows=3,5120.0,1692.064388888889,153.33333333333337,8.888888888888888,1.0,1000,379702,1 +google_2011,cpu_by_user,1h,cms,rows=3 cols=1024,0.019373032639913173,0.05,True,17783,,12288.0,22.3986,1.9333333333333336,28.333333333333336,1.0,1000,4179680,12 +google_2011,cpu_by_user,1h,countsketch,rows=5 cols=1024,0.030256153260673116,0.05,True,17783,cost scaled from rows=3,20480.0,43.67538888888889,3.111111111111111,93.88888888888889,1.0,1000,4179680,12 +google_2011,cpu_by_user,1h,topk,rows=5 cols=256,0.96875,0.95,True,1000,merged curve at m=16; cost scaled from rows=3,5120.0,1692.064388888889,153.33333333333337,8.888888888888888,1.0,1000,4179680,12 +google_2011,cpu_by_user_priority,instant,cms,rows=3 cols=1024,0.01169498334419633,0.05,True,5623,,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,212533,1 +google_2011,cpu_by_user_priority,instant,countsketch,rows=3 cols=1024,0.03829416534185969,0.05,True,1000,,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,212533,1 +google_2011,cpu_by_user_priority,instant,topk,rows=5 cols=256,0.96875,0.95,True,1000,cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,212533,1 +google_2011,cpu_by_user_priority,5m,cms,rows=3 cols=1024,0.012121078260562697,0.05,True,5623,,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,379702,1 +google_2011,cpu_by_user_priority,5m,countsketch,rows=3 cols=1024,0.039443381165268285,0.05,True,1000,,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,379702,1 +google_2011,cpu_by_user_priority,5m,topk,rows=5 cols=256,0.96875,0.95,True,1000,cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,379702,1 +google_2011,cpu_by_user_priority,1h,cms,rows=3 cols=1024,0.012067113093819451,0.05,True,5623,,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,4179680,12 +google_2011,cpu_by_user_priority,1h,countsketch,rows=3 cols=1024,0.0402749337344935,0.05,True,1000,,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,4179680,12 +google_2011,cpu_by_user_priority,1h,topk,rows=5 cols=256,0.96875,0.95,True,1000,merged curve at m=16; cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,4179680,12 +google_2011,cpu_by_priority,instant,cms,rows=3 cols=1024,0.01169498334419633,0.05,True,5623,,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,212533,1 +google_2011,cpu_by_priority,instant,countsketch,rows=3 cols=1024,0.03829416534185969,0.05,True,1000,,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,212533,1 +google_2011,cpu_by_priority,instant,topk,rows=5 cols=256,0.96875,0.95,True,1000,cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,212533,1 +google_2011,cpu_by_priority,5m,cms,rows=3 cols=1024,0.012121078260562697,0.05,True,5623,,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,379702,1 +google_2011,cpu_by_priority,5m,countsketch,rows=3 cols=1024,0.039443381165268285,0.05,True,1000,,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,379702,1 +google_2011,cpu_by_priority,5m,topk,rows=5 cols=256,0.96875,0.95,True,1000,cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,379702,1 +google_2011,cpu_by_priority,1h,cms,rows=3 cols=1024,0.012067113093819451,0.05,True,5623,,12288.0,22.423800000000004,1.9333333333333336,29.666666666666668,1.2,1000,4179680,12 +google_2011,cpu_by_priority,1h,countsketch,rows=3 cols=1024,0.0402749337344935,0.05,True,1000,,12288.0,26.283633333333334,2.0444444444444443,58.333333333333336,1.2,1000,4179680,12 +google_2011,cpu_by_priority,1h,topk,rows=5 cols=256,0.96875,0.95,True,1000,merged curve at m=16; cost scaled from rows=3,5120.0,2160.7369444444444,152.29629629629633,8.333333333333334,1.2,1000,4179680,12 +google_2011,cpu_by_job_id,instant,cms,rows=3 cols=4096,0.04232304463607425,0.05,True,177828,not saturated at min_N,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,212533,1 +google_2011,cpu_by_job_id,instant,countsketch,rows=3 cols=4096,0.020720519823678972,0.05,True,316228,not saturated at min_N,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,212533,1 +google_2011,cpu_by_job_id,instant,topk,rows=3 cols=1024,0.9583333333333334,0.95,True,1778,,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,212533,1 +google_2011,cpu_by_job_id,5m,cms,rows=3 cols=4096,0.04301674918691996,0.05,True,177828,not saturated at min_N,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,379702,1 +google_2011,cpu_by_job_id,5m,countsketch,rows=3 cols=4096,0.019333083136004733,0.05,True,316228,not saturated at min_N,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,379702,1 +google_2011,cpu_by_job_id,5m,topk,rows=3 cols=1024,0.9616434477198685,0.95,True,1778,,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,379702,1 +google_2011,cpu_by_job_id,1h,cms,rows=3 cols=4096,0.04488667446961157,0.05,True,177828,,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,4179680,12 +google_2011,cpu_by_job_id,1h,countsketch,rows=3 cols=4096,0.018399250683173572,0.05,True,316228,,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,4179680,12 +google_2011,cpu_by_job_id,1h,topk,rows=3 cols=1024,0.96875,0.95,True,1778,merged curve at m=16,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,4179680,12 +google_2011,cpu_by_logical_job_name,instant,cms,rows=3 cols=4096,0.04232304463607425,0.05,True,177828,not saturated at min_N,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,212533,1 +google_2011,cpu_by_logical_job_name,instant,countsketch,rows=3 cols=4096,0.020720519823678972,0.05,True,316228,not saturated at min_N,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,212533,1 +google_2011,cpu_by_logical_job_name,instant,topk,rows=3 cols=1024,0.9583333333333334,0.95,True,1778,,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,212533,1 +google_2011,cpu_by_logical_job_name,5m,cms,rows=3 cols=4096,0.04301674918691996,0.05,True,177828,not saturated at min_N,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,379702,1 +google_2011,cpu_by_logical_job_name,5m,countsketch,rows=3 cols=4096,0.019333083136004733,0.05,True,316228,not saturated at min_N,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,379702,1 +google_2011,cpu_by_logical_job_name,5m,topk,rows=3 cols=1024,0.9616434477198685,0.95,True,1778,,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,379702,1 +google_2011,cpu_by_logical_job_name,1h,cms,rows=3 cols=4096,0.04488667446961157,0.05,True,177828,,49152.0,22.33483333333333,5.977777777777778,2233.0,1.0,100000,4179680,12 +google_2011,cpu_by_logical_job_name,1h,countsketch,rows=3 cols=4096,0.018399250683173572,0.05,True,316228,,49152.0,26.39866666666667,6.177777777777778,5108.333333333334,1.0,100000,4179680,12 +google_2011,cpu_by_logical_job_name,1h,topk,rows=3 cols=1024,0.96875,0.95,True,1778,merged curve at m=16,12288.0,660.1273666666667,94.97777777777777,5.333333333333333,1.0,100000,4179680,12 +google_2011,cpu_by_scheduling_class,instant,cms,rows=3 cols=4096,0.016760841459045682,0.05,True,1000000,not saturated at min_N,49152.0,22.33646666666667,6.177777777777778,39.666666666666664,0.0,1000,212533,1 +google_2011,cpu_by_scheduling_class,instant,countsketch,rows=5 cols=4096,0.028718639298722665,0.05,True,562341,not saturated at min_N; cost scaled from rows=3,81920.0,43.976777777777784,10.185185185185185,117.77777777777779,0.0,1000,212533,1 +google_2011,cpu_by_scheduling_class,instant,topk,rows=5 cols=4096,0.9655239094354833,0.95,True,5623,cost scaled from rows=3,81920.0,231.64333333333335,122.81481481481482,8.888888888888888,0.0,1000,212533,1 +google_2011,cpu_by_scheduling_class,5m,cms,rows=3 cols=4096,0.013143994005858778,0.05,True,1000000,not saturated at min_N,49152.0,22.33646666666667,6.177777777777778,39.666666666666664,0.0,1000,379702,1 +google_2011,cpu_by_scheduling_class,5m,countsketch,rows=5 cols=4096,0.02563823434458546,0.05,True,562341,not saturated at min_N; cost scaled from rows=3,81920.0,43.976777777777784,10.185185185185185,117.77777777777779,0.0,1000,379702,1 +google_2011,cpu_by_scheduling_class,5m,topk,rows=5 cols=4096,0.971573790879474,0.95,True,5623,cost scaled from rows=3,81920.0,231.64333333333335,122.81481481481482,8.888888888888888,0.0,1000,379702,1 +google_2011,cpu_by_scheduling_class,1h,cms,rows=3 cols=4096,0.013026943752789035,0.05,True,1000000,,49152.0,22.33646666666667,6.177777777777778,39.666666666666664,0.0,1000,4179680,12 +google_2011,cpu_by_scheduling_class,1h,countsketch,rows=5 cols=4096,0.017628240253642864,0.05,True,562341,cost scaled from rows=3,81920.0,43.976777777777784,10.185185185185185,117.77777777777779,0.0,1000,4179680,12 +google_2011,cpu_by_scheduling_class,1h,topk,rows=5 cols=4096,0.6729999529522663,0.95,False,5623,target not met; merged curve at m=16; cost scaled from rows=3,81920.0,231.64333333333335,122.81481481481482,8.888888888888888,0.0,1000,4179680,12 +google_2011,cpu_by_machine_id,instant,cms,rows=5 cols=16384,0.7582599880170395,0.05,False,56234133,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,38.0,53.370370370370374,4237.222222222223,0.0,100000,212533,1 +google_2011,cpu_by_machine_id,instant,countsketch,rows=5 cols=16384,0.30138674217296635,0.05,False,1778279,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,44.283333333333324,48.85185185185186,8852.77777777778,0.0,100000,212533,1 +google_2011,cpu_by_machine_id,instant,topk,rows=5 cols=16384,0.06720288051074944,0.95,False,316228,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,158.7126111111111,171.7777777777778,9.444444444444445,0.0,100000,212533,1 +google_2011,cpu_by_machine_id,5m,cms,rows=5 cols=16384,1.0326638561629764,0.05,False,56234133,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,38.0,53.370370370370374,4237.222222222223,0.0,100000,379702,1 +google_2011,cpu_by_machine_id,5m,countsketch,rows=5 cols=16384,0.36704286832769284,0.05,False,1778279,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,44.283333333333324,48.85185185185186,8852.77777777778,0.0,100000,379702,1 +google_2011,cpu_by_machine_id,5m,topk,rows=5 cols=16384,0.024629771226929636,0.95,False,316228,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,158.7126111111111,171.7777777777778,9.444444444444445,0.0,100000,379702,1 +google_2011,cpu_by_machine_id,1h,cms,rows=5 cols=16384,2.1662410274416684,0.05,False,56234133,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,38.0,53.370370370370374,4237.222222222223,0.0,100000,4179680,12 +google_2011,cpu_by_machine_id,1h,countsketch,rows=5 cols=16384,0.6104741039391377,0.05,False,1778279,target not met; not saturated at min_N; cost scaled from rows=3,327680.0,44.283333333333324,48.85185185185186,8852.77777777778,0.0,100000,4179680,12 +google_2011,cpu_by_machine_id,1h,topk,rows=5 cols=16384,0.010416666666666666,0.95,False,316228,target not met; merged curve at m=16; cost scaled from rows=3,327680.0,158.7126111111111,171.7777777777778,9.444444444444445,0.0,100000,4179680,12 +google_2011,cpu_p99,instant,kll,k=200,0.002039960011051183,0.01,True,not_saturated,"alpha 21.4807 beyond grid, used 3; not saturated",6400.0,25.645400000000002,5.177777777777778,3240.9999999999995,3.0,,138139,1 +google_2011,cpu_p99,instant,dd,alpha=0.01,0.007329712681478714,0.01,True,1000,"alpha 21.4807 beyond grid, used 3",3464.0,15.694700000000001,1.1333333333333333,2008.3333333333333,3.0,,138139,1 +google_2011,cpu_p99,5m,kll,k=200,0.0022097160036066922,0.01,True,not_saturated,"alpha 20.2786 beyond grid, used 3; not saturated",6400.0,25.645400000000002,5.177777777777778,3240.9999999999995,3.0,,277263,1 +google_2011,cpu_p99,5m,dd,alpha=0.01,0.007336747808287365,0.01,True,1000,"alpha 20.2786 beyond grid, used 3",3464.0,15.694700000000001,1.1333333333333333,2008.3333333333333,3.0,,277263,1 +google_2011,cpu_p99,1h,kll,k=50,0.009321144543074669,0.01,True,not_saturated,"alpha 16.2919 beyond grid, used 3; merged curve at m=16; not saturated",1600.0,25.094000000000005,2.666666666666667,2186.3333333333335,3.0,,3021637,12 +google_2011,cpu_p99,1h,dd,alpha=0.01,0.007346596686089427,0.01,True,1000,"alpha 16.2919 beyond grid, used 3",3464.0,15.694700000000001,1.1333333333333333,2008.3333333333333,3.0,,3021637,12 +google_2011,memory_p99,instant,kll,k=200,0.002039654412650209,0.01,True,not_saturated,"alpha 17.2179 beyond grid, used 3; light tail; not saturated",6400.0,25.268599999999996,5.3999999999999995,2951.9999999999995,3.0,,136461,1 +google_2011,memory_p99,instant,dd,alpha=0.01,0.007328875873422717,0.01,True,1000,"alpha 17.2179 beyond grid, used 3; light tail",4616.0,15.611766666666668,1.266666666666667,1987.333333333333,3.0,,136461,1 +google_2011,memory_p99,5m,kll,k=200,0.0021330932787594088,0.01,True,not_saturated,"alpha 17.4546 beyond grid, used 3; light tail; not saturated",6400.0,25.268599999999996,5.3999999999999995,2951.9999999999995,3.0,,225145,1 +google_2011,memory_p99,5m,dd,alpha=0.01,0.007341556560272891,0.01,True,1000,"alpha 17.4546 beyond grid, used 3; light tail",4616.0,15.611766666666668,1.266666666666667,1987.333333333333,3.0,,225145,1 +google_2011,memory_p99,1h,kll,k=200,0.0029674150750894092,0.01,True,not_saturated,"alpha 16.0911 beyond grid, used 3; light tail; merged curve at m=16; not saturated",6400.0,25.268599999999996,5.3999999999999995,2951.9999999999995,3.0,,2446753,12 +google_2011,memory_p99,1h,dd,alpha=0.01,0.007347478509427665,0.01,True,1000,"alpha 16.0911 beyond grid, used 3; light tail",4616.0,15.611766666666668,1.266666666666667,1987.333333333333,3.0,,2446753,12 diff --git a/docs/saturation_study.md b/docs/saturation_study.md index f64fb765..1c292820 100644 --- a/docs/saturation_study.md +++ b/docs/saturation_study.md @@ -533,11 +533,33 @@ Crossover at theta = 1, K = 1e5 (frequency, top-k, HLL) and Pareto alpha 1.5 ### Not covered yet -- **Accuracy after merging.** Every curve is one sketch fed N items. For CMS, - CountSketch, HLL and DDSketch a merge of m shards equals one sketch over - the union, so the curves apply to merged windows. For KLL (merge depth) and - the top-k heap (a globally heavy key can miss every shard's heap) they are - only a lower bound on merged error; measuring that is the next PR. +- **Accuracy after merging** is now measured (`--operations merge --metrics + accuracy --merge-shards m`, or `--merge-shards-list 1,4,16,64` here, into + `saturation_merge_curve.csv`): the N-item stream is split into m contiguous + shards, one sketch per shard is folded into one, and it is scored with the + query's comparator against the whole-stream truth. A bounded run (first + config per sketch, N up to 1e7, 3 seeds, theta 0.5/1.0/1.5, K 1e3/1e5/1e7, + alpha 1.1/2) found: + - CMS, CountSketch, HLL and DDSketch: merged error is identical to the + single sketch at every N, point and shard count (0 of 1479 cells + differ), so their saturation curves apply unchanged to merged windows. + - KLL (k=50): merged mean rank error drifts but stays within about 2 seed + SE of the single sketch; at N=1e7 it is 0.0115/0.0115/0.0104/0.0121 + (alpha 1.1) and 0.0121/0.0124/0.0119/0.0141 (alpha 2) for m=1/4/16/64, + so only 64 shards shows a (5-16%) increase. + - Top-k heap (rows=3 cols=256): with few keys (K=1000) every heavy key + survives in every shard's heap and precision@k is unchanged; with + K=1e5 or 1e7 and theta 1.0/1.5, merged precision@k at N=1e7 drops by + 0.03-0.09 (8-25% relative), e.g. theta 1.5, K=1e5: 0.60 -> 0.55/0.51/0.52 + for m=4/16/64 (theta 0.5 is at low precision and within seed noise), so + the single-sketch curve overstates merged top-k quality. + - Full grids (all top-k configs, KLL k 50/200/800 and DDSketch with 10 + seeds; `docs/figures/saturation/merge_grid/`): DDSketch stays exact; + top-k's median merged/single precision is 1.00 but drops to 0.60 at large + K for every width; KLL's merged error grows with k (≈ 1.0–1.1x at + k = 50/200, 1.12–1.32x at k = 800 at N = 1e7, and up to 3–4x at + N = 1e4–1e5 for k = 800, m = 4). `recommend_config.py --merge-curves` + now covers every top-k and KLL config. - **HLL lg_k 10.** asap_sketchlib has register types for lg_k 12, 14, 16 (and 18 for the bucket list) only, so the HLL grid starts at 12. diff --git a/scripts/plot_saturation_merge.py b/scripts/plot_saturation_merge.py new file mode 100644 index 00000000..bb3a3a26 --- /dev/null +++ b/scripts/plot_saturation_merge.py @@ -0,0 +1,100 @@ +"""Accuracy after merging: error vs N, one line per shard count m, per sketch and distribution. + +Usage: plot_saturation_merge.py saturation_merge_curve.csv OUT_DIR (needs matplotlib) +Writes merge_error_vs_N____.png per sketch config and merge_ratio_at_nmax.png. +""" +import csv +import os +import sys + +import matplotlib +matplotlib.use("Agg") +import matplotlib.pyplot as plt # noqa: E402 + +rows = list(csv.DictReader(open(sys.argv[1]))) +out = sys.argv[2] +os.makedirs(out, exist_ok=True) +INK, INK2, MUTED, SURF = "#0b0b0b", "#52514e", "#898781", "#fcfcfb" +SHARD_COLORS = {"1": "#2a78d6", "4": "#eb6834", "16": "#1baf7a", "64": "#eda100"} +plt.rcParams.update({ + "font.size": 9, "axes.edgecolor": MUTED, "axes.labelcolor": INK2, + "xtick.color": MUTED, "ytick.color": MUTED, "axes.titlecolor": INK, + "axes.spines.top": False, "axes.spines.right": False, + "axes.grid": True, "grid.color": "#e8e7e3", "grid.linewidth": 0.6, + "figure.facecolor": SURF, "axes.facecolor": SURF, "legend.frameon": False, +}) +METRIC = {"cms-fastpath-vector2d": "are_top100", "countsketch-fastpath-vector2d": "are_top100", + "cms-heap-topk-fastpath-vector2d": "precision@k (higher is better)", + "hll": "relative error", "kll-percall": "mean rank error", "dd": "mean rank error"} +KLAB = {"1000": "1K", "100000": "100K", "10000000": "10M"} + +curves = {} +for r in rows: + key = (r["sketch"], r["config"], r["dist"], r["param"], r["cardinality"]) + curves.setdefault(key, {}).setdefault(r["shards"], []).append( + (int(r["n"]), float(r["seed_mean_error"]), float(r["seed_se"]))) +SHARDS = sorted({int(r["shards"]) for r in rows}) +if 1 not in SHARDS: + sys.exit(f"{sys.argv[1]} has no m=1 rows, the single-sketch baseline every ratio needs") +MERGED = [m for m in SHARDS if m != 1] +# ponytail: shard counts beyond the four fixed colours cycle tab10, which repeats past 10 more. +extra = plt.get_cmap("tab10").colors +for i, m in enumerate(m for m in MERGED if str(m) not in SHARD_COLORS): + SHARD_COLORS[str(m)] = extra[i % len(extra)] + +ratio = {} +for sk, cfg in dict.fromkeys((k[0], k[1]) for k in curves): + keys = sorted((k for k in curves if k[0] == sk and k[1] == cfg), + key=lambda k: (float(k[3]), float(k[4] or 0))) + params = sorted({k[3] for k in keys}, key=float) + ks = sorted({k[4] for k in keys}, key=lambda v: float(v or 0)) + fig, axes = plt.subplots(len(ks), len(params), figsize=(3.4 * len(params) + 0.5, 2.6 * len(ks) + 1.1), + squeeze=False, sharex=True, constrained_layout=True) + for key in keys: + ax = axes[ks.index(key[4]), params.index(key[3])] + base = None + for m in sorted(curves[key], key=int): + pts = sorted(curves[key][m]) + ns = [p[0] for p in pts] + ys = [p[1] for p in pts] + ses = [p[2] for p in pts] + ax.fill_between(ns, [y - 2 * s for y, s in zip(ys, ses)], [y + 2 * s for y, s in zip(ys, ses)], + color=SHARD_COLORS[m], alpha=0.12, lw=0) + ax.plot(ns, ys, color=SHARD_COLORS[m], lw=2 if m != "1" else 2.6, label=f"m={m}") + if m == "1": + base = ys[-1] + elif base: + ratio.setdefault(f"{sk.replace('-fastpath-vector2d', '')}\n{cfg}", []).append( + (key, int(m), ys[-1] / base)) + ax.set_xscale("log") + if all(y > 0 for m in curves[key] for _, y, _ in curves[key][m]) and "topk" not in sk: + ax.set_yscale("log") + head = f"α={key[3]}" if key[2] == "pareto" else f"θ={key[3]}, K={KLAB.get(key[4], key[4])}" + ax.set_title(head, loc="left", fontsize=9) + ax.set_xlabel("items inserted N") + axes[0, 0].legend(fontsize=8, labelcolor=INK2) + for a in axes[:, 0]: + a.set_ylabel(METRIC.get(sk, "error")) + fig.suptitle(f"{sk} ({keys[0][1]})\nerror after merging m contiguous shards vs one sketch (m=1); " + "mean over seeds (3 for Zipf, 10 for Pareto), band = ±2 SE", x=0.01, ha="left", color=INK, fontsize=11) + fig.savefig(os.path.join(out, f"merge_error_vs_N__{sk}__{cfg.replace(' ', '_')}.png"), dpi=110) + plt.close(fig) + +# Summary: merged / single error at the largest N, per sketch and shard count. +fig, ax = plt.subplots(figsize=(max(9, 1.1 * len(ratio)), 4.6), constrained_layout=True) +sks = list(ratio) +width = 0.66 / len(MERGED) +for j, m in enumerate(MERGED): + for i, sk in enumerate(sks): + vals = [v for (_, mm, v) in ratio[sk] if mm == m] + xs = [i + (j - (len(MERGED) - 1) / 2) * width] * len(vals) + ax.plot(xs, vals, "o", ms=6, color=SHARD_COLORS[str(m)], mec=SURF, mew=1.5, + label=f"m={m}" if i == 0 else None) +ax.axhline(1.0, color=MUTED, lw=1, ls=":") +ax.set_xticks(range(len(sks))) +ax.set_xticklabels(sks, fontsize=7) +ax.set_ylabel("merged / single at N = max\n(precision for top-k: < 1 is worse)") +ax.set_title("Each dot is one distribution; 1.0 = merging is exact", loc="left", fontsize=10) +ax.legend(fontsize=8, labelcolor=INK2) +fig.savefig(os.path.join(out, "merge_ratio_at_nmax.png"), dpi=110) +print(out) diff --git a/scripts/study_saturation.py b/scripts/study_saturation.py index 195d79d0..a76b4b4c 100644 --- a/scripts/study_saturation.py +++ b/scripts/study_saturation.py @@ -29,6 +29,9 @@ columns blank after --phase accuracy) crossover.csv N* per point + saturation_merge_curve.csv with --merge-shards-list: + seed-mean error per N of the sketch merged from m contiguous shards + (m=1 is the plain single-sketch query) """ import argparse @@ -80,6 +83,7 @@ "family", "sketch", "config", "dist", "param", "cardinality", "n", "seed_mean_error", "seed_se", ] +MERGE_CURVE_COLUMNS = CURVE_COLUMNS[:-2] + ["shards", "seed_mean_error", "seed_se"] def checkpoints(n_min, n_max, per_decade): @@ -141,12 +145,15 @@ def point_key(sketch, config, dist, param, cardinality): return (sketch, config, dist, float(param), card) -def load_curves(path): - """{point key: sorted [(n, seed-mean error, se)]} from a saturation_curve.csv.""" +def load_curves(path, shards=False): + """{point key: sorted [(n, seed-mean error, se)]} from a saturation_curve.csv, + or {point key + (m,): ...} from a saturation_merge_curve.csv with `shards`.""" curves = {} with open(path, newline="") as f: for r in csv.DictReader(f): key = point_key(r["sketch"], r["config"], r["dist"], r["param"], r["cardinality"]) + if shards: + key += (int(r["shards"]),) curves.setdefault(key, []).append( (int(r["n"]), float(r["seed_mean_error"]), float(r["seed_se"]))) return {key: sorted(curve) for key, curve in curves.items()} @@ -265,6 +272,9 @@ def main(): parser.add_argument("--cost-rows", type=int, help="cost: measure only this rows= value of the Vector2D sketches " "(other rows get blank cost columns and no crossover row)") + parser.add_argument("--merge-shards-list", default="", + help="accuracy: e.g. 1,4,16,64: also score the sketch merged from " + "m shards, for each m>1, into saturation_merge_curve.csv") args = parser.parse_args() families = args.families.split(",") @@ -273,6 +283,7 @@ def main(): alphas = [float(a) for a in args.alphas.split(",")] ns = checkpoints(args.n_min, args.n_max, args.per_decade) seeds = list(range(1, args.seeds + 1)) + shard_list = [int(m) for m in args.merge_shards_list.split(",") if m] os.environ.setdefault("BENCH_WARMUP_SECS", "0") os.makedirs(args.out, exist_ok=True) @@ -308,11 +319,13 @@ def main(): "are in the grid; widen --families/--thetas/--cardinalities/--alphas") print(f"{len(points)} points x {len(ns)} sizes x {len(seeds)} seeds", file=sys.stderr) - def accuracy(point, n, seed): + def accuracy(point, n, seed, shards=1): _, variant, config, comparator, metric, dataset, *_ = point + # One shard is the plain query; more score the sketch merged from them. + operation = ["query"] if shards == 1 else ["merge", "--merge-shards", str(shards)] return run(args.binary, [ "--variant", variant, "--library", "lib", "--config", config, - "--operations", "query", "--metrics", "accuracy", + "--operations", *operation, "--metrics", "accuracy", "--comparator", comparator, "--runs", "1", "--warmup-runs", "0", "--size", str(n), "--seed", str(seed), ] + dataset) @@ -326,12 +339,27 @@ def accuracy(point, n, seed): # point cut off mid-write is dropped and rerun, and a second # interruption loses nothing that was kept. Rows of points outside # this grid are written back as they are, so a narrower resume - # deletes nothing. - done, kept_rows = {}, [] + # deletes nothing. With --merge-shards-list a point is complete only + # once its merge curve is too. + merge_path = os.path.join(args.out, "saturation_merge_curve.csv") + done, kept_rows, kept_merge_rows = {}, [], [] if args.resume and os.path.exists(curve_path): grid = {point_key(p[1], p[2], *p[6:]) for p in points} done = {key: c for key, c in load_curves(curve_path).items() if key in grid and [n for n, _, _ in c] == ns} + if shard_list: + merge_done = (load_curves(merge_path, shards=True) + if os.path.exists(merge_path) else {}) + done = {key: c for key, c in done.items() + if all([n for n, _, _ in merge_done.get(key + (m,), [])] == ns + for m in shard_list)} + if os.path.exists(merge_path): + with open(merge_path, newline="") as f: + for r in csv.DictReader(f): + key = point_key(r["sketch"], r["config"], r["dist"], r["param"], + r["cardinality"]) + if key not in grid or (key in done and int(r["shards"]) in shard_list): + kept_merge_rows.append([r[c] for c in MERGE_CURVE_COLUMNS]) with open(curve_path, newline="") as f: for r in csv.DictReader(f): key = point_key(r["sketch"], r["config"], r["dist"], r["param"], @@ -345,6 +373,12 @@ def accuracy(point, n, seed): curve.writerow(CURVE_COLUMNS) curve.writerows(kept_rows) curve_file.flush() + if shard_list: + merge_file = open(merge_path, "w", newline="") + merge_curve = csv.writer(merge_file) + merge_curve.writerow(MERGE_CURVE_COLUMNS) + merge_curve.writerows(kept_merge_rows) + merge_file.flush() # Submit everything up front so the pool stays full; results are consumed # in point order, so the curve CSV fills point by point. with ThreadPoolExecutor(max_workers=args.jobs) as pool: @@ -352,11 +386,17 @@ def accuracy(point, n, seed): None if point_key(p[1], p[2], *p[6:]) in done else [[pool.submit(accuracy, p, n, s) for s in seeds] for n in ns] for p in points ] + merge_futures = [ + None if per_n is None else + [{m: [pool.submit(accuracy, p, n, s, m) for s in seeds] + for m in shard_list if m > 1} for n in ns] + for p, per_n in zip(points, futures) + ] print(f"{len(done)} points kept, {sum(f is not None for f in futures)} to run", file=sys.stderr) results = [] try: - for point, per_n in zip(points, futures): + for point, per_n, merge_per_n in zip(points, futures, merge_futures): family, variant, config, _, metric, _, dist, param, k = point if per_n is None: kept = done[point_key(variant, config, dist, param, k)] @@ -366,7 +406,7 @@ def accuracy(point, n, seed): results.append((point, n_sat, means[-1])) continue means, ses = [], [] - for n, per_seed in zip(ns, per_n): + for n, per_seed, per_shards in zip(ns, per_n, merge_per_n): records = [f.result() for f in per_seed] for r in records: raw.write(json.dumps(r) + "\n") @@ -374,7 +414,19 @@ def accuracy(point, n, seed): means.append(mean) ses.append(se) curve.writerow([family, variant, config, dist, param, k, n, mean, se]) + for m in shard_list: + if m == 1: + mean, se = means[-1], ses[-1] + else: + merged = [f.result() for f in per_shards[m]] + for r in merged: + raw.write(json.dumps(r) + "\n") + mean, se = mean_and_se([error(r, metric) for r in merged]) + merge_curve.writerow( + [family, variant, config, dist, param, k, n, m, mean, se]) curve_file.flush() + if shard_list: + merge_file.flush() n_sat = n_saturation(ns, means, args.tolerance, args.plateau_tail, ses) results.append((point, n_sat, means[-1])) print(f" {variant} ({config}) {dist}={param} K={k}: n_sat={n_sat}", @@ -383,9 +435,14 @@ def accuracy(point, n, seed): # A failed run (or Ctrl-C) should surface now, not after the queue drains. for f in (f for per_n in futures if per_n for fs in per_n for f in fs): f.cancel() + for f in (f for per_n in merge_futures if per_n + for by_m in per_n for fs in by_m.values() for f in fs): + f.cancel() raise raw.close() curve_file.close() + if shard_list: + merge_file.close() # Cost at the final N, one serial run per point with the merge setup of # export_rqe_optimizer_costs.sh. --phase accuracy leaves these blank. diff --git a/scripts/test_study_saturation.py b/scripts/test_study_saturation.py index 5e07677f..b9b1d303 100644 --- a/scripts/test_study_saturation.py +++ b/scripts/test_study_saturation.py @@ -141,7 +141,10 @@ def test_other_sizes_exit(self): lib = a[a.index("--library") + 1] ops = a[a.index("--operations") + 1] cpu = lambda s: {"user_ms": {"mean": s * 1000}, "sys_ms": {"mean": 0}} - if "accuracy" in a: + if "accuracy" in a and ops == "merge": + e = 0.01 * int(a[a.index("--merge-shards") + 1]) + r = {"bench": {"accuracy": {"relative_error": e, "are_top100": e}}} + elif "accuracy" in a: r = {"bench": {"accuracy": {"relative_error": 0.01, "are_top100": 0.01}}} elif lib == "lib": r = {"memory_bytes": 1000, "insert_cpu_time_ms": cpu(1.0), @@ -193,6 +196,33 @@ def test_points_outside_the_grid_exit(self): self.assertNotEqual(self.run_study(d, points).returncode, 0) +class MergeCurveTest(unittest.TestCase): + def test_one_row_per_shard_count_and_one_is_the_plain_query(self): + with tempfile.TemporaryDirectory() as d: + subprocess.run([ + sys.executable, SCRIPT, "--binary", fake_binary(d), "--out", d, + "--phase", "accuracy", "--families", "cardinality", "--one-config", + "--thetas", "1.0", "--cardinalities", "1000", "--n-max", "1e4", + "--per-decade", "1", "--seeds", "2", "--merge-shards-list", "4,1", + ], check=True, capture_output=True) + with open(os.path.join(d, "saturation_merge_curve.csv"), newline="") as f: + rows = list(csv.DictReader(f)) + self.assertEqual( + [(r["n"], r["shards"], float(r["seed_mean_error"])) for r in rows], + [("1000", "4", 0.04), ("1000", "1", 0.01), + ("10000", "4", 0.04), ("10000", "1", 0.01)]) + + def test_without_the_flag_there_is_no_merge_curve(self): + with tempfile.TemporaryDirectory() as d: + subprocess.run([ + sys.executable, SCRIPT, "--binary", fake_binary(d), "--out", d, + "--phase", "accuracy", "--families", "cardinality", "--one-config", + "--thetas", "1.0", "--cardinalities", "1000", "--n-max", "1e4", + "--per-decade", "1", "--seeds", "1", + ], check=True, capture_output=True) + self.assertFalse(os.path.exists(os.path.join(d, "saturation_merge_curve.csv"))) + + class ResumeTest(unittest.TestCase): def test_keeps_complete_curves_and_reruns_the_rest(self): with tempfile.TemporaryDirectory() as d: @@ -228,6 +258,33 @@ def test_keeps_complete_curves_and_reruns_the_rest(self): # Only the rerun point was measured: 4 sizes x 2 seeds. self.assertEqual(len(raw), 8) + def test_a_point_without_its_merge_curve_is_rerun_without_duplicates(self): + with tempfile.TemporaryDirectory() as d: + ns = checkpoints(1e3, 1e6, 1) + row = ["cardinality", "hll", "lg_k=12", "zipf"] + # Both curves are complete, but theta 1's merge rows were cut off + # after one size and that size was written twice. + write_csv(os.path.join(d, "saturation_curve.csv"), CURVE_HEADER, + [row + [t, 1000, n, 0.5, 0] for t in (0.0, 1.0) for n in ns]) + write_csv(os.path.join(d, "saturation_merge_curve.csv"), + CURVE_HEADER[:-2] + ["shards", "seed_mean_error", "seed_se"], + [row + [0.0, 1000, n, m, 0.5, 0] for n in ns for m in (1, 4)] + + [row + [1.0, 1000, ns[0], 4, 0.9, 0]] * 2) + subprocess.run([ + sys.executable, SCRIPT, "--binary", fake_binary(d), "--out", d, + "--phase", "accuracy", "--families", "cardinality", "--one-config", + "--thetas", "0,1.0", "--cardinalities", "1000", "--n-max", "1e6", + "--per-decade", "1", "--seeds", "2", "--merge-shards-list", "1,4", + "--resume", + ], check=True, capture_output=True) + with open(os.path.join(d, "saturation_merge_curve.csv"), newline="") as f: + rows = list(csv.DictReader(f)) + errors = {} + for r in rows: + errors.setdefault((r["param"], r["shards"]), []).append(float(r["seed_mean_error"])) + self.assertEqual(errors, {("0.0", "1"): [0.5] * 4, ("0.0", "4"): [0.5] * 4, + ("1.0", "1"): [0.01] * 4, ("1.0", "4"): [0.04] * 4}) + class CostPhaseTest(unittest.TestCase): def test_cost_rows_measures_only_that_rows_value(self): diff --git a/sketch-bench/src/wrappers/cms/datasketches.rs b/sketch-bench/src/wrappers/cms/datasketches.rs index c7550996..ef957001 100644 --- a/sketch-bench/src/wrappers/cms/datasketches.rs +++ b/sketch-bench/src/wrappers/cms/datasketches.rs @@ -125,13 +125,25 @@ pub fn query_cms_datasketches( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cms_datasketches(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_datasketches( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cms_datasketches(params)?; - for v in items.iter() { - sketch.inner.update(v.hash_key()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_datasketches_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/cms/oxide.rs b/sketch-bench/src/wrappers/cms/oxide.rs index 43f5efb0..b9bf5606 100644 --- a/sketch-bench/src/wrappers/cms/oxide.rs +++ b/sketch-bench/src/wrappers/cms/oxide.rs @@ -88,13 +88,28 @@ pub fn query_cms_oxide( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cms_oxide(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_oxide( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cms_oxide(params)?; - for v in items.iter() { - sketch.inner.update(&v.hash_key()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_oxide_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so rows/cols match"); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/cms/sketchlib.rs b/sketch-bench/src/wrappers/cms/sketchlib.rs index e8a3ab18..2581c16e 100644 --- a/sketch-bench/src/wrappers/cms/sketchlib.rs +++ b/sketch-bench/src/wrappers/cms/sketchlib.rs @@ -203,16 +203,32 @@ pub fn query_cms_lib_fixedmatrix( probes: Rc>, passes: usize, ) -> Result>, BuildError> +where + M: MatrixStorage + FastPathHasher + Default + Clone + 'static, + T: FrequencyValue, +{ + merge_query_cms_lib_fixedmatrix::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_lib_fixedmatrix( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> where M: MatrixStorage + FastPathHasher + Default + Clone + 'static, T: FrequencyValue, { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cms_lib_fixedmatrix::(params)?; - for v in items.iter() { - sketch.0.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_lib_fixedmatrix_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.0.merge(&other.0); } let probes = probes.clone(); out.push(Box::new(move || { @@ -353,13 +369,25 @@ pub fn query_cms_lib_vector2d_fast( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cms_lib_vector2d_fast(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_lib_vector2d_fast( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cms_lib_vector2d_fast(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_lib_vector2d_fast_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { @@ -488,13 +516,25 @@ pub fn query_cms_lib_vector2d_regular( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cms_lib_vector2d_regular(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_lib_vector2d_regular( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cms_lib_vector2d_regular(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_lib_vector2d_regular_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/cms_heap/sketchlib.rs b/sketch-bench/src/wrappers/cms_heap/sketchlib.rs index cf02bac9..c6293183 100644 --- a/sketch-bench/src/wrappers/cms_heap/sketchlib.rs +++ b/sketch-bench/src/wrappers/cms_heap/sketchlib.rs @@ -173,12 +173,25 @@ pub fn query_cms_heap_lib_vector2d_fast_estimate( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cms_heap_lib_vector2d_fast_estimate(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_heap_lib_vector2d_fast_estimate( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - let mut sketch = build_cms_heap_lib_vector2d_fast(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_heap_lib_vector2d_fast_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { @@ -198,12 +211,25 @@ pub fn query_cms_heap_lib_vector2d_regular_estimate( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cms_heap_lib_vector2d_regular_estimate(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_heap_lib_vector2d_regular_estimate( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - let mut sketch = build_cms_heap_lib_vector2d_regular(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_heap_lib_vector2d_regular_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { @@ -226,16 +252,29 @@ pub fn query_cms_heap_lib_vector2d_regular_estimate( // queries do. pub fn query_cms_heap_lib_vector2d_fast_topk( + params: &ParamSet, + items: Rc>, + probes: Rc>, + passes: usize, +) -> Result>>, BuildError> { + merge_query_cms_heap_lib_vector2d_fast_topk(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_heap_lib_vector2d_fast_topk( params: &ParamSet, items: Rc>, _probes: Rc>, + shards: usize, passes: usize, ) -> Result>>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - let mut sketch = build_cms_heap_lib_vector2d_fast(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_heap_lib_vector2d_fast_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } out.push(Box::new(move || { let ranked: TopkAnswer = sketch @@ -258,16 +297,29 @@ pub fn query_cms_heap_lib_vector2d_fast_topk( } pub fn query_cms_heap_lib_vector2d_regular_topk( + params: &ParamSet, + items: Rc>, + probes: Rc>, + passes: usize, +) -> Result>>, BuildError> { + merge_query_cms_heap_lib_vector2d_regular_topk(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cms_heap_lib_vector2d_regular_topk( params: &ParamSet, items: Rc>, _probes: Rc>, + shards: usize, passes: usize, ) -> Result>>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - let mut sketch = build_cms_heap_lib_vector2d_regular(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cms_heap_lib_vector2d_regular_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } out.push(Box::new(move || { let ranked: TopkAnswer = sketch diff --git a/sketch-bench/src/wrappers/cs/oxide.rs b/sketch-bench/src/wrappers/cs/oxide.rs index 86ea659c..879b9e68 100644 --- a/sketch-bench/src/wrappers/cs/oxide.rs +++ b/sketch-bench/src/wrappers/cs/oxide.rs @@ -90,13 +90,28 @@ pub fn query_cs_oxide( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cs_oxide(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cs_oxide( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cs_oxide(params)?; - for v in items.iter() { - sketch.inner.update(&v.hash_key(), 1); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cs_oxide_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so rows/cols match"); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/cs/sketchlib.rs b/sketch-bench/src/wrappers/cs/sketchlib.rs index 6fb1ac6b..31a502aa 100644 --- a/sketch-bench/src/wrappers/cs/sketchlib.rs +++ b/sketch-bench/src/wrappers/cs/sketchlib.rs @@ -191,16 +191,32 @@ pub fn query_cs_lib_fixedmatrix( probes: Rc>, passes: usize, ) -> Result>, BuildError> +where + M: MatrixStorage + FastPathHasher + Default + Clone + 'static, + T: FrequencyValue, +{ + merge_query_cs_lib_fixedmatrix::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cs_lib_fixedmatrix( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> where M: MatrixStorage + FastPathHasher + Default + Clone + 'static, T: FrequencyValue, { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cs_lib_fixedmatrix::(params)?; - for v in items.iter() { - sketch.0.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cs_lib_fixedmatrix_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.0.merge(&other.0); } let probes = probes.clone(); out.push(Box::new(move || { @@ -341,13 +357,25 @@ pub fn query_cs_lib_vector2d_fast( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cs_lib_vector2d_fast(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cs_lib_vector2d_fast( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cs_lib_vector2d_fast(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cs_lib_vector2d_fast_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { @@ -476,13 +504,25 @@ pub fn query_cs_lib_vector2d_regular( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_cs_lib_vector2d_regular(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_cs_lib_vector2d_regular( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_cs_lib_vector2d_regular(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = cs_lib_vector2d_regular_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/dd/oxide.rs b/sketch-bench/src/wrappers/dd/oxide.rs index 9e0fbe61..3ab1e568 100644 --- a/sketch-bench/src/wrappers/dd/oxide.rs +++ b/sketch-bench/src/wrappers/dd/oxide.rs @@ -87,14 +87,33 @@ pub fn query_dd_oxide( probes: Rc>, passes: usize, ) -> Result>, BuildError> +where + T: QuantileValue + 'static, +{ + merge_query_dd_oxide::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_dd_oxide( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> where T: QuantileValue + 'static, { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - let mut sketch = build_dd_oxide::(params)?; - for v in items.iter() { - sketch.inner.add(v.to_f64()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = dd_oxide_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so alpha matches"); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/dd/sketchlib.rs b/sketch-bench/src/wrappers/dd/sketchlib.rs index 17932c07..cdc9c845 100644 --- a/sketch-bench/src/wrappers/dd/sketchlib.rs +++ b/sketch-bench/src/wrappers/dd/sketchlib.rs @@ -90,14 +90,30 @@ pub fn query_dd_lib( probes: Rc>, passes: usize, ) -> Result>, BuildError> +where + T: asap_sketchlib::common::numerical::NumericalValue + 'static, +{ + merge_query_dd_lib::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_dd_lib( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> where T: asap_sketchlib::common::numerical::NumericalValue + 'static, { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - let mut sketch = build_dd_lib::(params)?; - for v in items.iter() { - sketch.inner.add(v); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = dd_lib_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/hll/datasketches.rs b/sketch-bench/src/wrappers/hll/datasketches.rs index 92578679..9835e7ab 100644 --- a/sketch-bench/src/wrappers/hll/datasketches.rs +++ b/sketch-bench/src/wrappers/hll/datasketches.rs @@ -95,13 +95,28 @@ pub fn query_hll_datasketches( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_hll_datasketches::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hll_datasketches( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_hll_datasketches(params)?; - for v in items.iter() { - sketch.inner.update(v.hash_key()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = hll_datasketches_shards(params, &items, shards)?; + for other in rest.iter() { + let mut union = ::datasketches::hll::HllUnion::new(sketch.lg_k); + union.update(&sketch.inner); + union.update(&other.inner); + sketch.inner = union.get_result(sketch.hll_type); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/hll/oxide.rs b/sketch-bench/src/wrappers/hll/oxide.rs index 1de7bc0a..710c40f6 100644 --- a/sketch-bench/src/wrappers/hll/oxide.rs +++ b/sketch-bench/src/wrappers/hll/oxide.rs @@ -83,13 +83,28 @@ pub fn query_hll_oxide( items: Rc>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_hll_oxide::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hll_oxide( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_hll_oxide(params)?; - for v in items.iter() { - sketch.inner.update(&v.hash_key()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = hll_oxide_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so lg_k matches"); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/hll/sketchlib.rs b/sketch-bench/src/wrappers/hll/sketchlib.rs index 67464f98..217d8e0d 100644 --- a/sketch-bench/src/wrappers/hll/sketchlib.rs +++ b/sketch-bench/src/wrappers/hll/sketchlib.rs @@ -174,13 +174,25 @@ pub fn query_hll_lib>, probes: Rc>, passes: usize, +) -> Result>, BuildError> { + merge_query_hll_lib::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hll_lib( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_hll_lib::(params)?; - for v in items.iter() { - sketch.inner.insert(&v.data_input()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = hll_lib_shards::(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/hydra_cms/sketchlib.rs b/sketch-bench/src/wrappers/hydra_cms/sketchlib.rs index 549af369..36e7053f 100644 --- a/sketch-bench/src/wrappers/hydra_cms/sketchlib.rs +++ b/sketch-bench/src/wrappers/hydra_cms/sketchlib.rs @@ -100,13 +100,28 @@ pub fn query_hydra_cms( items: Rc>, probes: Rc, V)>>, passes: usize, +) -> Result>, BuildError> { + merge_query_hydra_cms(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hydra_cms( + params: &ParamSet, + items: Rc>, + probes: Rc, V)>>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_hydra_cms(params)?; - for v in items.iter() { - sketch.inner.update(&v.0, &v.1.data_input(), None); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = hydra_cms_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so grid and cell shapes match"); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/hydra_cs/sketchlib.rs b/sketch-bench/src/wrappers/hydra_cs/sketchlib.rs index 36e81da5..dcad1eb8 100644 --- a/sketch-bench/src/wrappers/hydra_cs/sketchlib.rs +++ b/sketch-bench/src/wrappers/hydra_cs/sketchlib.rs @@ -100,13 +100,28 @@ pub fn query_hydra_cs( items: Rc>, probes: Rc, V)>>, passes: usize, +) -> Result>, BuildError> { + merge_query_hydra_cs(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hydra_cs( + params: &ParamSet, + items: Rc>, + probes: Rc, V)>>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_hydra_cs(params)?; - for v in items.iter() { - sketch.inner.update(&v.0, &v.1.data_input(), None); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = hydra_cs_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so grid and cell shapes match"); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/hydra_hll/sketchlib.rs b/sketch-bench/src/wrappers/hydra_hll/sketchlib.rs index 658c6aa2..80afbba4 100644 --- a/sketch-bench/src/wrappers/hydra_hll/sketchlib.rs +++ b/sketch-bench/src/wrappers/hydra_hll/sketchlib.rs @@ -95,13 +95,28 @@ pub fn query_hydra_hll( items: Rc>, probes: Rc>>, passes: usize, +) -> Result>, BuildError> { + merge_query_hydra_hll(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hydra_hll( + params: &ParamSet, + items: Rc>, + probes: Rc>>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_hydra_hll(params)?; - for v in items.iter() { - sketch.inner.update(&v.0, &v.1.data_input(), None); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = hydra_hll_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so grid and cell shapes match"); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/hydra_kll/sketchlib.rs b/sketch-bench/src/wrappers/hydra_kll/sketchlib.rs index 43af750e..beb72ed1 100644 --- a/sketch-bench/src/wrappers/hydra_kll/sketchlib.rs +++ b/sketch-bench/src/wrappers/hydra_kll/sketchlib.rs @@ -109,13 +109,28 @@ pub fn query_hydra_kll( items: Rc>, probes: Rc, f64)>>, passes: usize, +) -> Result>, BuildError> { + merge_query_hydra_kll(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hydra_kll( + params: &ParamSet, + items: Rc>, + probes: Rc, f64)>>, + shards: usize, + passes: usize, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_hydra_kll(params)?; - for v in items.iter() { - sketch.inner.update(&v.0, &v.1.data_input(), None); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = hydra_kll_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so grid and cell shapes match"); } let probes = probes.clone(); out.push(Box::new(move || { diff --git a/sketch-bench/src/wrappers/hydra_univmon/sketchlib.rs b/sketch-bench/src/wrappers/hydra_univmon/sketchlib.rs index 11784c0e..4362677b 100644 --- a/sketch-bench/src/wrappers/hydra_univmon/sketchlib.rs +++ b/sketch-bench/src/wrappers/hydra_univmon/sketchlib.rs @@ -121,15 +121,19 @@ fn asked_hydra_univmon( params: &ParamSet, items: Rc>, probes: Rc>>, + shards: usize, passes: usize, estimate: fn(&HydraUnivmon, &[&str]) -> f64, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_hydra_univmon(params)?; - for v in items.iter() { - sketch.inner.update(&v.0, &v.1.data_input(), None); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = hydra_univmon_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so grid and cell shapes match"); } let probes = probes.clone(); out.push(Box::new(move || { @@ -154,6 +158,26 @@ pub fn query_hydra_univmon_cardinality( params, items, probes, + 1, + passes, + HydraUnivmon::estimate_subpop_cardinality, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hydra_univmon_cardinality( + params: &ParamSet, + items: Rc>, + probes: Rc>>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_hydra_univmon( + params, + items, + probes, + shards, passes, HydraUnivmon::estimate_subpop_cardinality, ) @@ -169,6 +193,26 @@ pub fn query_hydra_univmon_l1_norm( params, items, probes, + 1, + passes, + HydraUnivmon::estimate_subpop_l1_norm, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hydra_univmon_l1_norm( + params: &ParamSet, + items: Rc>, + probes: Rc>>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_hydra_univmon( + params, + items, + probes, + shards, passes, HydraUnivmon::estimate_subpop_l1_norm, ) @@ -184,6 +228,26 @@ pub fn query_hydra_univmon_l2_norm( params, items, probes, + 1, + passes, + HydraUnivmon::estimate_subpop_l2_norm, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hydra_univmon_l2_norm( + params: &ParamSet, + items: Rc>, + probes: Rc>>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_hydra_univmon( + params, + items, + probes, + shards, passes, HydraUnivmon::estimate_subpop_l2_norm, ) @@ -199,6 +263,26 @@ pub fn query_hydra_univmon_entropy( params, items, probes, + 1, + passes, + HydraUnivmon::estimate_subpop_entropy, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_hydra_univmon_entropy( + params: &ParamSet, + items: Rc>, + probes: Rc>>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_hydra_univmon( + params, + items, + probes, + shards, passes, HydraUnivmon::estimate_subpop_entropy, ) diff --git a/sketch-bench/src/wrappers/kll/oxide.rs b/sketch-bench/src/wrappers/kll/oxide.rs index 0dd95004..f753b423 100644 --- a/sketch-bench/src/wrappers/kll/oxide.rs +++ b/sketch-bench/src/wrappers/kll/oxide.rs @@ -123,15 +123,33 @@ pub fn query_kll_oxide_per_call( probes: Rc>, passes: usize, ) -> Result>, BuildError> +where + T: QuantileValue + 'static, +{ + merge_query_kll_oxide_per_call::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_kll_oxide_per_call( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> where T: QuantileValue + 'static, { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_kll_oxide_per_call::(params)?; - for v in items.iter() { - sketch.inner.update(v.to_f64()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = kll_oxide_per_call_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so k matches"); } let probes = probes.clone(); out.push(Box::new(move || { @@ -280,15 +298,35 @@ pub fn query_kll_oxide_cdf( probes: Rc>, passes: usize, ) -> Result>, BuildError> +where + T: QuantileValue + 'static, +{ + merge_query_kll_oxide_cdf::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_kll_oxide_cdf( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> where T: QuantileValue + 'static, { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_kll_oxide_cdf::(params)?; - for v in items.iter() { - sketch.inner.update(v.to_f64()); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = kll_oxide_cdf_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so k matches"); + // A merged sketch invalidates any table cached from the pre-merge state. + sketch.cdf = None; } let (table, min, max) = (sketch.inner.cdf(), sketch.inner.min(), sketch.inner.max()); let probes = probes.clone(); diff --git a/sketch-bench/src/wrappers/kll/sketchlib.rs b/sketch-bench/src/wrappers/kll/sketchlib.rs index fa780563..0bb7467c 100644 --- a/sketch-bench/src/wrappers/kll/sketchlib.rs +++ b/sketch-bench/src/wrappers/kll/sketchlib.rs @@ -131,15 +131,30 @@ pub fn query_kll_lib_per_call( probes: Rc>, passes: usize, ) -> Result>, BuildError> +where + T: asap_sketchlib::common::numerical::NumericalValue + QuantileValue + 'static, +{ + merge_query_kll_lib_per_call::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_kll_lib_per_call( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> where T: asap_sketchlib::common::numerical::NumericalValue + QuantileValue + 'static, { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_kll_lib_per_call::(params)?; - for v in items.iter() { - sketch.inner.update(v); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = kll_lib_per_call_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { @@ -284,15 +299,32 @@ pub fn query_kll_lib_cdf( probes: Rc>, passes: usize, ) -> Result>, BuildError> +where + T: asap_sketchlib::common::numerical::NumericalValue + QuantileValue + 'static, +{ + merge_query_kll_lib_cdf::(params, items, probes, 1, passes) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_kll_lib_cdf( + params: &ParamSet, + items: Rc>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> where T: asap_sketchlib::common::numerical::NumericalValue + QuantileValue + 'static, { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - // Built and fed here: the closure below asks, and only asks. - let mut sketch = build_kll_lib_cdf::(params)?; - for v in items.iter() { - sketch.inner.update(v); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = kll_lib_cdf_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); + // A merged sketch invalidates any CDF cached from the pre-merge state. + sketch.cdf = None; } let cdf = sketch.inner.cdf(); let probes = probes.clone(); diff --git a/sketch-bench/src/wrappers/mod.rs b/sketch-bench/src/wrappers/mod.rs index 70ee384c..303dbf2f 100644 --- a/sketch-bench/src/wrappers/mod.rs +++ b/sketch-bench/src/wrappers/mod.rs @@ -103,9 +103,14 @@ pub type MergeBody = fn(&ParamSet, Rc>, usize, usize) -> Result = fn(&ParamSet, Rc>, usize, usize) -> Result, BuildError>; -/// Both forms of a row's fold: as one pass, and one shard at a time. A row -/// either supplies both or has no merge at all. -pub type Folds = (MergeBody, MergeStepBody); +/// Prime `passes` runs of the row's query, asked of the sketch a fold over +/// `shards` sketches leaves, so its answers can be scored like the query's. +pub type MergeQueryBody = + fn(&ParamSet, Rc>, Rc>, usize, usize) -> Result>, BuildError>; + +/// Every form of a row's fold: as one pass, one shard at a time, and asked +/// afterwards. A row either supplies all three or has no merge at all. +pub type Folds = (MergeBody, MergeStepBody, MergeQueryBody); /// Prime `passes` runs of the step that makes a fed sketch ready to answer. pub type PrepareBody = fn(&ParamSet, Rc>, usize) -> Result, BuildError>; diff --git a/sketch-bench/src/wrappers/univmon/oxide.rs b/sketch-bench/src/wrappers/univmon/oxide.rs index eba79f4b..07487752 100644 --- a/sketch-bench/src/wrappers/univmon/oxide.rs +++ b/sketch-bench/src/wrappers/univmon/oxide.rs @@ -142,15 +142,20 @@ fn asked_univmon_oxide( params: &ParamSet, items: Rc>>, probes: Rc>, + shards: usize, passes: usize, estimate: fn(&UnivMonOxide) -> f64, ) -> Result>, BuildError> { require_non_negative(&items)?; let mut out = Vec::with_capacity(passes); for _ in 0..passes { - let mut sketch = build_univmon_oxide(params)?; - for record in items.iter() { - sketch.feed(record); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = univmon_oxide_shards(params, &items, shards)?; + for other in rest.iter() { + sketch + .inner + .merge(&other.inner) + .expect("both operands built from one ParamSet, so their layers match"); } let probes = probes.clone(); out.push(Box::new(move || { @@ -172,6 +177,26 @@ pub fn query_univmon_oxide_l1_norm( params, items, probes, + 1, + passes, + UnivMonOxide::estimate_l1_norm, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_univmon_oxide_l1_norm( + params: &ParamSet, + items: Rc>>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_univmon_oxide( + params, + items, + probes, + shards, passes, UnivMonOxide::estimate_l1_norm, ) @@ -187,6 +212,26 @@ pub fn query_univmon_oxide_l2_norm( params, items, probes, + 1, + passes, + UnivMonOxide::estimate_l2_norm, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_univmon_oxide_l2_norm( + params: &ParamSet, + items: Rc>>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_univmon_oxide( + params, + items, + probes, + shards, passes, UnivMonOxide::estimate_l2_norm, ) @@ -202,6 +247,26 @@ pub fn query_univmon_oxide_entropy( params, items, probes, + 1, + passes, + UnivMonOxide::estimate_entropy, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_univmon_oxide_entropy( + params: &ParamSet, + items: Rc>>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_univmon_oxide( + params, + items, + probes, + shards, passes, UnivMonOxide::estimate_entropy, ) diff --git a/sketch-bench/src/wrappers/univmon/sketchlib.rs b/sketch-bench/src/wrappers/univmon/sketchlib.rs index db64fa59..ea18c0bd 100644 --- a/sketch-bench/src/wrappers/univmon/sketchlib.rs +++ b/sketch-bench/src/wrappers/univmon/sketchlib.rs @@ -99,14 +99,16 @@ fn asked_univmon_lib( params: &ParamSet, items: Rc>>, probes: Rc>, + shards: usize, passes: usize, estimate: fn(&UnivMonLib) -> f64, ) -> Result>, BuildError> { let mut out = Vec::with_capacity(passes); for _ in 0..passes { - let mut sketch = build_univmon_lib(params)?; - for record in items.iter() { - sketch.feed(record); + // Built, fed and folded here: the closure below asks, and only asks. + let (mut sketch, rest) = univmon_lib_shards(params, &items, shards)?; + for other in rest.iter() { + sketch.inner.merge(&other.inner); } let probes = probes.clone(); out.push(Box::new(move || { @@ -128,6 +130,26 @@ pub fn query_univmon_lib_cardinality( params, items, probes, + 1, + passes, + UnivMonLib::estimate_cardinality, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_univmon_lib_cardinality( + params: &ParamSet, + items: Rc>>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_univmon_lib( + params, + items, + probes, + shards, passes, UnivMonLib::estimate_cardinality, ) @@ -139,7 +161,33 @@ pub fn query_univmon_lib_l1_norm( probes: Rc>, passes: usize, ) -> Result>, BuildError> { - asked_univmon_lib(params, items, probes, passes, UnivMonLib::estimate_l1_norm) + asked_univmon_lib( + params, + items, + probes, + 1, + passes, + UnivMonLib::estimate_l1_norm, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_univmon_lib_l1_norm( + params: &ParamSet, + items: Rc>>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_univmon_lib( + params, + items, + probes, + shards, + passes, + UnivMonLib::estimate_l1_norm, + ) } pub fn query_univmon_lib_l2_norm( @@ -148,7 +196,33 @@ pub fn query_univmon_lib_l2_norm( probes: Rc>, passes: usize, ) -> Result>, BuildError> { - asked_univmon_lib(params, items, probes, passes, UnivMonLib::estimate_l2_norm) + asked_univmon_lib( + params, + items, + probes, + 1, + passes, + UnivMonLib::estimate_l2_norm, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_univmon_lib_l2_norm( + params: &ParamSet, + items: Rc>>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_univmon_lib( + params, + items, + probes, + shards, + passes, + UnivMonLib::estimate_l2_norm, + ) } pub fn query_univmon_lib_entropy( @@ -157,7 +231,33 @@ pub fn query_univmon_lib_entropy( probes: Rc>, passes: usize, ) -> Result>, BuildError> { - asked_univmon_lib(params, items, probes, passes, UnivMonLib::estimate_entropy) + asked_univmon_lib( + params, + items, + probes, + 1, + passes, + UnivMonLib::estimate_entropy, + ) +} + +/// The query, asked of the sketch a fold over `shards` shards leaves. One +/// shard is the plain query. +pub fn merge_query_univmon_lib_entropy( + params: &ParamSet, + items: Rc>>, + probes: Rc>, + shards: usize, + passes: usize, +) -> Result>, BuildError> { + asked_univmon_lib( + params, + items, + probes, + shards, + passes, + UnivMonLib::estimate_entropy, + ) } pub fn merge_univmon_lib(