From ac33b568a0bd15c39f22001276b8c4961f8d264d Mon Sep 17 00:00:00 2001 From: Sunyanan Choochotkaew Date: Thu, 24 Aug 2023 18:49:21 +0900 Subject: [PATCH] handle unset idle collection Signed-off-by: Sunyanan Choochotkaew --- pkg/collector/metric/node_metric.go | 14 +++++++++----- pkg/collector/node_energy_collector.go | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pkg/collector/metric/node_metric.go b/pkg/collector/metric/node_metric.go index 56dc425eb9..3a7b4e940c 100644 --- a/pkg/collector/metric/node_metric.go +++ b/pkg/collector/metric/node_metric.go @@ -27,6 +27,7 @@ import ( "github.com/sustainable-computing-io/kepler/pkg/config" "github.com/sustainable-computing-io/kepler/pkg/power/accelerator/gpu" qat "github.com/sustainable-computing-io/kepler/pkg/power/accelerator/qat/source" + "github.com/sustainable-computing-io/kepler/pkg/power/components" "github.com/sustainable-computing-io/kepler/pkg/power/components/source" ) @@ -345,15 +346,18 @@ func (ne *NodeMetrics) SetNodeGPUEnergy(gpuEnergy []uint32, isIdleEnergy bool) { } func (ne *NodeMetrics) UpdateIdleEnergyWithMinValue() { - ne.CalcIdleEnergy(CORE) - ne.CalcIdleEnergy(DRAM) - ne.CalcIdleEnergy(UNCORE) - ne.CalcIdleEnergy(PKG) // gpu metric if config.EnabledGPU && gpu.IsGPUCollectionSupported() { ne.CalcIdleEnergy(GPU) } - ne.CalcIdleEnergy(PLATFORM) + + if components.IsSystemCollectionSupported() { + ne.CalcIdleEnergy(CORE) + ne.CalcIdleEnergy(DRAM) + ne.CalcIdleEnergy(UNCORE) + ne.CalcIdleEnergy(PKG) + ne.CalcIdleEnergy(PLATFORM) + } // reset ne.FoundNewIdleState = false } diff --git a/pkg/collector/node_energy_collector.go b/pkg/collector/node_energy_collector.go index d7de06769c..974b0e9af1 100644 --- a/pkg/collector/node_energy_collector.go +++ b/pkg/collector/node_energy_collector.go @@ -91,11 +91,11 @@ func (c *Collector) updateNodeAvgCPUFrequency(wg *sync.WaitGroup) { // updateNodeIdleEnergy calculates the node idle energy consumption based on the minimum power consumption when real-time system power metrics are accessible. // When the node power model estimator is utilized, the idle power is updated with the estimated power considering minimal resource utilization. func (c *Collector) updateNodeIdleEnergy() { - if components.IsSystemCollectionSupported() { - // the idle energy is only updated if we find the node using less resources than previously observed - // TODO: Use regression to estimate the idle power when real-time system power metrics are available, instead of relying on the minimum power consumption. - c.NodeMetrics.UpdateIdleEnergyWithMinValue() - } else { + // the idle energy is only updated if we find the node using less resources than previously observed + // TODO: Use regression to estimate the idle power when real-time system power metrics are available, instead of relying on the minimum power consumption. + c.NodeMetrics.UpdateIdleEnergyWithMinValue() + if !components.IsSystemCollectionSupported() { + // if power collection on components is not supported, try using estimator to update idle energy if model.IsNodeComponentPowerModelEnabled() { nodeComponentsEnergy := model.GetNodeComponentPowers(&c.NodeMetrics, idlePower) // the node components power model returns gauge mentrics