Skip to content

Commit

Permalink
hwgraph: Adding metric get_full_name()
Browse files Browse the repository at this point in the history
When loading metrics, it appear that some can have the same name making
invalid data, data name and misleading graphs.

This was seen in issue #36.

The BMC reported the two following structures :

          "CPU": {
            "02-CPU 1 PkgTmp": {
              "name": "CPU1",
              "unit": "Celsius",
              "mean": [
	  [...]
            "12-CPU 1": {
              "name": "CPU1",
              "unit": "Celsius",
              "mean": [

As we use the name member, we got the two different metrics being merged
as a single one.

This patch is adding a workaround by consider the parent's name as the
"full_name" of the metric.

So this patch is adding this value, like "12-CPU 1", as the full name
and reachable via get_full_name().

This commit ensures the env graphs are using this full name to avoid
smashing metrics.

Signed-off-by: Erwan Velu <e.velu@criteo.com>
  • Loading branch information
ErwanAliasr1 committed Oct 25, 2024
1 parent 503e5ba commit c7669f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 5 additions & 5 deletions graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ def generic_graph(
time_serie.append(time)
# Collect all components mean value
for component in components:
if component.get_name() not in data_serie:
data_serie[component.get_name()] = []
data_serie[component.get_name()].append(component.get_mean()[sample])
if component.get_full_name() not in data_serie:
data_serie[component.get_full_name()] = []
data_serie[component.get_full_name()].append(component.get_mean()[sample])

if second_axis:
for _, entry in bench.get_monitoring_metric(second_axis).items():
Expand Down Expand Up @@ -291,8 +291,8 @@ def generic_graph(
graph.get_ax2().plot(x_serie, y2_serie, "", label=data2_item, marker="o")

for component in components:
y_serie = np.array(data_serie[component.get_name()])[order]
graph.get_ax().plot(x_serie, y_serie, "", label=component.get_name())
y_serie = np.array(data_serie[component.get_full_name()])[order]
graph.get_ax().plot(x_serie, y_serie, "", label=component.get_full_name())

graph.prepare_axes(
30,
Expand Down
2 changes: 1 addition & 1 deletion graph/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def load_monitoring(self):
mm = Temperature(measure, original_measure["unit"])
else:
mm = MonitorMetric(measure, original_measure["unit"])
mm.load_from_dict(original_measure)
mm.load_from_dict(original_measure, measure)
self.metrics[metric][component_family][measure] = mm
else:
fatal(f"Unexpected {metric} in monitoring")
Expand Down
9 changes: 8 additions & 1 deletion hwbench/bench/monitoring_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def __post_init__(self):
# If a value is given, let's add it
self.add(self.value)

def load_from_dict(self, input: dict):
def load_from_dict(self, input: dict, full_name: str):
self.full_name = full_name
self.name = str(input.get("name"))
self.unit = str(input.get("unit"))
self.mean = input.get("mean") # type: ignore[assignment]
Expand All @@ -35,6 +36,12 @@ def load_from_dict(self, input: dict):
self.stdev = input.get("stdev") # type: ignore[assignment]
self.samples = input.get("samples") # type: ignore[assignment]

def get_full_name(self):
"""Return the metric full name"""
if self.full_name:
return self.full_name
return self.name

def get_name(self):
"""Return the metric name"""
return self.name
Expand Down

0 comments on commit c7669f9

Please sign in to comment.