Skip to content

Commit

Permalink
Use the CPU utilization of the hottest cluster rather than the averag…
Browse files Browse the repository at this point in the history
…e of the whole instance.

PiperOrigin-RevId: 597274776
  • Loading branch information
bvliu authored and copybara-github committed Jan 10, 2024
1 parent bec1847 commit e45a0fa
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions perfkitbenchmarker/providers/gcp/gcp_bigtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def _Restore(self) -> None:
def GetAverageCpuUsage(
self, duration_minutes: int, end_time: datetime.datetime
) -> float:
"""Gets the average CPU usage for the cluster.
"""Gets the average CPU usage for the instance.
Note that there is a delay for the API to get data, so this returns the
average CPU usage in the period ending at `end_time` with missing data
Expand All @@ -507,7 +507,8 @@ def GetAverageCpuUsage(
end_time: The ending timestamp of the workload.
Returns:
The average CPU usage during the time period.
The average CPU usage during the time period. In the case of multiple
clusters, this returns the average CPU of the hottest cluster.
"""
if duration_minutes * 60 <= CPU_API_DELAY_SECONDS:
raise ValueError(
Expand All @@ -530,7 +531,7 @@ def GetAverageCpuUsage(
cpu_query = cpu_query.select_resources(instance=self.name)
time_series = list(cpu_query)

instance_total_utilization = 0.0
instance_utilization_by_cluster = []
for cluster_time_series in time_series:
cluster_total_utilization = 0.0
cluster_name = cluster_time_series.resource.labels['cluster']
Expand All @@ -550,10 +551,13 @@ def GetAverageCpuUsage(
cluster_name,
cluster_average_utilization,
)
instance_total_utilization += cluster_average_utilization
instance_utilization_by_cluster.append(cluster_average_utilization)

average_utilization = instance_total_utilization / len(time_series)
logging.info('Instance average CPU utilization: %s', average_utilization)
average_utilization = max(instance_utilization_by_cluster)
logging.info(
'Instance average CPU utilization (hottest cluster): %s',
average_utilization,
)
return average_utilization

def CalculateTheoreticalMaxThroughput(
Expand Down

0 comments on commit e45a0fa

Please sign in to comment.