From 5734f51130cb4f2276fe30a1d98c955d60fba930 Mon Sep 17 00:00:00 2001 From: Akashdeep Goel Date: Mon, 3 Jun 2024 10:43:05 -0700 Subject: [PATCH] Fix indendation --- service_capacity_modeling/models/common.py | 36 +++++++++++++------ .../models/org/netflix/evcache.py | 6 ++-- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/service_capacity_modeling/models/common.py b/service_capacity_modeling/models/common.py index 465b335..ddb4b1a 100644 --- a/service_capacity_modeling/models/common.py +++ b/service_capacity_modeling/models/common.py @@ -199,6 +199,7 @@ def compute_stateless_region( # pylint: disable=too-many-locals +# pylint: disable=too-many-statements def compute_stateful_zone( instance: Instance, drive: Drive, @@ -230,9 +231,8 @@ def compute_stateful_zone( cluster_size: Callable[[int], int] = lambda x: x, min_count: int = 0, adjusted_disk_io_needed: float = 0.0, - read_write_ratio: float = 0.0 + read_write_ratio: float = 0.0, ) -> ZoneClusterCapacity: - # Normalize the cores of this instance type to the latency reference needed_cores = math.ceil( max(1, needed_cores // (instance.cpu_ghz / core_reference_ghz)) @@ -273,16 +273,30 @@ 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 = 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 + instance_read_iops = ( + instance.drive.read_io_per_s + if instance.drive.read_io_per_s is not 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 is not 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)) - + count = max( + count, math.ceil(adjusted_disk_io_needed / instance_adjusted_io) + ) count = max(cluster_size(count), min_count) cost = count * instance.annual_cost diff --git a/service_capacity_modeling/models/org/netflix/evcache.py b/service_capacity_modeling/models/org/netflix/evcache.py index df1988e..754acf1 100644 --- a/service_capacity_modeling/models/org/netflix/evcache.py +++ b/service_capacity_modeling/models/org/netflix/evcache.py @@ -243,6 +243,8 @@ def reserve_memory(instance_mem_gib): read_disk_io_needed = reads_per_sec * read_size write_disk_io_needed = writes_per_sec * write_size adjusted_disk_io_needed = read_disk_io_needed + write_disk_io_needed + # Giving headroom for cachewarming and region squeeze + adjusted_disk_io_needed = 1.4 * adjusted_disk_io_needed read_write_ratio = reads_per_sec / (reads_per_sec + writes_per_sec) cluster = compute_stateful_zone( @@ -261,8 +263,8 @@ def reserve_memory(instance_mem_gib): # Sidecars and Variable OS Memory reserve_memory=lambda x: base_mem, core_reference_ghz=requirement.core_reference_ghz, - adjusted_disk_io_needed = adjusted_disk_io_needed, - read_write_ratio = read_write_ratio + adjusted_disk_io_needed=adjusted_disk_io_needed, + read_write_ratio=read_write_ratio, ) # Communicate to the actual provision that if we want reduced RF params = {"evcache.copies": copies_per_region}