Skip to content

Commit

Permalink
Merge pull request #976 from sunya-ch/model-server
Browse files Browse the repository at this point in the history
move model initialization after BPF attach
  • Loading branch information
Marcelo Carneiro do Amaral authored Oct 10, 2023
2 parents 8529097 + c9f69ea commit 34f6562
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
9 changes: 0 additions & 9 deletions cmd/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
collector_metric "github.com/sustainable-computing-io/kepler/pkg/collector/metric"
"github.com/sustainable-computing-io/kepler/pkg/config"
"github.com/sustainable-computing-io/kepler/pkg/manager"
"github.com/sustainable-computing-io/kepler/pkg/model"
"github.com/sustainable-computing-io/kepler/pkg/power/accelerator/gpu"
"github.com/sustainable-computing-io/kepler/pkg/power/accelerator/qat"
"github.com/sustainable-computing-io/kepler/pkg/power/components"
Expand Down Expand Up @@ -229,14 +228,6 @@ func main() {
}
}

// For local estimator, there is endpoint provided, thus we should let
// model component decide whether/how to init
model.CreatePowerEstimatorModels(
collector_metric.ContainerFeaturesNames,
collector_metric.NodeMetadataFeatureNames,
collector_metric.NodeMetadataFeatureValues,
)

m := manager.New()
prometheus.MustRegister(version.NewCollector("kepler_exporter"))
prometheus.MustRegister(m.PrometheusCollector)
Expand Down
9 changes: 9 additions & 0 deletions pkg/collector/metric_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/sustainable-computing-io/kepler/pkg/bpfassets/attacher"
"github.com/sustainable-computing-io/kepler/pkg/cgroup"
"github.com/sustainable-computing-io/kepler/pkg/config"
"github.com/sustainable-computing-io/kepler/pkg/model"
"github.com/sustainable-computing-io/kepler/pkg/power/accelerator/gpu"
"github.com/sustainable-computing-io/kepler/pkg/power/accelerator/qat"
"github.com/sustainable-computing-io/kepler/pkg/utils"
Expand Down Expand Up @@ -81,6 +82,14 @@ func (c *Collector) Initialize() error {
return err
}

// For local estimator, there is endpoint provided, thus we should let
// model component decide whether/how to init
model.CreatePowerEstimatorModels(
collector_metric.ContainerFeaturesNames,
collector_metric.NodeMetadataFeatureNames,
collector_metric.NodeMetadataFeatureValues,
)

c.prePopulateContainerMetrics(pods)
c.updateNodeEnergyMetrics()

Expand Down
9 changes: 8 additions & 1 deletion pkg/model/container_energy.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ func createContainerPowerModelConfig(powerSourceTarget string, containerFeatureN
collector_metric.GPU + "_IDLE", // for idle GPU power consumption
}...)
} else if powerSourceTarget == config.ContainerPlatformPowerKey {
platformUsageMetric := config.CoreUsageMetric
if !attacher.HardwareCountersEnabled {
// Given that there is no HW counter in some scenarios (e.g. on VMs), we have to use CPUTime data.
platformUsageMetric = config.CPUTime
}
modelConfig.ContainerFeatureNames = []string{
config.CoreUsageMetric, // for PLATFORM resource usage
platformUsageMetric, // for PLATFORM resource usage
}
modelConfig.NodeFeatureNames = modelConfig.ContainerFeatureNames
modelConfig.NodeFeatureNames = append(modelConfig.NodeFeatureNames, []string{
Expand All @@ -107,6 +112,7 @@ func CreateContainerPowerEstimatorModel(containerFeatureNames, systemMetaDataFea
ContainerPlatformPowerModel, err = createPowerModelEstimator(modelConfig)
if err == nil {
klog.Infof("Using the %s Power Model to estimate Container Platform Power", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String())
klog.Infof("Container feature names: %v", modelConfig.ContainerFeatureNames)
} else {
klog.Infof("Failed to create %s Power Model to estimate Container Platform Power: %v\n", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String(), err)
}
Expand All @@ -116,6 +122,7 @@ func CreateContainerPowerEstimatorModel(containerFeatureNames, systemMetaDataFea
ContainerComponentPowerModel, err = createPowerModelEstimator(modelConfig)
if err == nil {
klog.Infof("Using the %s Power Model to estimate Container Component Power", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String())
klog.Infof("Container feature names: %v", modelConfig.ContainerFeatureNames)
} else {
klog.Infof("Failed to create %s Power Model to estimate Container Component Power: %v\n", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String(), err)
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/model/process_power.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ func createProcessPowerModelConfig(powerSourceTarget string, processFeatureNames
collector_metric.GPU + "_IDLE", // for idle GPU power consumption
}...)
} else if powerSourceTarget == config.ProcessPlatformPowerKey {
platformUsageMetric := config.CoreUsageMetric
if !attacher.HardwareCountersEnabled {
// Given that there is no HW counter in some scenarios (e.g. on VMs), we have to use CPUTime data.
platformUsageMetric = config.CPUTime
}
modelConfig.ContainerFeatureNames = []string{
config.CoreUsageMetric, // for PLATFORM resource usage
platformUsageMetric, // for PLATFORM resource usage
}
modelConfig.NodeFeatureNames = modelConfig.ContainerFeatureNames
modelConfig.NodeFeatureNames = append(modelConfig.NodeFeatureNames, []string{
Expand All @@ -106,6 +111,7 @@ func CreateProcessPowerEstimatorModel(processFeatureNames, systemMetaDataFeature
ProcessPlatformPowerModel, err = createPowerModelEstimator(modelConfig)
if err == nil {
klog.Infof("Using the %s Power Model to estimate Process Platform Power", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String())
klog.Infof("Container feature names: %v", modelConfig.ContainerFeatureNames)
} else {
klog.Infof("Failed to create %s Power Model to estimate Process Platform Power: %v\n", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String(), err)
}
Expand All @@ -115,6 +121,7 @@ func CreateProcessPowerEstimatorModel(processFeatureNames, systemMetaDataFeature
ProcessComponentPowerModel, err = createPowerModelEstimator(modelConfig)
if err == nil {
klog.Infof("Using the %s Power Model to estimate Process Component Power", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String())
klog.Infof("Container feature names: %v", modelConfig.ContainerFeatureNames)
} else {
klog.Infof("Failed to create %s Power Model to estimate Process Component Power: %v\n", modelConfig.ModelType.String()+"/"+modelConfig.ModelOutputType.String(), err)
}
Expand Down

0 comments on commit 34f6562

Please sign in to comment.