mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-21 00:54:19 +01:00
cli options for max and min tick + adjust github action to run with faster clock so no timeouts happen
This commit is contained in:
@@ -108,11 +108,23 @@ pub struct SimulatorCLI {
|
||||
#[clap(long, help = "disable Reopen-Database fault", default_value_t = false)]
|
||||
pub disable_reopen_database: bool,
|
||||
#[clap(
|
||||
long = "latency_prob",
|
||||
long = "latency-prob",
|
||||
help = "added IO latency probability",
|
||||
default_value_t = 1
|
||||
)]
|
||||
pub latency_probability: usize,
|
||||
#[clap(
|
||||
long,
|
||||
help = "Minimum tick time in microseconds for simulated time",
|
||||
default_value_t = 1
|
||||
)]
|
||||
pub min_tick: u64,
|
||||
#[clap(
|
||||
long,
|
||||
help = "Maximum tick time in microseconds for simulated time",
|
||||
default_value_t = 30
|
||||
)]
|
||||
pub max_tick: u64,
|
||||
#[clap(long, help = "Enable experimental MVCC feature")]
|
||||
pub experimental_mvcc: bool,
|
||||
#[clap(long, help = "Enable experimental indexing feature")]
|
||||
|
||||
@@ -8,16 +8,17 @@ use rand_chacha::ChaCha8Rng;
|
||||
pub struct SimulatorClock {
|
||||
curr_time: RefCell<DateTime<Utc>>,
|
||||
rng: RefCell<ChaCha8Rng>,
|
||||
min_tick: u64,
|
||||
max_tick: u64,
|
||||
}
|
||||
|
||||
impl SimulatorClock {
|
||||
const MIN_TICK: u64 = 1;
|
||||
const MAX_TICK: u64 = 30;
|
||||
|
||||
pub fn new(rng: ChaCha8Rng) -> Self {
|
||||
pub fn new(rng: ChaCha8Rng, min_tick: u64, max_tick: u64) -> Self {
|
||||
Self {
|
||||
curr_time: RefCell::new(Utc::now()),
|
||||
rng: RefCell::new(rng),
|
||||
min_tick,
|
||||
max_tick,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ impl SimulatorClock {
|
||||
let nanos = self
|
||||
.rng
|
||||
.borrow_mut()
|
||||
.gen_range(Self::MIN_TICK..Self::MAX_TICK);
|
||||
.gen_range(self.min_tick..self.max_tick);
|
||||
let nanos = std::time::Duration::from_micros(nanos);
|
||||
*time += nanos;
|
||||
*time
|
||||
|
||||
@@ -247,8 +247,16 @@ impl SimulatorEnv {
|
||||
experimental_indexes: cli_opts.experimental_indexes,
|
||||
};
|
||||
|
||||
let io =
|
||||
Arc::new(SimulatorIO::new(seed, opts.page_size, cli_opts.latency_probability).unwrap());
|
||||
let io = Arc::new(
|
||||
SimulatorIO::new(
|
||||
seed,
|
||||
opts.page_size,
|
||||
cli_opts.latency_probability,
|
||||
cli_opts.min_tick,
|
||||
cli_opts.max_tick,
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
// Remove existing database file if it exists
|
||||
let db_path = paths.db(&simulation_type, &SimulationPhase::Test);
|
||||
|
||||
@@ -28,13 +28,19 @@ unsafe impl Send for SimulatorIO {}
|
||||
unsafe impl Sync for SimulatorIO {}
|
||||
|
||||
impl SimulatorIO {
|
||||
pub(crate) fn new(seed: u64, page_size: usize, latency_probability: usize) -> Result<Self> {
|
||||
pub(crate) fn new(
|
||||
seed: u64,
|
||||
page_size: usize,
|
||||
latency_probability: usize,
|
||||
min_tick: u64,
|
||||
max_tick: u64,
|
||||
) -> Result<Self> {
|
||||
let inner = Box::new(PlatformIO::new()?);
|
||||
let fault = Cell::new(false);
|
||||
let files = RefCell::new(Vec::new());
|
||||
let rng = RefCell::new(ChaCha8Rng::seed_from_u64(seed));
|
||||
let nr_run_once_faults = Cell::new(0);
|
||||
let clock = SimulatorClock::new(ChaCha8Rng::seed_from_u64(seed));
|
||||
let clock = SimulatorClock::new(ChaCha8Rng::seed_from_u64(seed), min_tick, max_tick);
|
||||
|
||||
Ok(Self {
|
||||
inner,
|
||||
|
||||
Reference in New Issue
Block a user