From 065069a524b8a68085e666c8cfcc74238454a670 Mon Sep 17 00:00:00 2001 From: Akashdeep Goel Date: Wed, 29 May 2024 11:59:59 -0700 Subject: [PATCH] Fix typecasting and adjust disk io --- service_capacity_modeling/models/common.py | 16 +++++++++------- .../models/org/netflix/evcache.py | 3 +-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/service_capacity_modeling/models/common.py b/service_capacity_modeling/models/common.py index b89fe8f..465b335 100644 --- a/service_capacity_modeling/models/common.py +++ b/service_capacity_modeling/models/common.py @@ -229,8 +229,8 @@ def compute_stateful_zone( # Some stateful clusters have preferences on per zone sizing cluster_size: Callable[[int], int] = lambda x: x, min_count: int = 0, - adjusted_disk_io_needed: Optional[float] = 0.0, - read_write_ratio: Optional[float] = 0.0 + adjusted_disk_io_needed: float = 0.0, + read_write_ratio: float = 0.0 ) -> ZoneClusterCapacity: # Normalize the cores of this instance type to the latency reference @@ -273,11 +273,13 @@ def compute_stateful_zone( disk_per_node = min(max_local_disk_gib, instance.drive.size_gib) count = max(count, math.ceil(needed_disk_gib / disk_per_node)) if adjusted_disk_io_needed != 0.0: - instance_read_iops = drive.read_io_per_s - instance_write_iops = drive.write_io_per_s - instance_adjusted_io = (read_write_ratio * instance_read_iops + \ - (1.0 - read_write_ratio) * instance_write_iops) * \ - drive.block_size_kib * 1024.0 + instance_read_iops = instance.drive.read_io_per_s if instance.drive.read_io_per_s != None else 0 + assert (isinstance(instance_read_iops, int)) + instance_write_iops = instance.drive.write_io_per_s if instance.drive.write_io_per_s != None else 0 + assert (isinstance(instance_write_iops, int)) + instance_adjusted_io = (read_write_ratio * float(instance_read_iops) + \ + (1.0 - read_write_ratio) * float(instance_write_iops)) * \ + instance.drive.block_size_kib * 1024.0 if instance_adjusted_io != 0.0: count = max(count, math.ceil(adjusted_disk_io_needed / instance_adjusted_io)) diff --git a/service_capacity_modeling/models/org/netflix/evcache.py b/service_capacity_modeling/models/org/netflix/evcache.py index a586611..df1988e 100644 --- a/service_capacity_modeling/models/org/netflix/evcache.py +++ b/service_capacity_modeling/models/org/netflix/evcache.py @@ -242,8 +242,7 @@ def reserve_memory(instance_mem_gib): write_size = desires.query_pattern.estimated_mean_write_size_bytes.mid read_disk_io_needed = reads_per_sec * read_size write_disk_io_needed = writes_per_sec * write_size - adjusted_disk_io_needed = (reads_per_sec * read_disk_io_needed + writes_per_sec * write_disk_io_needed) / \ - (reads_per_sec + writes_per_sec) + adjusted_disk_io_needed = read_disk_io_needed + write_disk_io_needed read_write_ratio = reads_per_sec / (reads_per_sec + writes_per_sec) cluster = compute_stateful_zone(