mirror of
https://github.com/wassname/ray.git
synced 2026-07-29 11:26:04 +08:00
[autoscaler/dashboard] Publish resource usage in units of bytes (#14002)
This commit is contained in:
@@ -5,6 +5,7 @@ import time
|
||||
from typing import Dict, List
|
||||
|
||||
import numpy as np
|
||||
import ray.ray_constants
|
||||
import ray._private.services as services
|
||||
from ray.autoscaler._private.constants import MEMORY_RESOURCE_UNIT_BYTES,\
|
||||
AUTOSCALER_MAX_RESOURCE_DEMAND_VECTOR_SIZE
|
||||
@@ -212,8 +213,15 @@ class LoadMetrics:
|
||||
) if self.static_resources_by_ip else {}
|
||||
usage_dict = {}
|
||||
for key in total_resources:
|
||||
total = total_resources[key]
|
||||
usage_dict[key] = (total - available_resources[key], total)
|
||||
if key in ["memory", "object_store_memory"]:
|
||||
total = total_resources[key] * \
|
||||
ray.ray_constants.MEMORY_RESOURCE_UNIT_BYTES
|
||||
available = available_resources[key] * \
|
||||
ray.ray_constants.MEMORY_RESOURCE_UNIT_BYTES
|
||||
usage_dict[key] = (total - available, total)
|
||||
else:
|
||||
total = total_resources[key]
|
||||
usage_dict[key] = (total - available_resources[key], total)
|
||||
|
||||
summarized_demand_vector = freq_of_dicts(
|
||||
self.get_resource_demand_vector(clip=False))
|
||||
|
||||
@@ -313,12 +313,12 @@ def format_pg(pg):
|
||||
|
||||
def get_usage_report(lm_summary) -> str:
|
||||
usage_lines = []
|
||||
for resource, (used, total) in lm_summary.usage.items():
|
||||
for resource, (used, total) in sorted(lm_summary.usage.items()):
|
||||
if "node:" in resource:
|
||||
continue # Skip the auto-added per-node "node:<ip>" resource.
|
||||
line = f" {used}/{total} {resource}"
|
||||
if resource in ["memory", "object_store_memory"]:
|
||||
to_GiB = ray.ray_constants.MEMORY_RESOURCE_UNIT_BYTES / 2**30
|
||||
to_GiB = 1 / 2**30
|
||||
used *= to_GiB
|
||||
total *= to_GiB
|
||||
line = f" {used:.2f}/{total:.3f} GiB {resource}"
|
||||
|
||||
Reference in New Issue
Block a user