From 2797e7b3069f1d865ccbc46d4d0e97f8c95b9bcb Mon Sep 17 00:00:00 2001 From: Dimitris Mouris Date: Mon, 5 Feb 2024 14:52:39 -0500 Subject: [PATCH] Change data_bytes to bits --- README.md | 4 ++-- src/bin/config-attributes.json | 4 ++-- src/bin/config-plain.json | 2 +- src/bin/config-weights.json | 2 +- src/bin/driver.rs | 7 +++---- src/bin/server.rs | 15 +++++---------- src/config.rs | 4 ++-- 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index a792c3b..bf87a8a 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ all the config files are shown below: ```bash { - "data_bytes": 1, # Number of bytes of each string (x8 for bits). + "data_bits": 8, # Number of bits of each string. "hist_buckets": 2, # Number of each histogram buckets "mode": ..., # See below. "server_0": "0.0.0.0:8000", # The `IP:port` for server 0. @@ -112,7 +112,7 @@ cargo run --release --bin driver -- --config src/bin/config-attributes.json -n 1 [Config-plain.json](./src/bin/config-plain.json) ```bash ... - "data_bytes": 0, # This is unused in this use-case + "data_bits": 0, # This is unused in this use-case "mode": "plain_metrics", ... ``` diff --git a/src/bin/config-attributes.json b/src/bin/config-attributes.json index 3602f50..2d51c7d 100644 --- a/src/bin/config-attributes.json +++ b/src/bin/config-attributes.json @@ -1,9 +1,9 @@ { - "data_bytes": 1, + "data_bits": 8, "hist_buckets": 4, "mode": { "attribute_based_metrics": { - "threshold": 10 + "num_attributes": 10 } }, "server_0": "0.0.0.0:8000", diff --git a/src/bin/config-plain.json b/src/bin/config-plain.json index 20b020b..2296efe 100644 --- a/src/bin/config-plain.json +++ b/src/bin/config-plain.json @@ -1,5 +1,5 @@ { - "data_bytes": 0, + "data_bits": 0, "hist_buckets": 4, "mode": "plain_metrics", "server_0": "0.0.0.0:8000", diff --git a/src/bin/config-weights.json b/src/bin/config-weights.json index 7080b28..c47ff55 100644 --- a/src/bin/config-weights.json +++ b/src/bin/config-weights.json @@ -1,5 +1,5 @@ { - "data_bytes": 1, + "data_bits": 8, "hist_buckets": 4, "mode": { "weighted_heavy_hitters": { diff --git a/src/bin/driver.rs b/src/bin/driver.rs index 3c09233..6ef8751 100644 --- a/src/bin/driver.rs +++ b/src/bin/driver.rs @@ -144,7 +144,7 @@ fn generate_reports(cfg: &config::Config, mastic: &MasticHistogram) -> Vec { // Synthesize a fake input and weight. - let alpha = sample_string(cfg.data_bytes * 8); + let alpha = sample_string(cfg.data_bits); let beta = mastic.encode_measurement(&bucket).unwrap(); let (key_0, key_1) = VidpfKey::gen_from_str(&alpha, &beta); @@ -749,8 +749,7 @@ async fn main() -> io::Result<()> { Mode::WeightedHeavyHitters { .. } => { tree_init(&client_0, &client_1).await?; - let bit_len = cfg.data_bytes * 8; // bits - for level in 0..bit_len - 1 { + for level in 0..cfg.data_bits - 1 { let start_level = Instant::now(); if level == 0 { run_flp_queries(&cfg, &mastic, &client_0, &client_1, num_clients).await?; @@ -764,7 +763,7 @@ async fn main() -> io::Result<()> { } println!( "\nTime for {} levels: {:?}", - bit_len, + cfg.data_bits, start.elapsed().as_secs_f64() ); diff --git a/src/bin/server.rs b/src/bin/server.rs index 63c7023..8004f90 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -40,7 +40,7 @@ use tarpc::{ struct CollectorServer { server_id: i8, seed: prg::PrgSeed, - data_bytes: usize, + data_bits: usize, arc: Arc>, } @@ -52,7 +52,7 @@ impl Collector for CollectorServer { Mastic::new_histogram(req.hist_buckets).unwrap(), self.server_id, &self.seed, - self.data_bytes, + self.data_bits, req.verify_key, ); "Done".to_string() @@ -334,13 +334,8 @@ async fn main() -> io::Result<()> { let seed = prg::PrgSeed { key: [1u8; 16] }; let mastic = Mastic::new_histogram(cfg.hist_buckets).unwrap(); - let coll = collect::KeyCollection::new( - mastic.clone(), - server_id, - &seed, - cfg.data_bytes * 8, - [0u8; 16], - ); + let coll = + collect::KeyCollection::new(mastic.clone(), server_id, &seed, cfg.data_bits, [0u8; 16]); let arc = Arc::new(Mutex::new(coll)); println!("Server {} running at {:?}", server_id, server_addr); @@ -354,7 +349,7 @@ async fn main() -> io::Result<()> { let server = CollectorServer { server_id, seed: seed.clone(), - data_bytes: cfg.data_bytes * 8, + data_bits: cfg.data_bits, arc: arc.clone(), }; diff --git a/src/config.rs b/src/config.rs index 94ffe1b..f5b6279 100644 --- a/src/config.rs +++ b/src/config.rs @@ -28,8 +28,8 @@ pub enum Mode { #[derive(Deserialize)] pub struct Config { - /// Number of bytes of each string (x8 for bits). - pub data_bytes: usize, + /// Number of bits of each string. + pub data_bits: usize, /// Number of histogram buckets for the FLP range check. pub hist_buckets: usize,