-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(code/starknet): Add mempool load generator to the Starknet test app #821
base: main
Are you sure you want to change the base?
feat(code/starknet): Add mempool load generator to the Starknet test app #821
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #821 +/- ##
==========================================
- Coverage 76.50% 74.69% -1.81%
==========================================
Files 169 171 +2
Lines 14358 14898 +540
==========================================
+ Hits 10984 11127 +143
- Misses 3374 3771 +397
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
let mut rng = rand::thread_rng(); | ||
let interval = Duration::from_secs(rng.gen_range(1..10)); | ||
let count = rng.gen_range(500..=10000) as usize; | ||
let size = rng.gen_range(128..=512) as usize; | ||
tokio::spawn(ticker(interval, myself.clone(), move || { | ||
Msg::GenerateTransactions { count, size } | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still uniform load but with random parameters. A non-uniform load would have spikes of high load relative to the normal.
Maybe we could do something like this (in pseudo-Rust):
MempoolLoadType::NonUniformLoad {
/// Base transaction count
base_count: usize,
/// Base transaction size
base_size: usize,
/// How much the transaction count can vary
count_variation: std::ops::Range<i32>,
size_variation: std::ops::Range<i32>,
/// Chance of generating a spike.
/// e.g. 0.1 = 10% chance of spike
spike_probability: f64,
/// Multiplier for spike transactions
/// e.g. 10 = 10x more transactions during spike
spike_multiplier: usize,
/// Range of intervals between generating load, in milliseconds
sleep_interval: std::ops::Range<u64>,
}
tokio::spawn(move async {
// Determine if this iteration should generate a spike
let is_spike = rng.gen_bool(params.spike_probability);
// Vary transaction count and size
let count_variation = rng.gen_range(params.count_variation);
let size_variation = rng.gen_range(params.size_variation);
let count = if is_spike {
(params.base_count + count_variation) * params.spike_multiplier
} else {
params.base_count + count_variation
};
let size = params.base_size + size_variation;
// Create and send the message
let msg = HostMsg::GenerateTransactions {
count: count.max(1), // Ensure count is at least 1
size: size.max(1), // Ensure size is at least 1
};
if myself.send(msg).is_err() {
println!("Channel closed, stopping load generator");
break;
}
// Random sleep between 100ms and 1s
let sleep_duration = Duration::from_millis(params.sleep_interval);
sleep(sleep_duration);
Note that this does not require ticker
as the sleep duration is random.
Closes: #801
PR author checklist
For all contributors
For external contributors