Skip to content

Commit

Permalink
Trying zipfian distro.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitkulshreshtha committed Dec 16, 2024
1 parent 77f3558 commit 55c7645
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions datastores/gossip_kv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ lazy_static = "1.5.0"
notify = { version = "6.1.1", default-features = false, features = ["macos_kqueue"] }
prometheus = "0.13.4"
rand = "0.8.5"
rand_distr = "0.4.3"
serde = "1.0.203"
serde_json = "1.0.117"
shlex = "1.3.0"
Expand Down
10 changes: 7 additions & 3 deletions datastores/gossip_kv/kv/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::{HashMap, HashSet};
use std::fmt::Debug;
use std::hash::Hash;

use std::iter::Zip;
use hydroflow::futures::{Sink, Stream};
use hydroflow::hydroflow_syntax;
use hydroflow::itertools::Itertools;
Expand All @@ -15,6 +15,7 @@ use lazy_static::lazy_static;
use prometheus::{register_int_counter, IntCounter};
use rand::seq::IteratorRandom;
use rand::thread_rng;
use rand_distr::{Distribution, Zipf};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use tracing::{info, trace};
Expand Down Expand Up @@ -102,6 +103,9 @@ where
let member_id_5 = my_member_id.clone();
let member_id_6 = my_member_id.clone();

let zipf = Zipf::new(1_000_000, 4.0).unwrap();
let mut rng = thread_rng();

hydroflow_syntax! {

on_start = initialize() -> tee();
Expand Down Expand Up @@ -148,8 +152,8 @@ where
})
-> writes;

simulated_puts = repeat_fn(2000, || {
upsert_row(Clock::new(100), rand::random(), "value".to_string())
simulated_puts = repeat_fn(20000, move || {
upsert_row(Clock::new(100), zipf.sample(&mut rng) as u64, "value".to_string())
})
-> inspect (|_| {
SETS_COUNTER.inc();
Expand Down

0 comments on commit 55c7645

Please sign in to comment.