Skip to content

Commit

Permalink
Merge pull request #13 from TrustworthyComputing/jimouris/bits
Browse files Browse the repository at this point in the history
Change data_bytes to bits
  • Loading branch information
jimouris committed Feb 5, 2024
2 parents 5302378 + 2797e7b commit ac567c2
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
...
```
Expand Down
4 changes: 2 additions & 2 deletions src/bin/config-attributes.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/bin/config-plain.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"data_bytes": 0,
"data_bits": 0,
"hist_buckets": 4,
"mode": "plain_metrics",
"server_0": "0.0.0.0:8000",
Expand Down
2 changes: 1 addition & 1 deletion src/bin/config-weights.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"data_bytes": 1,
"data_bits": 8,
"hist_buckets": 4,
"mode": {
"weighted_heavy_hitters": {
Expand Down
7 changes: 3 additions & 4 deletions src/bin/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn generate_reports(cfg: &config::Config, mastic: &MasticHistogram) -> Vec<Plain
match cfg.mode {
Mode::WeightedHeavyHitters { .. } | Mode::AttributeBasedMetrics { .. } => {
// 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);
Expand Down Expand Up @@ -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?;
Expand All @@ -764,7 +763,7 @@ async fn main() -> io::Result<()> {
}
println!(
"\nTime for {} levels: {:?}",
bit_len,
cfg.data_bits,
start.elapsed().as_secs_f64()
);

Expand Down
15 changes: 5 additions & 10 deletions src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use tarpc::{
struct CollectorServer {
server_id: i8,
seed: prg::PrgSeed,
data_bytes: usize,
data_bits: usize,
arc: Arc<Mutex<collect::KeyCollection>>,
}

Expand All @@ -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()
Expand Down Expand Up @@ -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);
Expand All @@ -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(),
};

Expand Down
4 changes: 2 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ac567c2

Please sign in to comment.