From 8ab6a04d3fedcdc0c4d2e1e14031b7b7e16328fa Mon Sep 17 00:00:00 2001 From: linzhecheng Date: Fri, 26 Jan 2024 12:07:10 +0800 Subject: [PATCH] refactor(sysadvisor): add metric and tag Signed-off-by: linzhecheng --- .../qosaware/resource/cpu/region/region_base.go | 4 +++- .../plugin/provisioner/policy/policy_canonical.go | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/region/region_base.go b/pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/region/region_base.go index e3b17432b..d0956ebe2 100644 --- a/pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/region/region_base.go +++ b/pkg/agent/sysadvisor/plugin/qosaware/resource/cpu/region/region_base.go @@ -49,6 +49,7 @@ const ( metricTagKeyPolicyName = "policy_name" metricTagKeyRegionType = "region_type" metricTagKeyRegionName = "region_name" + metricTagKeyRegionNUMAs = "region_numas" metricTagKeyControlKnobName = "control_knob_name" metricTagKeyControlKnobAction = "control_knob_action" ) @@ -389,7 +390,8 @@ func (r *QoSRegionBase) GetHeadroom() (float64, error) { } _ = r.emitter.StoreFloat64(metricRegionHeadroom, headroom, metrics.MetricTypeNameRaw, metrics.ConvertMapToTags(map[string]string{metricTagKeyRegionType: string(r.regionType), - metricTagKeyRegionName: r.name, metricTagKeyPolicyName: string(internal.name)})...) + metricTagKeyRegionName: r.name, metricTagKeyPolicyName: string(internal.name), + metricTagKeyRegionNUMAs: r.bindingNumas.String()})...) r.headroomPolicyNameInUse = internal.name return headroom, nil } diff --git a/pkg/agent/sysadvisor/plugin/qosaware/resource/memory/plugin/provisioner/policy/policy_canonical.go b/pkg/agent/sysadvisor/plugin/qosaware/resource/memory/plugin/provisioner/policy/policy_canonical.go index fa000334f..8976eed10 100644 --- a/pkg/agent/sysadvisor/plugin/qosaware/resource/memory/plugin/provisioner/policy/policy_canonical.go +++ b/pkg/agent/sysadvisor/plugin/qosaware/resource/memory/plugin/provisioner/policy/policy_canonical.go @@ -18,6 +18,7 @@ package policy import ( "fmt" + "strconv" "github.com/kubewharf/katalyst-core/pkg/agent/sysadvisor/plugin/qosaware/resource/helper" "github.com/kubewharf/katalyst-core/pkg/consts" @@ -31,6 +32,11 @@ import ( "github.com/kubewharf/katalyst-core/pkg/util/machine" ) +const ( + metricMemoryNUMAProvision = "memory_numa_provision" + metricTagKeyNUMAID = "numa_id" +) + type PolicyCanonical struct { *PolicyBase memoryProvisions machine.MemoryDetails @@ -120,7 +126,11 @@ func (p *PolicyCanonical) Update() error { systemWatermarkReservedAvg := uint64(int(systemWatermarkReserved) / nums) for numaID := range memoryProvisions { - memoryProvisions[numaID] = uint64(general.Clamp(float64(memoryProvisions[numaID]-reservedAvg-systemWatermarkReservedAvg), .0, float64(memoryTotals[numaID]))) + provison := uint64(general.Clamp(float64(memoryProvisions[numaID]-reservedAvg-systemWatermarkReservedAvg), .0, float64(memoryTotals[numaID]))) + memoryProvisions[numaID] = provison + + p.emitter.StoreInt64(metricMemoryNUMAProvision, int64(provison), metrics.MetricTypeNameRaw, + metrics.ConvertMapToTags(map[string]string{metricTagKeyNUMAID: strconv.Itoa(numaID)})...) } // set other numa nodes to 0