Skip to content

Commit

Permalink
refactor(sysadvisor): add metric and tag
Browse files Browse the repository at this point in the history
Signed-off-by: linzhecheng <linzhecheng@bytedance.com>
  • Loading branch information
cheney-lin committed Jan 26, 2024
1 parent df34d1e commit 8ab6a04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8ab6a04

Please sign in to comment.