Skip to content

Commit

Permalink
simplify naming, fix errors in example
Browse files Browse the repository at this point in the history
  • Loading branch information
brayniac committed Apr 10, 2024
1 parent cd813eb commit 16e3abb
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
2 changes: 2 additions & 0 deletions configs/blabber.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ start = 1
topics = 1
topic_len = 1
message_len = 64
# specify an approximate compression ratio for the message payload
compression_ratio = 1.0
weight = 1
# the total number of clients that will subscribe to this set of topics
subscriber_poolsize = 100
Expand Down
6 changes: 2 additions & 4 deletions configs/kafka.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ topic_names = ["hello", "world"]
partitions = 10
# the value length, in bytes
message_len = 512
# approximate compression ratio for the message payload. The config value
# represents the uncompressed size divided by the compressed size. <= 1.0 means
# the message is all random bytes. Higher values are more compressible.
message_compression_ratio = 1.0
# specify an approximate compression ratio for the message payload
compression_ration = 1.0
# the key length, in bytes
key_len = 8
2 changes: 2 additions & 0 deletions configs/memcached.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ nkeys = 1_000_000
vlen = 128
# use random bytes for the values
vkind = "bytes"
# specify an approximate compression ratio for the value
compression_ratio = 1.0
# optionally: specify a TTL for the keys, by default there is no expiration
# ttl = "15m"
# controls what commands will be used in this keyspace
Expand Down
2 changes: 2 additions & 0 deletions configs/momento.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ klen = 32
nkeys = 1_000_000
# sets the value length, in bytes
vlen = 128
# specify an approximate compression ratio for the value payload
compression_ratio = 1.0
# use random bytes for the values
vkind = "bytes"
# override the default ttl for this keyspace setting it to 15 minutes
Expand Down
4 changes: 4 additions & 0 deletions configs/momento_pubsub.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ topics = 10
topic_len = 64
# sets the value length, in bytes
message_len = 128
# specify an approximate compression ratio for the message payload
compression_ratio = 1.0

# An example set of topics using a high number of subscribers per topic.
[[workload.topics]]
Expand All @@ -84,3 +86,5 @@ topics = 1
topic_len = 32
# sets the value length, in bytes
message_len = 128
# specify an approximate compression ratio for the message payload
compression_ratio = 1.0
6 changes: 2 additions & 4 deletions configs/segcache.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ nkeys = 1_000_000
vlen = 128
# use random bytes for the values
vkind = "bytes"
# approximate compression ratio for the value. The config value represents the
# uncompressed size divided by the compressed size. <= 1.0 means the value is
# all random bytes. Higher values are more compressible.
message_compression_ratio = 1.0
# specify an approximate compression ratio for the value payload
compression_ratio = 1.0
# controls what commands will be used in this keyspace
commands = [
# get a value
Expand Down
2 changes: 1 addition & 1 deletion configs/smoketest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ klen = 32
nkeys = 1_000_000
vlen = 128
vkind = "bytes"
message_compression_ratio = 10.0
compression_ratio = 10.0
commands = [
{ verb = "get", weight = 80 },
{ verb = "set", weight = 20 },
Expand Down
12 changes: 6 additions & 6 deletions src/config/workload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct Topics {
topic_names: Vec<String>,
message_len: usize,
#[serde(default)]
message_compression_ratio: Option<f64>,
compression_ratio: Option<f64>,
#[serde(default = "one")]
key_len: usize,
weight: usize,
Expand Down Expand Up @@ -91,8 +91,8 @@ impl Topics {
self.message_len
}

pub fn message_compression_ratio(&self) -> f64 {
self.message_compression_ratio.unwrap_or(1.0)
pub fn compression_ratio(&self) -> f64 {
self.compression_ratio.unwrap_or(1.0)
}

pub fn subscriber_poolsize(&self) -> usize {
Expand Down Expand Up @@ -145,7 +145,7 @@ pub struct Keyspace {
#[serde(default)]
vkind: Option<ValueKind>,
#[serde(default)]
value_compression_ratio: Option<f64>,
compression_ratio: Option<f64>,
#[serde(default)]
// no ttl is treated as no-expires or max ttl for the protocol
ttl: Option<String>,
Expand Down Expand Up @@ -188,8 +188,8 @@ impl Keyspace {
self.vkind.unwrap_or(ValueKind::Bytes)
}

pub fn value_compression_ratio(&self) -> f64 {
self.value_compression_ratio.unwrap_or(1.0)
pub fn compression_ratio(&self) -> f64 {
self.compression_ratio.unwrap_or(1.0)
}

pub fn ttl(&self) -> Option<Duration> {
Expand Down
8 changes: 4 additions & 4 deletions src/workload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ pub struct Topics {

impl Topics {
pub fn new(config: &Config, topics: &config::Topics) -> Self {
let message_random_bytes = if topics.message_compression_ratio() <= 1.0 {
let message_random_bytes = if topics.compression_ratio() <= 1.0 {
// this indicates the message should not be compressible, to achieve
// this all bytes will be random
topics.message_len()
Expand Down Expand Up @@ -430,7 +430,7 @@ impl Topics {

let ratio = m.len() as f64 / compressed.len() as f64;

if ratio < topics.message_compression_ratio() {
if ratio < topics.compression_ratio() {
break;
}

Expand Down Expand Up @@ -556,7 +556,7 @@ impl Distribution {
impl Keyspace {
pub fn new(config: &Config, keyspace: &config::Keyspace) -> Self {
let value_random_bytes =
if keyspace.value_compression_ratio() <= 1.0 || keyspace.vlen().is_none() {
if keyspace.compression_ratio() <= 1.0 || keyspace.vlen().is_none() {
// this indicates the message should not be compressible, to achieve
// this all bytes will be random
keyspace.vlen().unwrap_or(0)
Expand Down Expand Up @@ -587,7 +587,7 @@ impl Keyspace {

let ratio = m.len() as f64 / compressed.len() as f64;

if ratio < keyspace.value_compression_ratio() {
if ratio < keyspace.compression_ratio() {
break;
}

Expand Down

0 comments on commit 16e3abb

Please sign in to comment.