Skip to content

Commit

Permalink
feat(sysadvisor): add top svc check in borwein model
Browse files Browse the repository at this point in the history
  • Loading branch information
lihonghao314 committed Feb 25, 2025
1 parent 3c1d4db commit 6704716
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
type LatencyRegression struct {
PredictValue float64 `json:"predict_value"`
EquilibriumValue float64 `json:"equilibrium_value"`
Ignore bool `json:"ignore"`
}

func GetLatencyRegressionPredictResult(metaReader metacache.MetaReader) (map[string]map[string]*LatencyRegression, int64, error) {
Expand Down Expand Up @@ -60,6 +61,9 @@ func GetLatencyRegressionPredictResult(metaReader metacache.MetaReader) (map[str
general.Errorf("invalid generic output: %s for %s", result.GenericOutput, inferenceResultKey)
return
}
if specificResult.Ignore {
return
}

if ret[podUID] == nil {
ret[podUID] = make(map[string]*LatencyRegression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,33 @@ import (
func TestGetLatencyRegressionPredictValue(t *testing.T) {
t.Parallel()
timeNow := time.Now().Unix()
res := &LatencyRegression{
res1 := &LatencyRegression{
PredictValue: 0.6,
EquilibriumValue: 0.1,
Ignore: false,
}
bs, _ := json.Marshal(res)
bs1, _ := json.Marshal(res1)
res2 := &LatencyRegression{
PredictValue: 0.7,
EquilibriumValue: 0.1,
Ignore: true,
}
bs2, _ := json.Marshal(res2)
reader := metacache.NewDummyMetaCacheImp()
_ = reader.SetInferenceResult(borweinutils.GetInferenceResultKey(borweinconsts.ModelNameBorweinLatencyRegression), &borweintypes.BorweinInferenceResults{
Timestamp: timeNow,
Results: map[string]map[string][]*borweininfsvc.InferenceResult{
"test": {
"test1": {
"test": []*borweininfsvc.InferenceResult{
{
GenericOutput: string(bs1),
},
},
},
"test2": {
"test": []*borweininfsvc.InferenceResult{
{
GenericOutput: string(bs),
GenericOutput: string(bs2),
},
},
},
Expand All @@ -57,13 +71,13 @@ func TestGetLatencyRegressionPredictValue(t *testing.T) {
name string
args args
want map[string]map[string]*LatencyRegression
want1 int64
wantTs int64
wantErr bool
}{
{
name: "GetLatencyRegressionPredictValue failed",
want: nil,
want1: 0,
wantTs: 0,
wantErr: true,
},
{
Expand All @@ -72,32 +86,30 @@ func TestGetLatencyRegressionPredictValue(t *testing.T) {
metaReader: reader,
},
want: map[string]map[string]*LatencyRegression{
"test": {
"test1": {
"test": &LatencyRegression{
PredictValue: 0.6,
EquilibriumValue: 0.1,
Ignore: false,
},
},
},
want1: timeNow,
wantTs: timeNow,
wantErr: false,
},
}
for _, tt := range tests {
curTT := tt
t.Run(curTT.name, func(t *testing.T) {
t.Parallel()
got, got1, err := GetLatencyRegressionPredictResult(curTT.args.metaReader)
got, _, err := GetLatencyRegressionPredictResult(curTT.args.metaReader)
if (err != nil) != curTT.wantErr {
t.Errorf("GetLatencyRegressionPredictResult() error = %v, wantErr %v", err, curTT.wantErr)
return
}
if !reflect.DeepEqual(got, curTT.want) {
t.Errorf("GetLatencyRegressionPredictResult() got = %v, want %v", got, curTT.want)
}
if got1 != curTT.want1 {
t.Errorf("GetLatencyRegressionPredictResult() got1 = %v, want %v", got1, curTT.want1)
}
})
}
}

0 comments on commit 6704716

Please sign in to comment.