diff --git a/simulator/generation/property.rs b/simulator/generation/property.rs index 4d200bad6..8fe207685 100644 --- a/simulator/generation/property.rs +++ b/simulator/generation/property.rs @@ -1046,32 +1046,25 @@ pub(crate) fn remaining( opts: &QueryProfile, stats: &InteractionStats, ) -> Remaining { - let total_weight = opts.read_weight + opts.write_weight; - - // Total amount of reads. Only considers select operations - let total_reads = (max_interactions * opts.read_weight) / total_weight; - // Total amount of writes. - let total_writes = (max_interactions * opts.write_weight) / total_weight; - - let remaining_select = total_reads - .checked_sub(stats.select_count) - .unwrap_or_default(); - - // This total is the sum of all the query weights that are write operations - let sum_write_weight = opts.create_table_weight + let total_weight = opts.select_weight + + opts.create_table_weight + opts.create_index_weight + opts.insert_weight + opts.update_weight + opts.delete_weight + opts.drop_table_weight; - let total_insert = (total_writes * opts.insert_weight) / sum_write_weight; - let total_create = (total_writes * opts.create_table_weight) / sum_write_weight; - let total_create_index = (total_writes * opts.create_index_weight) / sum_write_weight; - let total_delete = (total_writes * opts.delete_weight) / sum_write_weight; - let total_update = (total_writes * opts.update_weight) / sum_write_weight; - let total_drop = (total_writes * opts.drop_table_weight) / sum_write_weight; + let total_select = (max_interactions * opts.select_weight) / total_weight; + let total_insert = (max_interactions * opts.insert_weight) / total_weight; + let total_create = (max_interactions * opts.create_table_weight) / total_weight; + let total_create_index = (max_interactions * opts.create_index_weight) / total_weight; + let total_delete = (max_interactions * opts.delete_weight) / total_weight; + let total_update = (max_interactions * opts.update_weight) / total_weight; + let total_drop = (max_interactions * opts.drop_table_weight) / total_weight; + let remaining_select = total_select + .checked_sub(stats.select_count) + .unwrap_or_default(); let remaining_insert = total_insert .checked_sub(stats.insert_count) .unwrap_or_default(); diff --git a/simulator/profiles/mod.rs b/simulator/profiles/mod.rs index 553aa9f26..44c4d5bc4 100644 --- a/simulator/profiles/mod.rs +++ b/simulator/profiles/mod.rs @@ -48,8 +48,8 @@ impl Profile { // TODO: increase number of rows as well ..Default::default() }, - read_weight: 30, - write_weight: 70, + select_weight: 30, + insert_weight: 70, delete_weight: 0, update_weight: 0, ..Default::default() diff --git a/simulator/profiles/query.rs b/simulator/profiles/query.rs index d331dac4c..a58c983e0 100644 --- a/simulator/profiles/query.rs +++ b/simulator/profiles/query.rs @@ -9,12 +9,7 @@ pub struct QueryProfile { #[garde(dive)] pub gen_opts: Opts, #[garde(skip)] - /// Effectively the weight of how many select operations we want - pub read_weight: u32, - #[garde(skip)] - pub write_weight: u32, - // All weights below are only going to be sampled when we determine we are doing a write operation, - // meaning we first sample between `read_weight` and `write_weight`, and if we a write_weight we will then sample the weights below + pub select_weight: u32, #[garde(skip)] pub create_table_weight: u32, #[garde(skip)] @@ -33,8 +28,7 @@ impl Default for QueryProfile { fn default() -> Self { Self { gen_opts: Opts::default(), - read_weight: 60, - write_weight: 50, + select_weight: 60, create_table_weight: 15, create_index_weight: 5, insert_weight: 30,